shithub: mc

Download patch

ref: b53309d883b5facd81d37606c49b432833f32b72
parent: b7730c04c8c83ad6a536a64e549d4d88cc636feb
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Aug 8 10:30:41 EDT 2017

Allow listing targets and selecting tests.

	This is the first half of running specific tests.
	The second half involves actually adding implicit test
	targets.

--- a/mbld/bld.sub
+++ b/mbld/bld.sub
@@ -1,6 +1,5 @@
 bin mbld =
 	build.myr
-	clean.myr
 	deps.myr
 	libs.myr
 	install.myr
--- a/mbld/build.myr
+++ b/mbld/build.myr
@@ -11,12 +11,15 @@
 ;;
 
 const buildtarg = {b, targ
-	var g
+	var g, targs
 
 	g = b.deps
-	var outs = std.htgetv(g.targs, targ, [][:])
-	for o : outs
-		mark(b, o)
+	match std.htget(g.targs, targ)
+	| `std.Some t:	targs = t
+	| `std.None:	fatal("unknown target: {}\n", targ)
+	;;
+	for t : targs
+		mark(b, t)
 	;;
 	build(b, g)
 	-> !b.fail
--- a/mbld/clean.myr
+++ /dev/null
@@ -1,8 +1,0 @@
-use std
-
-use "opts"
-use "types"
-use "util"
-
-pkg bld =
-;;
--- a/mbld/main.myr
+++ b/mbld/main.myr
@@ -91,15 +91,17 @@
 		if cmd.args.len == 0
 			ok = bld.buildtarg(b, "all")
 		else
-			for c : cmd.args
-				match c
-				| "clean":	r = bld.clean(b)
-				| "install":	r = bld.install(b)
-				| "uninstall":	r = bld.uninstall(b)
-				| "test":	r = bld.test(b)
-				| target:	r = bld.buildtarg(b, target)
+			match cmd.args[0]
+			| "clean":	r = bld.clean(b)
+			| "install":	r = bld.install(b)
+			| "uninstall":	r = bld.uninstall(b)
+			| "test":	r = bld.test(b, cmd.args[1:])
+			| "list":	r = show(b, cmd.args[1:])
+			| _:
+				ok = true
+				for target : cmd.args
+					r = ok && bld.buildtarg(b, target)
 				;;
-				ok = ok && r
 			;;
 		;;
 	;;
@@ -166,3 +168,8 @@
 	;;
 }
 
+const show = {b, targs
+	var k = std.htkeys(b.targs)
+	std.put("{j=\n}\n", k)
+	-> true
+}
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -9,10 +9,10 @@
 use "config"
 
 pkg bld =
-	const test	: (b : build# -> bool)
+	const test	: (b : build#, targs : byte[:][:] -> bool)
 ;;
 
-const test = {b
+const test = {b, targs
 	var failed, ok
 	var tests
 
@@ -19,7 +19,17 @@
 	if !buildtarg(b, "test")
 		std.exit(1)
 	;;
-	tests = std.htgetv(b.deps.targs, "test", [][:])
+	if targs.len == 0
+		tests = std.htgetv(b.deps.targs, "test", [][:])
+	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)
+			;;
+		;;
+	;;
 	ok = true
 	failed = [][:]
 	for t in tests