ref: 2980a6f863a6fb262f78c8ecd305d7775e73f802
parent: d1c72c34e6fd566250e4e8c750d89c3631bf9668
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Feb 14 08:14:20 EST 2015
Add support for explicit tests.
--- a/build.myr
+++ b/build.myr
@@ -19,16 +19,12 @@
const buildall = {p
for t in p.targs
match t
- | `Bin bt:
- buildbin(p, bt, false)
- | `Lib lt:
- buildlib(p, lt)
- | `Gen gt:
- genfiles(p, gt)
- | `Sub subs:
- subdirs(p, subs, `std.None)
- | `Man m:
- /* nothing needed */
+ | `Bin bt: buildbin(p, bt, false)
+ | `Lib lt: buildlib(p, lt)
+ | `Test tt: /* build on 'mbld test' by default */
+ | `Gen gt: genfiles(p, gt)
+ | `Sub subs: subdirs(p, subs, `std.None)
+ | `Man m: /* nothing needed */
;;
;;
-> true
@@ -58,6 +54,11 @@
| `Lib lt:
if std.sleq(lt.name, targ)
buildlib(p, lt)
+ found = true
+ ;;
+ | `Test tt:
+ if std.sleq(tt.name, targ)
+ buildbin(p, tt, false)
found = true
;;
| `Gen gt:
--- a/clean.myr
+++ b/clean.myr
@@ -19,6 +19,8 @@
cleanup(p, bt, bt.inputs, true)
| `Lib lt:
cleanup(p, lt, lt.inputs, true)
+ | `Test tt:
+ cleanup(p, tt, tt.inputs, true)
| `Gen gt:
for f in gt.out
if std.remove(f)
@@ -43,6 +45,10 @@
| `Lib lt:
if std.sleq(lt.name, targ)
cleanup(p, lt, lt.inputs, true)
+ ;;
+ | `Test tt:
+ if std.sleq(tt.name, targ)
+ cleanup(p, tt, tt.inputs, true)
;;
| `Gen gt:
| `Sub subs:
--- a/install.myr
+++ b/install.myr
@@ -44,6 +44,7 @@
for m in mans
moveman(delete, m)
;;
+ | `Test tt: /* nothing */
;;
;;
-> true
--- a/parse.myr
+++ b/parse.myr
@@ -39,6 +39,7 @@
const target = {p : parser#
match word(p)
| `std.Some "bin": bintarget(p)
+ | `std.Some "test": testtarget(p)
| `std.Some "lib": libtarget(p)
| `std.Some "gen": gentarget(p)
| `std.Some "sub": subtarget(p)
@@ -52,6 +53,11 @@
/* bintarget: myrtarget */
const bintarget = {p
p.targs = std.slpush(p.targs, `Bin myrtarget(p, "bin"))
+}
+
+/* testtarget: myrtarget */
+const testtarget = {p
+ p.targs = std.slpush(p.targs, `Test myrtarget(p, "test"))
}
/* libtarget: myrtarget */
--- a/test.myr
+++ b/test.myr
@@ -16,7 +16,7 @@
;;
const test = {p
- var hasdir, ok
+ var hasdir, ok, bin
/* no implicit tests to run */
ok = true
@@ -24,13 +24,27 @@
if hasdir
for it in p.targs
match it
- | `Bin bt: ok = dotest(p, bt, ok)
- | `Lib lt: ok = dotest(p, lt, ok)
+ | `Bin bt:
+ if !dotest(p, bt, ok)
+ ok = false
+ ;;
+ | `Lib lt:
+ if !dotest(p, lt, ok)
+ ok = false
+ ;;
| _: /* ignore */
;;
;;
;;
- -> true
+ for `Test t in p.targs
+ buildbin(p, t, false)
+ bin = std.strcat("./", t.name)
+ if !runtest(bin)
+ ok = false
+ ;;
+ std.slfree(bin)
+ ;;
+ -> ok
}
const dotest = {p, targ, ok
@@ -38,7 +52,7 @@
tests = [][:]
for s in targ.inputs
- path = std.pathcat("test", s)
+ path = std.pathcat("./test", s)
if std.fexists(path)
bin = srcswapsuffix(path, "")
tt = [
--- a/types.myr
+++ b/types.myr
@@ -45,6 +45,7 @@
type targ = union
`Bin myrtarg#
`Lib myrtarg#
+ `Test myrtarg#
`Gen gentarg#
`Sub byte[:][:]
`Man byte[:][:]