summaryrefslogtreecommitdiff
path: root/mbld
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2018-03-24 22:35:40 -0700
committerOri Bernstein <ori@eigenstate.org>2018-03-24 23:13:51 -0700
commitb39e8ca0f806bd6a76f378373cb4d27fcf028190 (patch)
tree5a9c057b27a55d45424b844e697b277088c62fdb /mbld
parent17cb502c1578b8e1a94f02b84cf47acfef6b20b1 (diff)
downloadmc-b39e8ca0f806bd6a76f378373cb4d27fcf028190.tar.gz
Improve test runner test filtering.
Filter on what the user sees. Before, we would use the internal target names, which bore a resemblance to the target names used by the user, but they didn't match perfectly. This led to unintuitive behavior. Now, we filter on a substring of the test name matching. So, you can do something like: mbld test crypto/sha3 instead of mbld test lib/bio/test:delim In addition, not all tests had an explicit target, and these would be impossible to match on. Still left to do is adding subtest patterns.
Diffstat (limited to 'mbld')
-rw-r--r--mbld/test.myr37
1 files changed, 23 insertions, 14 deletions
diff --git a/mbld/test.myr b/mbld/test.myr
index 4d4b2ed..e199d20 100644
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -28,21 +28,11 @@ const go = {b, targs, kind, isbench
if !buildtarg(b, kind)
std.exit(1)
;;
- if targs.len == 0
- tests = std.htgetv(b.deps.targs, kind, [][:])
- else
- tests = [][:]
- for t : targs
- match std.htget(b.deps.targs, t)
- | `std.Some tl: std.sljoin(&tests, tl)
- | `std.None: std.fatal("unknown test {}\n", t)
- ;;
- ;;
- ;;
+ tests = std.htgetv(b.deps.targs, kind, [][:])
ok = true
failed = [][:]
for t : tests
- if !runtest(b, t, isbench, &failed)
+ if !runtest(b, t, targs, isbench, &failed)
ok = false
;;
;;
@@ -71,10 +61,19 @@ const printfailed = {failed
;;
}
-const runtest = {b, n, isbench, failed
+const runtest = {b, n, targs, isbench, failed
var dir, res, log, logfd
- var sub
+ var sub, found
+ if targs.len > 0
+ found = false
+ for t : targs
+ found = found || matchtest(n.lbl, t)
+ ;;
+ if !found
+ -> true
+ ;;
+ ;;
mbldput("run {}: ", n.lbl)
dir = std.pathcat(b.basedir, n.wdir)
std.chdir(dir)
@@ -116,3 +115,13 @@ const runtest = {b, n, isbench, failed
-> res
}
+const matchtest = {name, pat
+ match std.strfind(pat, ":")
+ | `std.Some i: pat = pat[:i]
+ | `std.None: /* ok */
+ ;;
+ match std.strfind(name, pat)
+ | `std.Some _: -> true
+ | `std.None: -> false
+ ;;
+}