shithub: mc

Download patch

ref: 82526d4456cab45d013dbf12fe9d49cd79ec9796
parent: a843f825632bd19e34a81bccf9b8a015a0196586
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Sep 17 16:32:59 EDT 2015

Handle tests generic tests for system impls.

    If we have foo+attr.myr in the main thing, try testing
    foo+attr.myr, and if that's not there, foo.myr.

--- a/lib/sys/sys+linux-x64.myr
+++ b/lib/sys/sys+linux-x64.myr
@@ -643,7 +643,7 @@
 
 	/* threading */
 	const futex	: (uaddr : int32#, op : futexop, val : int32, \
-		timeout : timespec#, uaddr2 : int#, val3 : int -> int64)
+		timeout : timespec#, uaddr2 : int32#, val3 : int32 -> int64)
 
 	/* polling */
 	const epollcreate	: (flg : epollflags	-> fd)	/* actually epoll_create1 */
--- a/mbld/test.myr
+++ b/mbld/test.myr
@@ -69,13 +69,14 @@
 }
 
 const buildtests = {b, targ
-	var tt, bin ,path, tests
+	var tt, bin, tests
 
 	tests = [][:]
 	setdir(b, targ.dir)
 	for s in targ.inputs
-		path = std.pathcat("./test", s)
-		if std.fexists(path)
+		match testpath(s)
+		| `std.None: /* nothing to do */
+		| `std.Some path:
 			bin = srcswapsuffix(path, "")
 			tt = [
 				.name = bin,
@@ -91,8 +92,8 @@
 			tests = std.slpush(tests, (std.strcat("./", bin), std.sldup(targ.dir)))
 			std.slfree(tt.libdeps)
 			std.slfree(tt.incpath)
+			std.slfree(path)
 		;;
-		std.slfree(path)
 	;;
 	-> tests
 }
@@ -144,5 +145,25 @@
 		;;
 	;;
 	-> r
+}
+
+const testpath = {s
+	var path, file
+
+	path = std.pathcat("./test", s)
+	if std.fexists(path)
+		-> `std.Some path
+	;;
+	match std.strfind(s, "+")
+	| `std.None:
+	| `std.Some idx:
+		file = std.strcat(s[:idx], ".myr")
+		path = std.pathcat("./test", file)
+		std.slfree(file)
+		if std.fexists(path)
+			-> `std.Some path
+		;;
+	;;
+	-> `std.None
 }