Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci.nix
Original file line number Diff line number Diff line change
@@ -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; }
2 changes: 2 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ rec {
src = sourceByRegex ./. [
"test/"
"test/.*Makefile.*"
"test/quick.mk"
"test/(run.*|fail)/"
"test/(run.*|fail)/.*.as"
"test/(run.*|fail)/ok/.*"
Expand Down Expand Up @@ -141,6 +142,7 @@ rec {
src = sourceByRegex ./. [
"test/"
"test/.*Makefile.*"
"test/quick.mk"
"test/(run.*|fail)/"
"test/(run.*|fail)/.*.as"
"test/(run.*|fail)/ok/.*"
Expand Down
7 changes: 6 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $< $@

Expand Down Expand Up @@ -52,3 +54,6 @@ test: $(NAME)

accept: $(NAME)
$(MAKE) -C ../test ASC=$(ASC) accept

test-quick: $(NAME)
$(MAKE) -C ../test ASC=$(ASC) quick
7 changes: 6 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 6 additions & 2 deletions test/fail/Makefile
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions test/quick.mk
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 6 additions & 2 deletions test/run-dfinity/Makefile
Original file line number Diff line number Diff line change
@@ -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
33 changes: 17 additions & 16 deletions test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
#

Expand All @@ -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
Expand All @@ -31,6 +32,9 @@ while getopts "ad" o; do
DFINITY=yes
EXTRA_ASC_FLAGS=--dfinity
;;
s)
ECHO=true
;;
esac
done

Expand All @@ -55,7 +59,7 @@ do
out=_out
ok=ok

echo -n "$base:"
$ECHO -n "$base:"
[ -d $out ] || mkdir $out
[ -d $ok ] || mkdir $ok

Expand All @@ -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"
Expand All @@ -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"

Expand All @@ -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"

Expand All @@ -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
Expand All @@ -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
Expand All @@ -126,7 +130,7 @@ do
fi
fi
fi
echo ""
$ECHO ""

# normalize files
for file in $diff_files
Expand Down Expand Up @@ -167,8 +171,5 @@ then
echo "Some tests failed."
exit 1
else
echo "All tests passed."
$ECHO "All tests passed."
fi



8 changes: 6 additions & 2 deletions test/run/Makefile
Original file line number Diff line number Diff line change
@@ -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