Skip to content

Commit

Permalink
NTest output handler for TAP messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nwf committed Dec 26, 2020
1 parent 884e0c2 commit c2c0ce6
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/NTest/NTestTapOut.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- This is a NTest output shim that formats its output in a way that resembles
-- the Test Anything Protocol (though prefixed with "TAP: " so we can more
-- readily find it in comingled output streams).

local nrun
return function(e, test, msg, err)
msg = msg or ""
err = err or ""
if e == "pass" then
print(("\nTAP: ok %d %s # %s\n"):format(nrun, test, msg))
nrun = nrun + 1
elseif e == "fail" then
print(("\nTAP: not ok %d %s # %s: %s\n"):format(nrun, test, msg, err))
nrun = nrun + 1
elseif e == "except" then
print(("\nTAP: not ok %d %s # exn; %s: %s\n"):format(nrun, test, msg, err))
nrun = nrun + 1
elseif e == "abort" then
print(("\nTAP: Bail out! %d %s # exn; %s: %s\n"):format(nrun, test, msg, err))
elseif e == "start" then
-- We don't know how many tests we plan to run, so emit a comment instead
print(("\nTAP: # STARTUP %s\n"):format(test))
nrun = 1
elseif e == "finish" then
-- Ah, now, here we go; we know how many tests we ran, so signal completion
print(("\nTAP: 1..%d\n"):format(nrun))
elseif #msg ~= 0 or #err ~= 0 then
print(("\nTAP: # %s: %s: %s\n"):format(test, msg, err))
end
end

0 comments on commit c2c0ce6

Please sign in to comment.