Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
L
lua-TestMore
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 2
    • Issues 2
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • François Perrad
  • lua-TestMore
  • Issues
  • #11

Closed
Open
Opened Feb 07, 2020 by Enrico Scholz@ensc

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)
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: fperrad/lua-TestMore#11