tests/Makefile
branchwxPython4
changeset 3438 24fbd4d1fe80
parent 3435 c17155fd8573
child 3527 fbe924df437b
equal deleted inserted replaced
3437:ce366d67a5b7 3438:24fbd4d1fe80
    45 #   Matiec and Beremiz code are expected to be clean, ready to build
    45 #   Matiec and Beremiz code are expected to be clean, ready to build
    46 #   Any change in Matiec directory triggers rebuild of matiec.
    46 #   Any change in Matiec directory triggers rebuild of matiec.
    47 #   Any change in Matiec and Beremiz directory triggers copy of source code
    47 #   Any change in Matiec and Beremiz directory triggers copy of source code
    48 #   to $(test_dir)/build.
    48 #   to $(test_dir)/build.
    49 #
    49 #
       
    50 #   BEREMIZPYTHONPATH is expected to be absolute path to python interpreter
    50 #
    51 #
    51 #   Please note:
    52 #   Please note:
    52 #       In order to run asside a freshly build Matiec, tested beremiz instance
    53 #       In order to run asside a freshly build Matiec, tested beremiz instance
    53 #       needs to run on code from $(test_dir)/build/beremiz, a fresh copy
    54 #       needs to run on code from $(test_dir)/build/beremiz, a fresh copy
    54 #       of the Beremiz directory $(src)/beremiz, where we run tests from.
    55 #       of the Beremiz directory $(src)/beremiz, where we run tests from.
    97 
    98 
    98 # TODO: use packge (deb/snap ?)
    99 # TODO: use packge (deb/snap ?)
    99 own_apps: $(build_dir)/matiec/iec2c $(build_dir)/beremiz/$(beremiz_checksum).sha1
   100 own_apps: $(build_dir)/matiec/iec2c $(build_dir)/beremiz/$(beremiz_checksum).sha1
   100 	touch $@
   101 	touch $@
   101 
   102 
   102 ide_tests = $(subst $(src)/ide_tests/,,$(wildcard $(src)/ide_tests/*.sikuli))
   103 ide_test_dir = $(src)/ide_tests
       
   104 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))
   103 
   106 
   104 define idetest_command
   107 define sikuli_idetest_command
   105 	(fluxbox >/dev/null 2>&1 &); BEREMIZPATH=$(build_dir)/beremiz sikulix -r $(src)/ide_tests/$(1) | tee test_stdout.txt; exit $$$${PIPESTATUS[0]}
   108 	(fluxbox >/dev/null 2>&1 &); BEREMIZPATH=$(build_dir)/beremiz sikulix -r $(src)/ide_tests/$(1) | tee test_stdout.txt; exit $$$${PIPESTATUS[0]}
       
   109 endef
       
   110 
       
   111 
       
   112 DELAY=400
       
   113 KILL_DELAY=430
       
   114 PYTEST=$(dir $(BEREMIZPYTHONPATH))/pytest
       
   115 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]}
   106 endef
   117 endef
   107 
   118 
   108 # Xnest based interactive sessions for tests edit and debug. 
   119 # Xnest based interactive sessions for tests edit and debug. 
   109 # Would be nice with something equivalent to xvfb-run, waiting for USR1.
   120 # Would be nice with something equivalent to xvfb-run, waiting for USR1.
   110 # Arbitrary "sleep 1" is probably enough for interactive use
   121 # Arbitrary "sleep 1" is probably enough for interactive use
   120 
   131 
   121 xserver_command ?= xvfb-run -s '-screen 0 1920x1080x24'
   132 xserver_command ?= xvfb-run -s '-screen 0 1920x1080x24'
   122 
   133 
   123 define make_idetest_rule
   134 define make_idetest_rule
   124 $(test_dir)/$(1)_idetest/.passed: own_apps
   135 $(test_dir)/$(1)_idetest/.passed: own_apps
   125 	$(call prep_test,$(1)); $(xserver_command) bash -c '$(call idetest_command,$(1))'
   136 	$(call prep_test,$(1)); $(xserver_command) bash -c '$(call $(2),$(1))'
   126 	touch $$@
   137 	touch $$@
   127 
   138 
   128 # Manually invoked rule {testname}.sikuli
   139 # Manually invoked rule {testname}.sikuli
   129 $(1): $(test_dir)/$(1)_idetest/.passed
   140 $(1): $(test_dir)/$(1)_idetest/.passed
   130 
   141 
   131 # Manually invoked rule xnest_{testname}.sikuli
   142 # Manually invoked rule xnest_{testname}.sikuli
   132 # runs test in xnest so that one can see what happens
   143 # runs test in xnest so that one can see what happens
   133 xnest_$(1): own_apps
   144 xnest_$(1): own_apps
   134 	$(call prep_test,$(1)); $$(call xnest_run, bash -c '$(call idetest_command,$(1))')
   145 	$(call prep_test,$(1)); $$(call xnest_run, bash -c '$(call $(2),$(1))')
   135 
   146 
   136 ide_tests_targets += $(test_dir)/$(1)_idetest/.passed
   147 ide_tests_targets += $(test_dir)/$(1)_idetest/.passed
   137 endef
   148 endef
   138 $(foreach idetest,$(ide_tests),$(eval $(call make_idetest_rule,$(idetest))))
   149 $(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)))
   139 
   151 
   140 ide_tests : $(ide_tests_targets)
   152 ide_tests : $(ide_tests_targets)
   141 	echo "$(ide_tests_targets) : Passed"
   153 	echo "$(ide_tests_targets) : Passed"
   142 
   154 
   143 xnest_xterm: own_apps
   155 xnest_xterm: own_apps