summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-11-07 12:35:10 -0800
committerOri Bernstein <ori@eigenstate.org>2016-11-07 14:23:02 -0800
commit2e3e676b32b16cf0f73b508e7633a15b4184b9db (patch)
tree219296f3c99ad8e134b997680813e12034de64f1
parent91a715bcdfdd2c762c700b45591e74f42c4a0626 (diff)
downloadmc-2e3e676b32b16cf0f73b508e7633a15b4184b9db.tar.gz
Show the subtests that fail.
-rw-r--r--mbld/subtest.myr37
-rw-r--r--mbld/test.myr20
2 files changed, 35 insertions, 22 deletions
diff --git a/mbld/subtest.myr b/mbld/subtest.myr
index 17594d9..e380a68 100644
--- a/mbld/subtest.myr
+++ b/mbld/subtest.myr
@@ -2,8 +2,12 @@ use std
use bio
use regex
+use "types"
+
pkg bld =
- const showsub : (f : std.fd, logfd : std.fd -> std.option(bool))
+ const showsub : (b : build#, cmd : byte[:], \
+ f : std.fd, logfd : std.fd, \
+ failed : byte[:][:]# -> std.option(bool))
;;
var planpat
@@ -16,7 +20,7 @@ const __init__ = {
footpat = std.try(regex.compile("!}>>\\s*(ok|fail\\s*(.*))\\s*"))
}
-const showsub = {fd, logfd
+const showsub = {b, cmd, fd, logfd, failed
var f, log
var res
@@ -32,7 +36,8 @@ const showsub = {fd, logfd
bio.write(log, ln)
showraw(fd, logfd)
| `std.Some ntests:
- res = `std.Some showtests(f, log, ntests)
+ res = `std.Some showtests(b, cmd, failed, \
+ f, log, ntests)
;;
std.slfree(ln)
@@ -56,7 +61,7 @@ const showraw = {f, log
std.slfree(buf)
}
-const showtests = {f, log, ntests
+const showtests = {b, cmd, failed, f, log, ntests
var curtest
var nresults
var ok
@@ -82,10 +87,10 @@ const showtests = {f, log, ntests
match testfoot(ln)
| `std.None:
| `std.Some `std.Ok _:
- endtest(&curtest, &nresults, true, "")
+ endtest(b, cmd, &curtest, failed, &nresults, true, "")
continue
| `std.Some `std.Err m:
- endtest(&curtest, &nresults, false, m)
+ endtest(b, cmd, &curtest, failed, &nresults, false, m)
ok = false
continue
;;
@@ -127,19 +132,27 @@ const starttest = {curtest, t
curtest# = t
}
-const endtest = {curtest, nresults, pass, msg
+const endtest = {b, cmd, curtest, failed, nresults, pass, msg
+ var p
+
if curtest#.len == 0
std.fatal("malformed input: test ended without start\n")
;;
- std.slfree(curtest#)
- curtest# = ""
+
if pass
std.put("PASS\n")
- elif msg.len > 0
- std.put("FAIL {}\n", msg)
else
- std.put("FAIL\n")
+ if msg.len > 0
+ std.put("FAIL {}\n", msg)
+ else
+ std.put("FAIL\n")
+ ;;
+ p = std.pathjoin([b.curdir, cmd, curtest#][:])
+ std.slpush(failed, p)
;;
+
+ std.slfree(curtest#)
+ curtest# = ""
nresults#++
}
diff --git a/mbld/test.myr b/mbld/test.myr
index c499bee..ed25f0f 100644
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -18,7 +18,7 @@ pkg bld =
const test = {b
var tests : (byte[:][:], byte[:])[:]
- var failed, p, ok
+ var failed, ok
var bincmd
/* build with the test tag */
@@ -60,10 +60,8 @@ const test = {b
failed = [][:]
for (c, dir) in tests
setdir(b, dir)
- if !runtest(b, c)
+ if !runtest(b, c, &failed)
ok = false
- p = std.pathcat(b.curdir, c[0])
- std.slpush(&failed, p)
;;
;;
@@ -90,10 +88,8 @@ const test = {b
}
const printfailed = {failed
- if failed.len > 10
- std.put("\t{} tests failed\n", failed.len)
- elif failed.len > 0
- std.put("FAILURES:\n")
+ if failed.len > 0
+ std.put("FAILURES: {}\n", failed.len)
for t in failed
std.put("\t{}\n", t)
;;
@@ -151,7 +147,7 @@ const buildtests = {b, targ
-> tests
}
-const runtest = {b, cmd
+const runtest = {b, cmd, failed
var res, log, logfd, p
var sub
@@ -168,7 +164,7 @@ const runtest = {b, cmd
| `std.Ok (pid, infd, outfd):
log = std.strcat(cmd[0], ".log")
logfd = std.try(std.openmode(log, std.Owronly | std.Ocreat, 0o644))
- sub = showsub(outfd, logfd)
+ sub = showsub(b, cmd[0], outfd, logfd, failed)
std.slfree(log)
std.close(infd)
std.close(outfd)
@@ -186,6 +182,10 @@ const runtest = {b, cmd
;;
| `std.Waiterror: std.put("failed waiting for pid {}\n", pid)
;;
+ if !res
+ p = std.pathcat(b.curdir, cmd[0])
+ std.slpush(failed, p)
+ ;;
;;
-> res
}