#
# test1.in : simply macro replacement

include CONFIG

export PYTHONPATH:=../src:$(PYTHONPATH)


.PRECIOUS: %.out

# set this only to "yes" in order to create the 
# test[n].ok files. These files are later compared to
# the test[n].out files.
# In order for the tests to really test pyexpander, 
# the variable MUST BE set to "no".
CREATE_TESTS=no

testlist= $(basename $(wildcard *.ok)) $(basename $(wildcard *.sds))


all: pure_module_test $(addsuffix .tst, $(testlist))

clean:
	rm -f $(addsuffix .out, $(testlist)) 
	rm -f *.tmp

_clean: clean
	rm -f $(addsuffix .ok, $(testlist)) 

pure_module_test:
	$(PYTHON3) ../src/StructuredData/Classes.py
	$(PYTHON3) ../src/StructuredData/internal/dictutils.py
	$(PYTHON3) ../src/StructuredData/internal/enumclass.py
	$(PYTHON3) ../src/StructuredData/internal/lock.py
	$(PYTHON3) ../src/StructuredData/internal/Repr.py
	$(PYTHON3) ../src/StructuredData/internal/rst_load.py

ok: $(addsuffix .ok, $(testlist))

%.out: %.sh 
	bash ./$< > $@

%.out: %.sdp
	@echo -e '\n-> test SDpyshell $<'
	$(PYTHON3) ../src/StructuredData/SDpyshell.py $< > $@

ifeq "$(CREATE_TESTS)" "yes"
%.ok: %.out
	cp $< $@
endif

%.tst: %.sh %.ok %.out
	diff $(wordlist 2, 3, $+) 

%.tst: %.sdp %.ok %.out
	diff $(wordlist 2, 3, $+) 

