-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NTest output handler for TAP messages
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |