|
|
@@ -8,6 +8,7 @@ expect_ok() {
|
|
|
else
|
|
|
fail=$((fail+1)); echo "FAIL(ok, rejected): $1"
|
|
|
fi
|
|
|
+ collect_mcd
|
|
|
}
|
|
|
expect_fail() {
|
|
|
if ./M2comp "$1" 2>&1 | grep -q "Incorrect source"; then
|
|
|
@@ -15,6 +16,7 @@ expect_fail() {
|
|
|
else
|
|
|
fail=$((fail+1)); echo "FAIL(fail, accepted): $1"
|
|
|
fi
|
|
|
+ collect_mcd
|
|
|
}
|
|
|
expect_dump() {
|
|
|
if ./M2comp "$1" 2>&1 | grep -q "$2"; then
|
|
|
@@ -22,19 +24,29 @@ expect_dump() {
|
|
|
else
|
|
|
fail=$((fail+1)); echo "FAIL(ast): $1 [$2]"
|
|
|
fi
|
|
|
+ collect_mcd
|
|
|
}
|
|
|
-MCINT="${MCINT:-../mc64/mcint}"
|
|
|
+MCINT="${MCINT:-../m-code-64/mcint}"
|
|
|
+mkdir -p MC4
|
|
|
MCTIMEOUT="${MCTIMEOUT:-10}"
|
|
|
+# MGen emits <Module>.MC4 in the current directory; the run helpers
|
|
|
+# below collect it into MC4/ and run it from there.
|
|
|
+collect_mcd() {
|
|
|
+ for f in *.MC4; do
|
|
|
+ [ -f "$f" ] && mv -f "$f" MC4/
|
|
|
+ done
|
|
|
+}
|
|
|
expect_run() {
|
|
|
# $1 = test file, $2 = expected printed ExitCode value
|
|
|
name="$1"
|
|
|
want="$2"
|
|
|
mod=$(head -n 1 "tests/$name" | cut -d' ' -f2 | cut -d';' -f1)
|
|
|
- mcd="$mod.MC4"
|
|
|
- rm -f "$mcd"
|
|
|
+ mcd="MC4/$mod.MC4"
|
|
|
+ rm -f "$mcd" "$mod.MC4"
|
|
|
if ./M2comp "tests/$name" 2>&1 | grep -q "Incorrect source"; then
|
|
|
fail=$((fail+1)); echo "FAIL(run): $name rejected"; return
|
|
|
fi
|
|
|
+ [ -f "$mod.MC4" ] && mv -f "$mod.MC4" "$mcd"
|
|
|
if [ ! -f "$mcd" ]; then
|
|
|
fail=$((fail+1)); echo "FAIL(run): $name no $mcd"; return
|
|
|
fi
|
|
|
@@ -53,11 +65,12 @@ expect_run_none() {
|
|
|
# $1 = test file — must compile and run silent (terminating)
|
|
|
name="$1"
|
|
|
mod=$(head -n 1 "tests/$name" | cut -d' ' -f2 | cut -d';' -f1)
|
|
|
- mcd="$mod.MC4"
|
|
|
- rm -f "$mcd"
|
|
|
+ mcd="MC4/$mod.MC4"
|
|
|
+ rm -f "$mcd" "$mod.MC4"
|
|
|
if ./M2comp "tests/$name" 2>&1 | grep -q "Incorrect source"; then
|
|
|
fail=$((fail+1)); echo "FAIL(silent): $name rejected"; return
|
|
|
fi
|
|
|
+ [ -f "$mod.MC4" ] && mv -f "$mod.MC4" "$mcd"
|
|
|
if [ ! -f "$mcd" ]; then
|
|
|
fail=$((fail+1)); echo "FAIL(silent): $name no $mcd"; return
|
|
|
fi
|