ref: 2e3e676b32b16cf0f73b508e7633a15b4184b9db
parent: 91a715bcdfdd2c762c700b45591e74f42c4a0626
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Nov 7 07:35:10 EST 2016
Show the subtests that fail.
--- a/mbld/subtest.myr
+++ b/mbld/subtest.myr
@@ -2,8 +2,12 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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#++
}
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -18,7 +18,7 @@
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 @@
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 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 @@
-> tests
}
-const runtest = {b, cmd
+const runtest = {b, cmd, failed
var res, log, logfd, p
var sub
@@ -168,7 +164,7 @@
| `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)
@@ -185,6 +181,10 @@
| `std.None: std.put("PASS\n")
;;
| `std.Waiterror: std.put("failed waiting for pid {}\n", pid)
+ ;;
+ if !res
+ p = std.pathcat(b.curdir, cmd[0])
+ std.slpush(failed, p)
;;
;;
-> res