diff --git a/ci.nix b/ci.nix index 41bed40d752..7453ecd04e5 100644 --- a/ci.nix +++ b/ci.nix @@ -1,4 +1,4 @@ -# We need to set test-dvm to false becaue hydra has +# We need to set test-dvm to false because hydra has # no access to the `dev` repo. This can go away once we join # the monorepo. import ./default.nix { test-dvm = false; } diff --git a/default.nix b/default.nix index 3fb207375b8..0a4f8b7e7cf 100644 --- a/default.nix +++ b/default.nix @@ -91,6 +91,7 @@ rec { src = sourceByRegex ./. [ "test/" "test/.*Makefile.*" + "test/quick.mk" "test/(run.*|fail)/" "test/(run.*|fail)/.*.as" "test/(run.*|fail)/ok/.*" @@ -141,6 +142,7 @@ rec { src = sourceByRegex ./. [ "test/" "test/.*Makefile.*" + "test/quick.mk" "test/(run.*|fail)/" "test/(run.*|fail)/.*.as" "test/(run.*|fail)/ok/.*" diff --git a/src/Makefile b/src/Makefile index c25cdf5b346..fd811340b00 100644 --- a/src/Makefile +++ b/src/Makefile @@ -21,10 +21,12 @@ OCAMLBUILD = ocamlbuild $(OCAML_FLAGS) \ $(OPAM_PACKAGES:%=-pkg %) \ -tags debug -.PHONY: all clean test +.PHONY: all quick clean test test-quick all: $(NAME) test +quick: $(NAME) test-quick + $(NAME): $(MAIN).$(BUILD) mv $< $@ @@ -52,3 +54,6 @@ test: $(NAME) accept: $(NAME) $(MAKE) -C ../test ASC=$(ASC) accept + +test-quick: $(NAME) + $(MAKE) -C ../test ASC=$(ASC) quick diff --git a/test/Makefile b/test/Makefile index f5e5031d430..19b6c2eec37 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,7 +1,12 @@ all: $(MAKE) -C fail $(MAKE) -C run - $(MAKE) -C run-dfinity all + $(MAKE) -C run-dfinity + +quick: + $(MAKE) --no-print-directory --load-average -j -C fail quick + $(MAKE) --no-print-directory --load-average -j -C run quick + $(MAKE) --no-print-directory --load-average -j -C run-dfinity _out/chatpp.done coverage: rm -rf _coverage diff --git a/test/fail/Makefile b/test/fail/Makefile index 5a3247c47d8..ca32260888f 100644 --- a/test/fail/Makefile +++ b/test/fail/Makefile @@ -1,8 +1,12 @@ +RUNFLAGS = + all: - ../run.sh *.as + ../run.sh $(RUNFLAGS) *.as accept: - ../run.sh -a *.as + ../run.sh $(RUNFLAGS) -a *.as clean: rm -rf _out + +include ../*.mk diff --git a/test/quick.mk b/test/quick.mk new file mode 100644 index 00000000000..274061b9433 --- /dev/null +++ b/test/quick.mk @@ -0,0 +1,10 @@ +# Note: this rule collection is included for one level deeper + +TO-TEST = $(patsubst %.as,_out/%.done,$(wildcard *.as)) + +quick: $(TO-TEST) + +# run single test, e.g. make _out/AST-56.done +_out/%.done: %.as $(ASC) ../run.sh + @ mkdir -p _out + @ (../run.sh $(RUNFLAGS) $< > $@.tmp && mv $@.tmp $@) || (cat $@.tmp; rm -f $@.tmp; false) diff --git a/test/run-dfinity/Makefile b/test/run-dfinity/Makefile index d49057c8a2a..356eab76f18 100644 --- a/test/run-dfinity/Makefile +++ b/test/run-dfinity/Makefile @@ -1,8 +1,12 @@ +RUNFLAGS = -d + all: - ../run.sh -d *.as + ../run.sh $(RUNFLAGS) *.as accept: - ../run.sh -d -a *.as + ../run.sh $(RUNFLAGS) -a *.as clean: rm -rf _out + +include ../*.mk diff --git a/test/run.sh b/test/run.sh index 0e7587c4071..8a0367fabf1 100755 --- a/test/run.sh +++ b/test/run.sh @@ -6,7 +6,7 @@ # # Options: # -# -a: Update the files in ok/ +# -a: Update the files in ok/ # -d: Compile with --dfinity, use dvm to run # @@ -21,8 +21,9 @@ EXTRA_ASC_FLAGS= ASC=${ASC:-$(realpath $(dirname $0)/../src/asc)} WASM=${WASM:-wasm} DVM_WRAPPER=$(realpath $(dirname $0)/dvm.sh) +ECHO=echo -while getopts "ad" o; do +while getopts "ads" o; do case "${o}" in a) ACCEPT=yes @@ -31,6 +32,9 @@ while getopts "ad" o; do DFINITY=yes EXTRA_ASC_FLAGS=--dfinity ;; + s) + ECHO=true + ;; esac done @@ -55,7 +59,7 @@ do out=_out ok=ok - echo -n "$base:" + $ECHO -n "$base:" [ -d $out ] || mkdir $out [ -d $ok ] || mkdir $ok @@ -64,8 +68,8 @@ do # First run all the steps, and remember what to diff diff_files= - # Typeckeck - echo -n " [tc]" + # Typecheck + $ECHO -n " [tc]" $ASC $ASC_FLAGS --check $base.as > $out/$base.tc 2>&1 tc_succeeded=$? diff_files="$diff_files $base.tc" @@ -75,12 +79,12 @@ do if [ "$SKIP_RUNNING" != yes ] then # Interpret - echo -n " [run]" + $ECHO -n " [run]" $ASC $ASC_FLAGS -r $base.as > $out/$base.run 2>&1 diff_files="$diff_files $base.run" # Interpret with lowering - echo -n " [run-low]" + $ECHO -n " [run-low]" $ASC $ASC_FLAGS -r -a -A $base.as > $out/$base.run-low 2>&1 diff_files="$diff_files $base.run-low" @@ -89,7 +93,7 @@ do diff_files="$diff_files $base.diff-low" # Interpret IR - echo -n " [run-ir]" + $ECHO -n " [run-ir]" $ASC $ASC_FLAGS -r -iR $base.as > $out/$base.run-ir 2>&1 diff_files="$diff_files $base.run-ir" @@ -99,7 +103,7 @@ do fi # Compile - echo -n " [wasm]" + $ECHO -n " [wasm]" if [ $DFINITY = 'yes' ] then $ASC $ASC_FLAGS $EXTRA_ASC_FLAGS --map -c $base.as <(echo 'print("Top-level code done.\n")') -o $out/$base.wasm 2> $out/$base.wasm.stderr @@ -113,11 +117,11 @@ do then if [ $DFINITY = 'yes' ] then - echo -n " [dvm]" + $ECHO -n " [dvm]" $DVM_WRAPPER $out/$base.wasm > $out/$base.dvm-run 2>&1 diff_files="$diff_files $base.dvm-run" else - echo -n " [wasm-run]" + $ECHO -n " [wasm-run]" $WASM _out/$base.wasm > $out/$base.wasm-run 2>&1 sed 's/wasm:0x[a-f0-9]*:/wasm:0x___:/g' $out/$base.wasm-run >$out/$base.wasm-run.temp mv -f $out/$base.wasm-run.temp $out/$base.wasm-run @@ -126,7 +130,7 @@ do fi fi fi - echo "" + $ECHO "" # normalize files for file in $diff_files @@ -167,8 +171,5 @@ then echo "Some tests failed." exit 1 else - echo "All tests passed." + $ECHO "All tests passed." fi - - - diff --git a/test/run/Makefile b/test/run/Makefile index 5a3247c47d8..ca32260888f 100644 --- a/test/run/Makefile +++ b/test/run/Makefile @@ -1,8 +1,12 @@ +RUNFLAGS = + all: - ../run.sh *.as + ../run.sh $(RUNFLAGS) *.as accept: - ../run.sh -a *.as + ../run.sh $(RUNFLAGS) -a *.as clean: rm -rf _out + +include ../*.mk