summaryrefslogtreecommitdiff
path: root/Tools/LuaMacro/tests/run-tests.lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-11-17 23:03:07 +0800
committerchai <chaifix@163.com>2021-11-17 23:03:07 +0800
commit27d6efb5f5a076f825fe2da1875e0cabaf02b4e7 (patch)
tree44f301110bc2ea742908ed92a78eba0803cd3b60 /Tools/LuaMacro/tests/run-tests.lua
parentb34310c631989551054d456eb47aaab5ded266a4 (diff)
+ LuaMacro
Diffstat (limited to 'Tools/LuaMacro/tests/run-tests.lua')
-rw-r--r--Tools/LuaMacro/tests/run-tests.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/Tools/LuaMacro/tests/run-tests.lua b/Tools/LuaMacro/tests/run-tests.lua
new file mode 100644
index 0000000..8bc3317
--- /dev/null
+++ b/Tools/LuaMacro/tests/run-tests.lua
@@ -0,0 +1,35 @@
+-- similar syntax to tests.bat, but more portable and aware of errors.
+require_ 'forall'
+require_ 'qw'
+local lua52 = _VERSION:match '5.2'
+local lua51 = not lua52
+def_ put io.stderr:write
+
+local tests = qw(dollar,lambda,try,block,forall,scope,do,const,with,case,mod,test,rawhash)
+
+local luam = lua51 and 'luam' or 'luam52'
+
+function run (f)
+ put(f,': ')
+ local res = os.execute(luam..' '..f)
+ if (lua52 and not res) or (lua51 and res ~= 0) then
+ put 'failed!\n'
+ os.exit(1)
+ else
+ put 'ok\n'
+ end
+end
+
+forall f in tests do
+ f = 'test-'..f..'.lua'
+ run(f)
+end
+
+run '-lcskin test-cskin.lua'
+
+if pcall(require,'pl') then
+ run 'test-list.lua'
+ run 'test-pl-list.lua'
+end
+
+