[Omake] Tests

David Kågedal davidk at lysator.liu.se
Mon Sep 4 03:22:18 PDT 2006


There is a directory called "tests" in the distribution, and in the
0.9.8.x svn branch.  But there isn't very much in it.  And I don't see
any way to run all the tests.

I whipped up a quick osh script that will run  all tests and print
FAILED if the exit status wasn't 0.  It scans for files or directories
called Test or Test1..Test9.  For files, it runs them through osh, and
for directories it cd's to them and runs omake.

This is not really functioning, since many of the test scripts are not
written to test itself, but it's a start.

And it probably also shows that I'm a beginner osh programmer :-)  Two
things I really missed were a $(dirname ...) function.  The $(dirof
...) function doesn't give the parent directory if the given name is
already a directory, and the other was a simple way to find a list of
all file names matching the regexp "Test[0-9]*".

--- tests/runall	(revision 0)
+++ tests/runall	(revision 0)
@@ -0,0 +1,35 @@
+#!/usr/bin/osh
+# -*- Makefile -*-
+
+dirname(seq) =
+    X =
+	foreach(x, $(seq))
+	    d = $(dirof $x)
+	    if $(equal $x, $d)
+		d = $(string $(dir $(d)/..))
+		export
+            value $d
+    return $X
+
+TESTDIRS = $(set $(dirname $(glob */Test*)))
+
+runtest(subtest) =
+    if $(test -f $(subtest))
+        res = $(shell-code osh $(subtest) >& $(resultfile))
+        export res
+    else
+	cd $(subtest)
+	res = $(shell-code omake >& $(resultfile))
+        export res
+    return$(equal $(res), 0)
+
+foreach(testdir, $(TESTDIRS))
+    echo "Testing $(testdir)"
+    cd $(testdir)
+    subtests = $(filter-exists Test)
+    subtests += $(glob i, Test[1-9])
+    foreach(subtest, $(subtests))
+        echo "  ... $(subtest)"
+	resultfile = $(file $(subtest).result)
+	if $(not $(runtest $(subtest)))
+            echo "      FAILED"



-- 
David Kågedal



More information about the Omake mailing list