RFE: return information whether tests succeeded
Atm, it seems to be not possible to check the test status directly. Instead of, there must be called an external program which parses the output.
To simplify automated tests I would like to avoid such external parsing and let the script fail on errors; e.g.:
require 'Test.More'
is(1,2)
return true -- if everything ok, or
return false -- if some tests failed
When passing back the self.is_passing
status in Builder.done_testing()
to More.done_testing()
and returning it there, you could write above
return done_testing()
Perhaps subtest()
could return the test status too. Something like
diff --git a/src/Test/Builder.lua b/src/Test/Builder.lua
index 055d107..cacdf3a 100644
--- a/src/Test/Builder.lua
+++ b/src/Test/Builder.lua
@@ -120,6 +120,8 @@ function m:subtest (name, func)
child:done_testing()
end
child:finalize()
+
+ return child.is_passing
end
function m:finalize ()
@@ -222,6 +224,8 @@ function m:done_testing (num_tests)
if self.curr_test == 0 then
self.is_passing = false
end
+
+ return self.is_passing
end
function m:has_plan ()
diff --git a/src/Test/More.lua b/src/Test/More.lua
index 273ab5f..fd7cf03 100644
--- a/src/Test/More.lua
+++ b/src/Test/More.lua
@@ -23,7 +23,7 @@ function m.plan (arg)
end
function m.done_testing (num_tests)
- tb:done_testing(num_tests)
+ return tb:done_testing(num_tests)
end
function m.skip_all (reason)
@@ -130,7 +130,7 @@ function m.type_ok (val, t, name)
end
function m.subtest (name, func)
- tb:subtest(name, func)
+ return tb:subtest(name, func)
end
function m.pass (name)