summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@markovcorp.com>2018-01-31 11:42:25 -0800
committerOri Bernstein <ori@markovcorp.com>2018-01-31 11:42:25 -0800
commitd4bb1a020b60fe906dfa7ee2a12cc4fee1513e6a (patch)
treef2e1fe35983b555f05880cc44d2820344b0bf4e3
parentbc9ee15fdd4a4c961bac0de2f4f9c4fceccd4a86 (diff)
downloadmc-d4bb1a020b60fe906dfa7ee2a12cc4fee1513e6a.tar.gz
Teach libtestr to listen MTEST_SUBSET.
Now it won't run tests that aren't listed there.
-rw-r--r--lib/http/url.myr1
-rw-r--r--lib/testr/testr.myr56
2 files changed, 46 insertions, 11 deletions
diff --git a/lib/http/url.myr b/lib/http/url.myr
index 34bf447..6dc7648 100644
--- a/lib/http/url.myr
+++ b/lib/http/url.myr
@@ -60,6 +60,7 @@ const urlfmt = {sb, ap, opts
const parseurl = {url
var schema, host, port, path, params
+ std.put("url: {}\n", url)
match parseschema(&url)
| `std.Ok s: schema = s
| `std.Err e: -> `std.Err e
diff --git a/lib/testr/testr.myr b/lib/testr/testr.myr
index 19cdad6..d9443c7 100644
--- a/lib/testr/testr.myr
+++ b/lib/testr/testr.myr
@@ -22,17 +22,25 @@ pkg testr =
;;
const bench = {specs
+ var subset
+
+ subset = subtests()
std.put("MTEST {}\n", specs.len)
for s : specs
- benchspec(&s)
+ benchspec(&s, subset)
;;
+ std.htfree(subset)
}
const run = {specs
+ var subset
+
+ subset = subtests()
std.put("MTEST {}\n", specs.len)
for s : specs
- testspec(&s)
+ testspec(&s, subset)
;;
+ std.htfree(subset)
}
const ok = {ctx
@@ -75,11 +83,11 @@ const softfailv = {ctx, msg, ap
;;
}
-const benchspec = {ts
+const benchspec = {ts, sub
+ var ctx : ctx
var avg, m, d, n, nsamp
var start, dt
- var ctx : ctx
- var jmpbuf
+ var dorun, jmpbuf
ctx.ok = true
ctx.reason = ""
@@ -89,8 +97,9 @@ const benchspec = {ts
m = 0.0;
n = 0.0;
nsamp = 0
+ dorun = matchtest(ts.name, sub)
std.put("test {} <<{{!\n", ts.name)
- if !std.setjmp(&jmpbuf)
+ if !std.setjmp(&jmpbuf) && dorun
/* estimate samples */
start = std.now()
ts.fn(&ctx)
@@ -114,7 +123,9 @@ const benchspec = {ts
;;
;;
- if ctx.ok
+ if !dorun
+ std.put("!}}>> skip filtered\n", nsamp, avg, m)
+ elif ctx.ok
std.put("!}}>> timing {} {} {}\n", nsamp, avg, m)
else
std.put("!}}>> fail {}\n", ctx.reason)
@@ -122,23 +133,46 @@ const benchspec = {ts
;;
}
-const testspec = {ts
+const testspec = {ts, sub
var ctx : ctx
- var jmpbuf
+ var dorun, jmpbuf
ctx.ok = true
ctx.reason = ""
ctx.jmpbuf = &jmpbuf
+ dorun = matchtest(ts.name, sub)
std.put("test {} <<{{!\n", ts.name)
- if !std.setjmp(&jmpbuf)
+ if !std.setjmp(&jmpbuf) && dorun
ts.fn(&ctx)
;;
- if ctx.ok
+ if !dorun
+ std.put("!}}>> skip filtered\n")
+ elif ctx.ok
std.put("!}}>> ok\n")
else
std.put("!}}>> fail {}\n", ctx.reason)
std.slfree(ctx.reason)
;;
}
+
+const subtests = {
+ var subset
+
+ subset = std.mkht()
+ match std.getenv("MTEST_SUBSET")
+ | `std.None: /* no subtests */
+ | `std.Some "": /* no subtests */
+ | `std.Some subs:
+ for s : std.bysplit(subs, ",")
+ std.htput(subset, s, true)
+ ;;
+ ;;
+ -> subset
+}
+
+const matchtest = {name, sub
+ -> std.htcount(sub) == 0 || std.hthas(sub, name)
+}
+