testsuite: more cleanup of the makefiles

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@13670 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Damien Doligez 2013-05-14 17:05:21 +00:00
parent 4efee60493
commit 0e199b5f7d
6 changed files with 68 additions and 18 deletions

View File

@ -16,22 +16,25 @@ NO_PRINT=`$(MAKE) empty --no-print-directory >/dev/null 2>&1 && echo '--no-print
FIND=find
include ../config/Makefile
.PHONY: default
default:
@echo "Available targets:"
@echo " all launches all tests"
@echo " list FILE=f launches the tests referenced in file f (one path per line)"
@echo " one DIR=p launches the tests located in path p"
@echo " promote DIR=p promotes the reference files for the tests located in path p"
@echo " lib builds library modules"
@echo " clean deletes generated files"
@echo " report prints the report for the last execution, if any"
@echo " all launche all tests"
@echo " list FILE=f launche the tests referenced in file f (one path per line)"
@echo " one DIR=p launche the tests located in path p"
@echo " promote DIR=p promote the reference files for the tests located in path p"
@echo " lib build library modules"
@echo " clean delete generated files"
@echo " report print the report for the last execution, if any"
.PHONY: all
all: lib
@for dir in tests/*; do \
$(MAKE) $(NO_PRINT) exec-one DIR=$$dir; \
done 2>&1 | tee _log
@$(MAKE) report
.PHONY: list
list: lib
@if [ -z "$(FILE)" ]; \
then echo "No value set for variable 'FILE'."; \
@ -42,6 +45,7 @@ list: lib
done <$(FILE) 2>&1 | tee _log
@$(MAKE) report
.PHONY: one
one: lib
@if [ -z "$(DIR)" ]; then \
echo "No value set for variable 'DIR'."; \
@ -53,6 +57,7 @@ one: lib
fi
@$(MAKE) $(NO_PRINT) exec-one DIR=$(DIR)
.PHONY: exec-one
exec-one:
@if [ ! -f $(DIR)/Makefile ]; then \
for dir in $(DIR)/*; do \

View File

@ -67,7 +67,7 @@ defaultclean:
done
.SUFFIXES:
.SUFFIXES: .mli .ml .mly .mll .cmi .cmo .cmx .cmm .cmxa .s .S .o .so
.SUFFIXES: .mli .ml .mly .mll .cmi .cmo .cmx .cmm .cmxa .s .S .o .so .c .f
.mli.cmi:
@$(OCAMLC) -c $(COMPFLAGS) $(ADD_COMPFLAGS) $<
@ -103,3 +103,9 @@ defaultclean:
.s.o:
@$(ASPP) $(ASPPFLAGS) -DSYS_$(SYSTEM) -o $*.o $*.s
.c.o:
@$(CC) -c -I$(CTOPDIR)/byterun $*.c -o $*.$(O)
.f.o:
@$(FORTRAN_COMPILER) -c -I$(CTOPDIR)/byterun $*.f -o $*.$(O)

View File

@ -31,7 +31,9 @@ compile:
fi; \
done
.PHONY: promote
promote: defaultpromote
.PHONY: clean
clean: defaultclean
@rm -f ./a.out *.cm* *.result

View File

@ -25,11 +25,15 @@ ADD_CMX_FILES=$(ADD_MODULES:=.cmx)
GENERATED_SOURCES=$(ML_LEX_FILES) $(ML_YACC_FILES) $(MLI_YACC_FILES)
CUSTOM_FLAG=`if [ -z "$(C_FILES)" ]; then true; else echo '-custom'; fi`
CUSTOM_FLAG=`if [ -n "$(C_FILES)" ]; then echo '-custom'; fi`
ADD_CFLAGS+=$(CUSTOM_FLAG)
CC=$(NATIVECC) $(NATIVECCCOMPOPTS)
.PHONY: default
default: compile run
.PHONY: compile
compile: $(ML_FILES) $(CMO_FILES) $(MAIN_MODULE).cmo
@for file in $(C_FILES); do \
$(NATIVECC) $(NATIVECCCOMPOPTS) -c -I$(CTOPDIR)/byterun $$file.c; \
@ -45,6 +49,7 @@ compile: $(ML_FILES) $(CMO_FILES) $(MAIN_MODULE).cmo
$(MAIN_MODULE).cmx; \
fi
.PHONY: run
run:
@printf " ... testing with ocamlc"
@./program.byte $(EXEC_ARGS) >$(MAIN_MODULE).result \
@ -58,8 +63,10 @@ run:
&& echo " => passed" || echo " => failed"
.PHONY: promote
promote: defaultpromote
.PHONY: clean
clean: defaultclean
@rm -f *.result ./program.* $(GENERATED_SOURCES) $(O_FILES) \
@rm -f *.result program program.exe $(GENERATED_SOURCES) $(O_FILES) \
$(TEST_TEMP_FILES)

View File

@ -24,11 +24,13 @@ FORTRAN_LIB=`if [ -n "$(F_FILES)" ]; then echo '$(FORTRAN_LIBRARY)'; fi`
ADD_CFLAGS+=$(FORTRAN_LIB)
ADD_OPTFLAGS+=$(FORTRAN_LIB)
.PHONY: check
check:
@if [ -n "$(FORTRAN_COMPILER)" -o -z "$(F_FILES)" ]; then \
$(MAKE) run-all; \
fi
.PHONY: run-all
run-all:
@for file in $(C_FILES); do \
$(CC) -c -I$(PREFIX)/lib/ocaml/caml $$file.c; \
@ -41,19 +43,39 @@ run-all:
CANKILL=$(CANKILL) sh `basename $$file ml`precheck || continue; \
fi; \
printf " ... testing '$$file':"; \
$(MAKE) run-file DESC=ocamlc COMP='$(OCAMLC)' COMPFLAGS='$(ADD_COMPFLAGS) $(ADD_CFLAGS) $(O_FILES) -w a $(CMA_FILES) -I $(OTOPDIR)/testsuite/lib $(CMO_FILES)' FILE=$$file PROGRAM_ARGS=$(PROGRAM_ARGS) \
&& if [ -z "$(BYTECODE_ONLY)" ]; then \
$(MAKE) run-file DESC=ocamlopt COMP='$(OCAMLOPT)' COMPFLAGS='$(ADD_COMPFLAGS) $(ADD_OPTFLAGS) $(O_FILES) -w a $(CMXA_FILES) -I $(OTOPDIR)/testsuite/lib $(CMX_FILES)' FILE=$$file PROGRAM_ARGS=$(PROGRAM_ARGS); \
fi \
&& if [ ! -z $(UNSAFE) ]; then \
$(MAKE) run-file DESC=ocamlc-unsafe COMP='$(OCAMLC)' COMPFLAGS='-w a -unsafe -I $(OTOPDIR)/testsuite/lib $(CMO_FILES)' FILE=$$file \
&& if [ -z "$(BYTECODE_ONLY)" ]; then \
$(MAKE) run-file DESC=ocamlopt-unsafe COMP='$(OCAMLOPT)' COMPFLAGS='-w a -unsafe -I $(OTOPDIR)/testsuite/lib $(CMX_FILES)' FILE=$$file; \
$(MAKE) run-file DESC=ocamlc COMP='$(OCAMLC)' \
COMPFLAGS='-w a $(ADD_COMPFLAGS) $(ADD_CFLAGS) $(O_FILES) \
$(CMA_FILES) -I $(OTOPDIR)/testsuite/lib \
$(CMO_FILES)' \
FILE=$$file PROGRAM_ARGS=$(PROGRAM_ARGS) \
&& \
if [ -z "$(BYTECODE_ONLY)" ]; then \
$(MAKE) run-file DESC=ocamlopt COMP='$(OCAMLOPT)' \
COMPFLAGS='-w a $(ADD_COMPFLAGS) $(ADD_OPTFLAGS) $(O_FILES)\
$(CMXA_FILES) -I $(OTOPDIR)/testsuite/lib \
$(CMX_FILES)' \
FILE=$$file PROGRAM_ARGS=$(PROGRAM_ARGS); \
fi \
&& \
if [ -n "$(UNSAFE)" ]; then \
$(MAKE) run-file DESC=ocamlc-unsafe COMP='$(OCAMLC)' \
COMPFLAGS='-w a -unsafe $(ADD_COMPFLAGS) $(ADD_CFLAGS) \
$(O_FILES) $(CMA_FILES) \
-I $(OTOPDIR)/testsuite/lib $(CMO_FILES)' \
FILE=$$file \
&& \
if [ -z "$(BYTECODE_ONLY)" ]; then \
$(MAKE) run-file DESC=ocamlopt-unsafe COMP='$(OCAMLOPT)' \
COMPFLAGS='-w a -unsafe $(ADD_COMPFLAGS) $(ADD_OPTFLAGS) \
$(O_FILES) $(CMXA_FILES) -I $(OTOPDIR)/testsuite/lib \
$(CMX_FILES)' \
FILE=$$file; \
fi; \
fi \
&& echo " => passed" || echo " => failed"; \
done
.PHONY: run-file
run-file:
@printf " $(DESC)"
@rm -f program program.exe
@ -71,7 +93,9 @@ run-file:
$(DIFF) $$F.reference $$F.result >/dev/null; \
fi
.PHONY: promote
promote: defaultpromote
.PHONY: clean
clean: defaultclean
@rm -f *.result program program.exe

View File

@ -48,6 +48,11 @@ function record_unexp() {
curfile = "";
}
/ ... testing.* ... testing/ {
printf("error at line %d: found two test results on the same line\n", NR);
errored = 1;
}
/^ ... testing '[^']*'/ {
if (in_test) record_unexp();
match($0, /... testing '[^']*'/);
@ -74,6 +79,7 @@ function record_unexp() {
END {
if (errored){
printf ("\n#### Some fatal error occurred during testing.\n\n");
exit (3);
}else{
printf("\n");