diff options
author | Ori Bernstein <ori@eigenstate.org> | 2016-05-31 10:08:02 -0400 |
---|---|---|
committer | Ori Bernstein <ori@eigenstate.org> | 2016-05-31 10:08:02 -0400 |
commit | d43127a52e3dfac1f1f1eba32986ae3bbdd083ee (patch) | |
tree | cc3c5228f66a39aadf5968956ce4acb1cf113ffb /lib/testr | |
parent | 88a4ba446d6b505f26cfefb8f81b223a45bbeba3 (diff) | |
download | mc-d43127a52e3dfac1f1f1eba32986ae3bbdd083ee.tar.gz |
Test failures should longjmp out of the context.
Diffstat (limited to 'lib/testr')
-rw-r--r-- | lib/testr/testr.myr | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/testr/testr.myr b/lib/testr/testr.myr index ff3ecc2..7c5e3cc 100644 --- a/lib/testr/testr.myr +++ b/lib/testr/testr.myr @@ -4,6 +4,8 @@ pkg testr = type ctx = struct ok : bool reason : byte[:] + + retctx : std.jmpbuf# ;; type spec = struct @@ -14,6 +16,7 @@ pkg testr = const run : (specs : spec[:] -> void) const ok : (ctx : ctx# -> void) const fail : (ctx : ctx#, msg : byte[:] -> void) + const softfail : (ctx : ctx#, msg : byte[:] -> void) ;; const run = {specs @@ -24,23 +27,31 @@ const run = {specs } const ok = {ctx - /* nothing to do here */ + /* nothing to do here? */ } const fail = {ctx, msg + softfail(ctx, msg) + std.longjmp(ctx.retctx) +} + +const softfail = {ctx, msg ctx.ok = false ctx.reason = msg } const runspec = {ts + var status, reason, jbuf var ctx : ctx - var status, reason ctx.ok = true ctx.reason = "" + ctx.retctx = &jbuf std.put("test {} <<{{!\n", ts.name) - ts.fn(&ctx) + if !std.setjmp(&jbuf) + ts.fn(&ctx) + ;; if ctx.ok status = "ok" |