summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mbld/subtest.myr33
-rwxr-xr-xtest/runtest.sh2
2 files changed, 29 insertions, 6 deletions
diff --git a/mbld/subtest.myr b/mbld/subtest.myr
index d8b1e60..f1f9976 100644
--- a/mbld/subtest.myr
+++ b/mbld/subtest.myr
@@ -59,6 +59,7 @@ const showraw = {f, log
}
const showtests = {f, log, ntests
+ var curtest
var nresults
var ok
@@ -67,13 +68,15 @@ const showtests = {f, log, ntests
-> false
;;
ok = true
+ curtest = ""
nresults = 0
+ std.put("\n")
for ln in bio.byline(f)
ln = std.strstrip(ln)
match testhead(ln)
| `std.None:
| `std.Some t:
- std.put("\trun {}:\t", std.strstrip(t))
+ starttest(&curtest, t)
bio.put(log, "RUN {}\n", t)
continue
;;
@@ -81,13 +84,11 @@ const showtests = {f, log, ntests
match testfoot(ln)
| `std.None:
| `std.Some `std.Ok _:
- std.put("PASS\n")
- nresults++
+ endtest(&curtest, &nresults, true)
continue
| `std.Some `std.Fail m:
- std.put("FAIL\n")
+ endtest(&curtest, &nresults, false)
ok = false
- nresults++
continue
;;
@@ -100,6 +101,28 @@ const showtests = {f, log, ntests
-> ok
}
+const starttest = {curtest, t
+ if curtest#.len != 0
+ std.fatal("malformed input: test {} nested in {}\n", t, curtest)
+ ;;
+ std.put("\trun {}:\t", std.strstrip(t))
+ curtest# = t
+}
+
+const endtest = {curtest, nresults, pass
+ if curtest#.len == 0
+ std.fatal("malformed input: test ended without start\n")
+ ;;
+ std.slfree(curtest#)
+ curtest# = ""
+ if pass
+ std.put("PASS\n")
+ else
+ std.put("FAIL\n")
+ ;;
+ nresults#++
+}
+
const testhead = {ln
var t
diff --git a/test/runtest.sh b/test/runtest.sh
index a60f835..4643bbf 100755
--- a/test/runtest.sh
+++ b/test/runtest.sh
@@ -87,7 +87,7 @@ function B {
# Should fail
function F {
- echo "test $test <<{!"
+ echo "test $1 <<{!"
(build $1) > /dev/null 2>1
if [ $? -eq '1' ]; then
pass $1