83 |
87 |
84 define make_src_rule |
88 define make_src_rule |
85 $(build_dir)/$(1)/$($(1)_checksum).sha1: $(build_dir) $(workspace)/$(1) |
89 $(build_dir)/$(1)/$($(1)_checksum).sha1: $(build_dir) $(workspace)/$(1) |
86 rm -rf $(build_dir)/$(1) |
90 rm -rf $(build_dir)/$(1) |
87 tar -C $(workspace) $(tar_opts) -c $(1) | tar -C $(build_dir) -x |
91 tar -C $(workspace) $(tar_opts) -c $(1) | tar -C $(build_dir) -x |
88 #cp -a $(workspace)/$(1) $(build_dir)/$(1) |
|
89 touch $$@ |
92 touch $$@ |
90 endef |
93 endef |
91 $(foreach project,$(OWN_PROJECTS),$(eval $(call make_src_rule,$(project)))) |
94 $(foreach project,$(OWN_PROJECTS),$(eval $(call make_src_rule,$(project)))) |
92 |
95 |
93 $(build_dir)/matiec/iec2c: | $(build_dir)/matiec/$(matiec_checksum).sha1 |
96 $(build_dir)/matiec/iec2c: | $(build_dir)/matiec/$(matiec_checksum).sha1 |
94 cd $(build_dir)/matiec && \ |
97 cd $(build_dir)/matiec && \ |
95 autoreconf -i && \ |
98 autoreconf -i && \ |
96 ./configure && \ |
99 ./configure && \ |
97 make |
100 make |
98 |
101 |
99 # TODO: use packge (deb/snap ?) |
|
100 own_apps: $(build_dir)/matiec/iec2c $(build_dir)/beremiz/$(beremiz_checksum).sha1 |
102 own_apps: $(build_dir)/matiec/iec2c $(build_dir)/beremiz/$(beremiz_checksum).sha1 |
101 touch $@ |
103 touch $@ |
|
104 |
|
105 define log_command |
|
106 $(call $(1),$(2)) | tee test_stdout.txt; exit $$$${PIPESTATUS[0]} |
|
107 endef |
|
108 |
|
109 define prep_test |
|
110 rm -rf $(test_dir)/$(1)_results |
|
111 mkdir $(test_dir)/$(1)_results |
|
112 cd $(test_dir)/$(1)_results |
|
113 endef |
|
114 |
|
115 # |
|
116 # IDE TESTS |
|
117 # |
102 |
118 |
103 ide_test_dir = $(src)/ide_tests |
119 ide_test_dir = $(src)/ide_tests |
104 sikuli_ide_tests = $(subst $(ide_test_dir)/,,$(wildcard $(ide_test_dir)/*.sikuli)) |
120 sikuli_ide_tests = $(subst $(ide_test_dir)/,,$(wildcard $(ide_test_dir)/*.sikuli)) |
105 pytest_ide_tests = $(subst $(ide_test_dir)/,,$(wildcard $(ide_test_dir)/*.pytest)) |
121 pytest_ide_tests = $(subst $(ide_test_dir)/,,$(wildcard $(ide_test_dir)/*.pytest)) |
106 |
122 |
107 define sikuli_idetest_command |
123 define sikuli_idetest_command |
108 (fluxbox >/dev/null 2>&1 &); BEREMIZPATH=$(build_dir)/beremiz sikulix -r $(src)/ide_tests/$(1) | tee test_stdout.txt; exit $$$${PIPESTATUS[0]} |
124 (fluxbox >/dev/null 2>&1 &); BEREMIZPATH=$(build_dir)/beremiz sikulix -r $(src)/ide_tests/$(1) |
109 endef |
125 endef |
110 |
126 |
111 |
127 |
112 DELAY=400 |
128 DELAY=400 |
113 KILL_DELAY=430 |
129 KILL_DELAY=430 |
114 PYTEST=$(dir $(BEREMIZPYTHONPATH))/pytest |
130 PYTEST=$(dir $(BEREMIZPYTHONPATH))/pytest |
115 define pytest_idetest_command |
131 define pytest_idetest_command |
116 (fluxbox >/dev/null 2>&1 &); PYTHONPATH=$(ide_test_dir) timeout -k $(KILL_DELAY) $(DELAY) $(PYTEST) --maxfail=1 --timeout=100 $(src)/ide_tests/$(1) | tee test_stdout.txt; exit $$$${PIPESTATUS[0]} |
132 (fluxbox >/dev/null 2>&1 &); PYTHONPATH=$(ide_test_dir) timeout -k $(KILL_DELAY) $(DELAY) $(PYTEST) --maxfail=1 --timeout=100 $(src)/ide_tests/$(1) |
117 endef |
133 endef |
118 |
134 |
119 # Xnest based interactive sessions for tests edit and debug. |
135 # Xnest based interactive sessions for tests edit and debug. |
120 # Would be nice with something equivalent to xvfb-run, waiting for USR1. |
136 # Would be nice with something equivalent to xvfb-run, waiting for USR1. |
121 # Arbitrary "sleep 1" is probably enough for interactive use |
137 # Arbitrary "sleep 1" is probably enough for interactive use |
122 define xnest_run |
138 define xnest_run |
123 Xnest :42 -geometry 1920x1080+0+0 & export xnestpid=$$!; sleep 1; DISPLAY=:42 $(1); export res=$$?; kill $${xnestpid} 2>/dev/null; exit $${res} |
139 Xnest :42 -geometry 1920x1080+0+0 & export xnestpid=$$!; sleep 1; DISPLAY=:42 $(1); export res=$$?; kill $${xnestpid} 2>/dev/null; exit $${res} |
124 endef |
140 endef |
125 |
141 |
126 define prep_test |
|
127 rm -rf $(test_dir)/$(1)_idetest |
|
128 mkdir $(test_dir)/$(1)_idetest |
|
129 cd $(test_dir)/$(1)_idetest |
|
130 endef |
|
131 |
|
132 xserver_command ?= xvfb-run -s '-screen 0 1920x1080x24' |
142 xserver_command ?= xvfb-run -s '-screen 0 1920x1080x24' |
133 |
143 |
134 define make_idetest_rule |
144 define make_idetest_rule |
135 $(test_dir)/$(1)_idetest/.passed: own_apps |
145 $(test_dir)/$(1)_results/.passed: own_apps |
136 $(call prep_test,$(1)); $(xserver_command) bash -c '$(call $(2),$(1))' |
146 $(call prep_test,$(1)); $(xserver_command) bash -c '$(call log_command,$(2),$(1))' |
137 touch $$@ |
147 touch $$@ |
138 |
148 |
139 # Manually invoked rule {testname}.sikuli |
149 # Manually invoked rule {testname}.sikuli |
140 $(1): $(test_dir)/$(1)_idetest/.passed |
150 $(1): $(test_dir)/$(1)_results/.passed |
141 |
151 |
142 # Manually invoked rule xnest_{testname}.sikuli |
152 # Manually invoked rule xnest_{testname}.sikuli |
143 # runs test in xnest so that one can see what happens |
153 # runs test in xnest so that one can see what happens |
144 xnest_$(1): own_apps |
154 xnest_$(1): own_apps |
145 $(call prep_test,$(1)); $$(call xnest_run, bash -c '$(call $(2),$(1))') |
155 $(call prep_test,$(1)); $$(call xnest_run, bash -c '$(call log_command,$(2),$(1))') |
146 |
156 |
147 ide_tests_targets += $(test_dir)/$(1)_idetest/.passed |
157 ide_tests_targets += $(test_dir)/$(1)_results/.passed |
148 endef |
158 endef |
149 $(foreach idetest,$(sikuli_ide_tests),$(eval $(call make_idetest_rule,$(idetest),sikuli_idetest_command))) |
159 $(foreach idetest,$(sikuli_ide_tests),$(eval $(call make_idetest_rule,$(idetest),sikuli_idetest_command))) |
150 $(foreach idetest,$(pytest_ide_tests),$(eval $(call make_idetest_rule,$(idetest),pytest_idetest_command))) |
160 $(foreach idetest,$(pytest_ide_tests),$(eval $(call make_idetest_rule,$(idetest),pytest_idetest_command))) |
151 |
161 |
152 ide_tests : $(ide_tests_targets) |
162 ide_tests : $(ide_tests_targets) |
164 echo "Docker container must be created with TESTDEBUG=YES. For example :" |
174 echo "Docker container must be created with TESTDEBUG=YES. For example :" |
165 echo "./clean_docker_container.sh && ./build_docker_image.sh && TESTDEBUG=YES ./create_docker_container.sh && ./do_test_in_docker.sh xvfb_sikuli" |
175 echo "./clean_docker_container.sh && ./build_docker_image.sh && TESTDEBUG=YES ./create_docker_container.sh && ./do_test_in_docker.sh xvfb_sikuli" |
166 echo "******************************************" |
176 echo "******************************************" |
167 $(xserver_command) bash -c '(fluxbox &);(x11vnc &);(BEREMIZPATH=$(build_dir)/beremiz xterm -e sikulix &);xterm' |
177 $(xserver_command) bash -c '(fluxbox &);(x11vnc &);(BEREMIZPATH=$(build_dir)/beremiz xterm -e sikulix &);xterm' |
168 |
178 |
169 clean: |
179 # |
170 rm -rf $(ide_tests_targets) $(build_dir) |
180 # CLI TESTS |
|
181 # |
|
182 |
|
183 cli_test_dir = $(src)/cli_tests |
|
184 cli_tests = $(subst $(cli_test_dir)/,,$(wildcard $(cli_test_dir)/*.bash)) |
|
185 |
|
186 define clitest_command |
|
187 BEREMIZPATH=$(build_dir)/beremiz source $(src)/cli_tests/$(1) |
|
188 endef |
|
189 |
|
190 define make_clitest_rule |
|
191 $(test_dir)/$(1)_results/.passed: own_apps |
|
192 $(call prep_test,$(1)); bash -c '$(call log_command,$(2),$(1))' |
|
193 touch $$@ |
|
194 |
|
195 # Manually invoked rule |
|
196 $(1): $(test_dir)/$(1)_results/.passed |
|
197 |
|
198 cli_tests_targets += $(test_dir)/$(1)_results/.passed |
|
199 endef |
|
200 $(foreach clitest,$(cli_tests),$(eval $(call make_clitest_rule,$(clitest),clitest_command))) |
|
201 |
|
202 cli_tests: $(cli_tests_targets) |
|
203 echo "$(cli_tests_targets) : Passed" |
|
204 |
|
205 clean_results: |
|
206 rm -rf $(test_dir)/*_results |
|
207 |
|
208 clean: clean_results |
|
209 rm -rf $(build_dir) |
171 |
210 |
172 |
211 |
173 # TODOs |
212 # TODOs |
174 |
213 |
175 source_check: |
214 source_check: |
176 echo TODO $@ |
215 echo TODO $@ |
177 |
216 |
178 cli_tests : |
|
179 echo TODO $@ |
|
180 |
|
181 runtime_tests: |
217 runtime_tests: |
182 echo TODO $@ |
218 echo TODO $@ |
183 |
219 |
184 |
220 |
185 |
221 |