default: diag

TEST = catapy
TODELETE = $(TEST).export debut.capy commande

include ../Makefile.inc

debut.capy: 
	@sed -e 's@PAR_LOT *=@MCTEST_CAPY=SIMP(statut="o",typ="TXM"), PAR_LOT =@g' \
	   $(ASTER_ROOT)/$(ASTER_VERSION)/catapy/commande/debut.capy > $@

unittest: $(TEST).export debut.capy
	$(as_run) $< > output.1.$@ 2> error.1.$@
	@grep EXIT_CODE output.1.$@ > exit_code.tmp
	@if  [ `grep -c EXIT_CODE=0 exit_code.tmp` -eq 1 ] && \
	     [ `grep -c MCTEST_CAPY commande/cata.py` -ne 1 ]; then \
	   echo "EXIT_CODE=104" > exit_code.tmp; \
	elif [ `grep -c 'DEBUT *= *MACRO' commande/cata.py` -ne 1 ]; then \
	   echo "EXIT_CODE=204" > exit_code.tmp; \
	elif [ `grep -c -E 'DIAGNOSTIC JOB : OK|DIAGNOSTIC JOB :.*ALARM' output.1.$@` -ne 1 ]; then \
	   echo 'DIAG != OK'; \
	   echo "EXIT_CODE=304" > exit_code.tmp; \
	fi
	@mv -f exit_code.tmp $@

