default: diag

TEST = etude
TODELETE = $(TEST).export $(TEST).comm test.py stanley.py pyobj cmdline pystan base_results P1

include ../Makefile.inc

$(TEST).comm:
	@echo 'DEBUT()' > $(TEST).tmp
	@echo 'P1 = 9999'              >> $(TEST).tmp
	@echo 'print "PARAMETER=", P1' >> $(TEST).tmp
	@echo 'open("./REPE_OUT/parameter", "w").write("PARAMETER=%s\\n" % P1)' >> $(TEST).tmp
	@echo 'FIN()'  >> $(TEST).tmp
	@mv -f $(TEST).tmp $@

cmdline: $(TEST).export $(TEST).comm
	$(as_run) $< > output.1.$@ 2> error.1.$@
	@grep EXIT_CODE output.1.$@ > $@

pyobj: $(TEST).export $(TEST).comm test.py
	$(PYTHONEXECUTABLE) test.py > output.2.$@ 2> error.2.$@
	@grep EXIT_CODE output.2.$@ > $@

base_results: pyobj

pystan: $(TEST).export base_results stanley.py
	$(PYTHONEXECUTABLE) stanley.py > output.3.$@ 2> error.3.$@
	@grep EXIT_CODE output.3.$@ > $@

unittest: cmdline pyobj pystan
	@echo "EXIT_CODE=0" > exit_code.tmp
	@if  [ `grep -c EXIT_CODE=0 cmdline`  -ne 1 ] || \
	     [ `grep -c EXIT_CODE=0 pyobj` -ne 1 ] || \
	     [ `grep -c EXIT_CODE=0 pystan` -ne 1 ]; then \
	   echo "EXIT_CODE=104" > exit_code.tmp; \
	fi
	@mv -f exit_code.tmp $@

