shithub: mc

Download patch

ref: 56c70bd6049b8eb88c7b7ab3636d6c1761fa0008
parent: 34a0fe0d51a0bf0679d2d3b4c09140c8447dac2c
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Mar 24 19:13:34 EDT 2018

Handle subtests correctly.

--- a/lib/std/env+posixy.myr
+++ b/lib/std/env+posixy.myr
@@ -69,11 +69,13 @@
 			idx++
 		;;
 	;;
-	if !found
+	if found
+		std.slfree(cstrconvp(environ[idx]))
+	else
 		idx = env.len - 1
 		std.slpush(&environ, Zenvp)
 	;;
-	e = cstrconvp(environ[idx])
+	environ[idx] = (e : byte#)
 	sys.__cenvp = (environ : byte##)
 	unlock(envlck)
 }
--- a/lib/testr/testr.myr
+++ b/lib/testr/testr.myr
@@ -149,21 +149,21 @@
 
 const testspec = {ts, sub
 	var ctx : ctx
-	var dorun, jmpbuf
+	var jmpbuf
 
 	ctx.ok = true
 	ctx.reason = ""
 	ctx.jmpbuf = &jmpbuf
-	dorun = matchtest(ts.name, sub)
+	if !matchtest(ts.name, sub)
+		-> void
+	;;
 
 	std.put("test {} <<{{!\n", ts.name)
-	if !std.setjmp(&jmpbuf) && dorun
+	if !std.setjmp(&jmpbuf)
 		ts.fn(&ctx)
 	;;
 
-	if !dorun
-		std.put("!}}>> skip filtered\n")
-	elif ctx.ok
+	if ctx.ok
 		std.put("!}}>> ok\n")
 	else
 		std.put("!}}>> fail {}\n", ctx.reason)
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -78,6 +78,13 @@
 	dir = std.pathcat(b.basedir, n.wdir)
 	std.chdir(dir)
 	std.slfree(dir)
+
+	if targs.len > 0
+		match std.strfind(targs[0], ":")
+		| `std.Some i:	std.setenv("MTEST_SUBSET", targs[0][i+1:])
+		| `std.None:	/* ok */
+		;;
+	;;
 	match std.spork(n.cmd)
 	| `std.Err m:
 		std.fatal("\nunable to run test: {}\n", m)