11SHELL  := /bin/bash
22V  ?= 0
3- TEST_LIST  ?= $(wildcard  test_* /* .ino) 
43ESP8266_CORE_PATH  ?= $(realpath  ../..) 
54BUILD_DIR  ?= $(PWD ) /.build
65HARDWARE_DIR  ?= $(PWD ) /.hardware
@@ -18,6 +17,12 @@ TEST_CONFIG := test_env.cfg
1817TEST_REPORT_XML  := test_report.xml
1918TEST_REPORT_HTML  := test_report.html
2019
20+ ifeq  ("$(MOCK ) ", "1")
21+ #  To enable a test for mock testing, just rename dir+files to '*_sw_*'
22+ TEST_LIST  ?= $(wildcard  test_sw_* /* .ino) 
23+ else 
24+ TEST_LIST  ?= $(wildcard  test_* /* .ino) 
25+ endif 
2126
2227ifneq  ("$(V ) ","1")
2328	SILENT = @
2934endif 
3035
3136help :
32- 	@echo ' make list                           - show list of tests' 
33- 	@echo ' make [V=1] sometest/sometest.ino    - run one test' 
34- 	@echo ' make [V=1] all                      - run all tests' 
35- 	@echo ' variables needed: $$ARDUINO_IDE_PATH' 
37+ 	@echo
38+ 	@echo ' make list                    - show list of tests' 
39+ 	@echo ' make sometest/sometest.ino   - run one test' 
40+ 	@echo ' make all                     - run all tests' 
41+ 	@echo ' make MOCK=1 all              - run all emulation-on-host compatible tests' 
42+ 	@echo ' variables needed: $$ARDUINO_IDE_PATH $$ESP8266_CORE_PATH' 
43+ 	@echo ' make options: V=1 NO_BUILD=1 NO_UPLOAD=1 NO_RUN=1 MOCK=1' 
44+ 	@echo
3645
3746list : showtestlist
3847
@@ -53,6 +62,18 @@ $(TEST_LIST):
5362	@echo " --------------------------------" 
5463	@echo " Running test '$@ ' of $( words $( TEST_LIST) )   tests" 
5564	$(SILENT ) mkdir -p $(LOCAL_BUILD_DIR ) 
65+ ifeq  ("$(MOCK ) ", "1")
66+ 	@echo Compiling $(notdir $@)
67+ 	(cd ../host; make ULIBDIRS=../device/libraries/BSTest ../device/$(@:%.ino=%))
68+ 	$(SILENT)source $(BS_DIR)/virtualenv/bin/activate && \
69+ 		$(PYTHON) $(BS_DIR)/runner.py \
70+ 			$(RUNNER_DEBUG_FLAG) \
71+ 			-e "$(ESP8266_CORE_PATH)/tests/host/bin/$(@:%.ino=%)" \
72+ 			-n $(basename $(notdir $@)) \
73+ 			-o $(LOCAL_BUILD_DIR)/test_result.xml \
74+ 			--env-file $(TEST_CONFIG) \
75+ 			`test -f $(addsuffix .py, $(basename $@)) && echo "-m $(addsuffix .py, $(basename $@))" || echo ""`
76+ else 
5677ifneq  ("$(NO_BUILD ) ","1")
5778	@test -n "$(ARDUINO_IDE_PATH)" || (echo "Please export ARDUINO_IDE_PATH" && exit 1)
5879	@echo Compiling $(notdir $@)
@@ -108,6 +129,7 @@ ifneq ("$(NO_RUN)","1")
108129			--env-file $(TEST_CONFIG) \
109130			`test -f $(addsuffix .py, $(basename $@)) && echo "-m $(addsuffix .py, $(basename $@))" || echo ""`
110131endif 
132+ endif 
111133
112134$(TEST_REPORT_XML )  : $(HARDWARE_DIR )  virtualenv
113135	$(SILENT )$(BS_DIR ) /xunitmerge $(shell  find $(BUILD_DIR )  -name 'test_result.xml' | xargs echo)  $(TEST_REPORT_XML ) 
0 commit comments