diff options
author | Ori Bernstein <ori@eigenstate.org> | 2016-05-24 12:03:04 -0700 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2016-05-24 12:03:04 -0700 |
commit | eed9e36c5e089005e8c8cb80400a1af7a3ed6332 (patch) | |
tree | 659cb36e690b766858a0687f4d024850f373216d /mbld | |
parent | e7cef4c863e80881584d6d9d58af76e9b95b07ad (diff) | |
download | mc-eed9e36c5e089005e8c8cb80400a1af7a3ed6332.tar.gz |
Allow subtests to add MTEST lines.
At any point outside a test, MTEST n will add 'n' to the
number of tests expected.
Diffstat (limited to 'mbld')
-rw-r--r-- | mbld/subtest.myr | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/mbld/subtest.myr b/mbld/subtest.myr index f1f9976..d2d9e44 100644 --- a/mbld/subtest.myr +++ b/mbld/subtest.myr @@ -13,12 +13,11 @@ var footpat const __init__ = { planpat = std.try(regex.compile("MTEST\\s+(-?\\d+)\\s*")) headpat = std.try(regex.compile("test\\s+(.*)<<{!")) - footpat = std.try(regex.compile("!}>>\\s*(ok|fail\\s*(.*))")) + footpat = std.try(regex.compile("!}>>\\s*(ok|fail\\s*(.*))\\s*")) } const showsub = {fd, logfd var f, log - var ntests var res f = bio.mkfile(fd, bio.Rd) @@ -28,15 +27,14 @@ const showsub = {fd, logfd | `bio.Err e: std.fatal("error reading subfile: {}\n", e) | `bio.Eof: -> `std.None | `bio.Ok ln: - match regex.exec(planpat, ln) + match testplan(ln) | `std.None: bio.write(log, ln) showraw(fd, logfd) - | `std.Some m: - ntests = std.get(std.intparse(m[1])) - regex.matchfree(m) + | `std.Some ntests: res = `std.Some showtests(f, log, ntests) ;; + std.slfree(ln) ;; bio.close(f) @@ -92,6 +90,15 @@ const showtests = {f, log, ntests continue ;; + match testplan(ln) + | `std.None: + | `std.Some n: + if curtest.len == 0 + ntests += n + continue + ;; + ;; + bio.put(log, "\t{}\n", ln) ;; if ntests > 0 && ntests != nresults @@ -123,6 +130,19 @@ const endtest = {curtest, nresults, pass nresults#++ } +const testplan = {ln + var ntests + + match regex.exec(planpat, ln) + | `std.None: + -> `std.None + | `std.Some m: + ntests = std.get(std.intparse(m[1])) + regex.matchfree(m) + -> `std.Some ntests + ;; +} + const testhead = {ln var t |