Browse Source

Improve test output;

bjorn 10 years ago
parent
commit
4ca5949826
1 changed files with 19 additions and 9 deletions
  1. 19 9
      tests/runner.lua

+ 19 - 9
tests/runner.lua

@@ -7,18 +7,28 @@ end
 
 
 if arg[1] then
 if arg[1] then
   arg[1] = arg[1]:gsub('^(tests/).+', ''):gsub('%.lua$', '')
   arg[1] = arg[1]:gsub('^(tests/).+', ''):gsub('%.lua$', '')
-  return dofile('tests/' .. arg[1] .. '.lua')
+  dofile('tests/' .. arg[1] .. '.lua')
+else
+  local files = {
+    'observer'
+  }
+
+  for i, file in ipairs(files) do
+    dofile('tests/' .. file .. '.lua')
+    if next(files, i) then
+      print()
+    end
+  end
 end
 end
 
 
-local files = {
-  'observer'
-}
+local red = string.char(27) .. '[31m'
+local green = string.char(27) .. '[32m'
+local normal = string.char(27) .. '[0m'
 
 
-for i, file in ipairs(files) do
-  dofile('tests/' .. file .. '.lua')
-  if next(files, i) then
-    print()
-  end
+if lust.errors > 0 then
+  io.write(red .. lust.errors .. normal .. ' failed, ')
 end
 end
 
 
+print(green .. lust.passes .. normal .. ' passed')
+
 if lust.errors > 0 then os.exit(1) end
 if lust.errors > 0 then os.exit(1) end