Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 9539464

Browse files
committed
[[ Tests ]] Move TestRunnerRunPrintSummary to tester lib
This patch relocates the summary printing to the tester lib to centralise output of tests. This also adds a mechanism to redirect test output to post to a URL for mobile testing. (cherry picked from commit a685485)
1 parent d6b1d5e commit 9539464

4 files changed

Lines changed: 66 additions & 44 deletions

File tree

tests/_compilertestrunnerbehavior.livecodescript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private command runAllScripts pInfo
7171
runCompilerTestScript pInfo, tFile
7272
put TesterTapCombine(tAnalysis, the result) into tAnalysis
7373
end repeat
74-
TestRunnerRunPrintSummary(tAnalysis)
74+
TesterRunPrintSummary tAnalysis
7575
return tAnalysis
7676
end runAllScripts
7777

tests/_testerlib.livecodescript

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ on revLoadLibrary
2525
insert the script of me into back
2626
end revLoadLibrary
2727

28+
local sLogCallbackURL
29+
2830
----------------------------------------------------------------
2931
-- Script-only stack handling
3032
----------------------------------------------------------------
@@ -117,7 +119,13 @@ function TesterParseTestCommandNames pFilename
117119

118120
if tCommandNameSeen[tName] then
119121
-- Duplicate test name
120-
write merge("Error: duplicate test name [[tName]] in [[pFilename]]\n") to stderr
122+
123+
get merge("Error: duplicate test name [[tName]] in [[pFilename]]\n")
124+
if sLogCallbackURL is not empty then
125+
post "^err^N^"&it to sLogCallbackURL
126+
else
127+
write it to stderr
128+
end if
121129
quit 1
122130
end if
123131

@@ -314,21 +322,72 @@ command TesterLog pStatus, pDescription
314322
put space after tMessage
315323
end if
316324

317-
write tMessage && pDescription & return to stdout
325+
get tMessage && pDescription & return
326+
if sLogCallbackURL is not empty then
327+
post "^out^N^"&it to sLogCallbackURL
328+
else
329+
write it to stdout
330+
end if
318331
end TesterLog
319332

320333
command TesterLogSummaryLine pTapResults, pTestName
321334
local tTotal, tPassed, tWorst, tMessage
322-
335+
323336
put pTapResults["xpass"] + pTapResults["pass"] + pTapResults["skip"] into tPassed
324337
put TesterTapGetTestCount(pTapResults) into tTotal
325-
338+
326339
put TesterTapGetWorstResult(pTapResults) into tWorst
327340
put pTestName into tMessage
328341
put space & "[" & tPassed & "/" & tTotal & "]" after tMessage
329342
if pTapResults["failures"] is not empty then
330343
put return & pTapResults["failures"] after tMessage
331344
end if
332-
345+
333346
TesterLog tWorst, tMessage
334347
end TesterLogSummaryLine
348+
349+
command TesterLogSetCallbackURL pURL
350+
put pURL into sLogCallbackURL
351+
end TesterLogSetCallbackURL
352+
353+
354+
-- Print out a table of statistics
355+
command TesterRunPrintSummary pAnalysis
356+
local tSummaryString, tTotal, tDecoration
357+
358+
put TesterTapGetTestCount(pAnalysis) into tTotal
359+
360+
-- Format basic summary information
361+
if pAnalysis["xfail"] is 0 and pAnalysis["fail"] is 0 then
362+
put "All" && tTotal && "tests passed" into tSummaryString
363+
364+
else if pAnalysis["fail"] is 0 then
365+
put "All" && tTotal && "tests behaved as expected" into tSummaryString
366+
367+
else
368+
put pAnalysis["fail"] && "OF" && tTotal && "TESTS FAILED" into tSummaryString
369+
end if
370+
371+
put return after tSummaryString
372+
373+
-- Add extra summary info from expected failure & skip directives
374+
if pAnalysis["xpass"] > 0 then
375+
put tab & pAnalysis["xpass"] && "unexpected passes" & return after tSummaryString
376+
end if
377+
if pAnalysis["xfail"] > 0 then
378+
put tab & pAnalysis["xfail"] && "expected failures" & return after tSummaryString
379+
end if
380+
if pAnalysis["skip"] > 0 then
381+
put tab & pAnalysis["skip"] && "skipped" & return after tSummaryString
382+
end if
383+
384+
put "================================================================" into tDecoration
385+
put tDecoration & return before tSummaryString
386+
put tDecoration & return after tSummaryString
387+
388+
if sLogCallbackURL is not empty then
389+
post "^out^N^"&tSummaryString to sLogCallbackURL
390+
else
391+
write tSummaryString to stdout
392+
end if
393+
end TesterRunPrintSummary

tests/_testrunner.livecodescript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private command runAllScripts pInfo, pFolder
9494
runTestScript pInfo, tFile
9595
put TesterTapCombine(tAnalysis, the result) into tAnalysis
9696
end repeat
97-
TestRunnerRunPrintSummary tAnalysis
97+
TesterRunPrintSummary tAnalysis
9898

9999
return tAnalysis
100100
end runAllScripts

tests/_testrunnerbehavior.livecodescript

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -241,40 +241,3 @@ command TestRunnerProcessOutput pScriptfile, pCommand, pOutput
241241

242242
return tTapResults
243243
end TestRunnerProcessOutput
244-
245-
-- Print out a table of statistics
246-
command TestRunnerRunPrintSummary pAnalysis
247-
local tSummaryString, tTotal, tDecoration
248-
249-
put TesterTapGetTestCount(pAnalysis) into tTotal
250-
251-
-- Format basic summary information
252-
if pAnalysis["xfail"] is 0 and pAnalysis["fail"] is 0 then
253-
put "All" && tTotal && "tests passed" into tSummaryString
254-
255-
else if pAnalysis["fail"] is 0 then
256-
put "All" && tTotal && "tests behaved as expected" into tSummaryString
257-
258-
else
259-
put pAnalysis["fail"] && "OF" && tTotal && "TESTS FAILED" into tSummaryString
260-
end if
261-
262-
put return after tSummaryString
263-
264-
-- Add extra summary info from expected failure & skip directives
265-
if pAnalysis["xpass"] > 0 then
266-
put tab & pAnalysis["xpass"] && "unexpected passes" & return after tSummaryString
267-
end if
268-
if pAnalysis["xfail"] > 0 then
269-
put tab & pAnalysis["xfail"] && "expected failures" & return after tSummaryString
270-
end if
271-
if pAnalysis["skip"] > 0 then
272-
put tab & pAnalysis["skip"] && "skipped" & return after tSummaryString
273-
end if
274-
275-
put "================================================================" into tDecoration
276-
put tDecoration & return before tSummaryString
277-
put tDecoration & return after tSummaryString
278-
279-
write tSummaryString to stdout
280-
end TestRunnerRunPrintSummary

0 commit comments

Comments
 (0)