@@ -19,6 +19,8 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1919-- FIXME provide this on the command line
2020constant kLogFilename = "_test_suite.log"
2121
22+ local sTestsRun = false
23+
2224on startup
2325 local tTarget
2426 if the target begins with "card" then
@@ -28,17 +30,23 @@ on startup
2830 end if
2931
3032 if tTarget is the long id of me then
31- if the environment begins with "development" then
32- send "TestRunnerInvokeAll" to me in 0
33- else
34- send "TestRunnerMain" to me in 0
35- end if
33+ if the environment begins with "development" then
34+ if not sTestsRun then
35+ send "TestRunnerInvokeAll" to me in 0
36+ end if
37+ put true into sTestsRun
38+ else
39+ send "TestRunnerMain" to me in 0
40+ end if
3641 end if
37- end startup
42+ end startup
3843
3944on openStack
4045 if the long id of the target is the long id of this card of me then
41- send "TestRunnerInvokeAll" to me in 0
46+ if not sTestsRun then
47+ send "TestRunnerInvokeAll" to me in 0
48+ end if
49+ put true into sTestsRun
4250 end if
4351end openStack
4452
@@ -328,66 +336,76 @@ end invokeLoadLibrary
328336
329337-- Add the test runner library stack to the backscripts
330338private command runLoadLibrary pInfo
331- -- Compute the filename of the library stack
332- local tFilename
333- put pInfo ["self-script" ] into tFilename
334-
335- set the itemDelimiter to slash
336- put "_testerlib.livecodescript" into item - 1 of tFilename
337- put "../" before tFilename
338- -- Load the library
339- local tStackname
340- put the name of stack tFilename into tStackname
341-
342- send "revLoadLibrary" to stack tStackname
339+ -- Compute the filename of the library stack
340+ local tFilename
341+ put the effective filename of me into tFileName
342+ set the itemDelimiter to slash
343+ put "tests/_testerlib.livecodescript" into item - 3 to - 1 of tFilename
344+ -- Load the library
345+ local tStackname
346+ put the name of stack tFilename into tStackname
347+
348+ send "revLoadLibrary" to stack tStackname
343349end runLoadLibrary
344350
345351-- Launch this stack in the IDE
346352private command runAllTests pInfo
347353 local tAnalysis
348-
354+
349355 -- Invoke the test in a subprocess. This ensures that we can detect
350356 -- if a crash occurs
351357 local tTestOutput , tTestExitStatus , tCommand
352358
353359 -- First put the target engine into the command to run
354360 put pInfo ["args" ][2 ] into tCommand
355-
361+
356362 -- Add the command line args
357363 repeat with x = 3 to the number of elements in pInfo ["args" ]
358364 put tCommand && pInfo ["args" ][x] into tCommand
359365 end repeat
360366
361367 -- Add the target stack (this one)
362368 put tCommand && pInfo ["self-script" ] into tCommand
363-
369+
364370 -- Execute the shell command
365- put shell (tCommand ) into tTestOutput
366- put the result into tTestExitStatus
371+ open process tCommand for text read
372+ set the itemDelimiter to ":"
373+ repeat
374+ if tCommand is not among the lines of the openProcesses then
375+ exit repeat
376+ end if
377+
378+ read from process tCommand for 1 line
379+ local tOutput
380+ -- The output from the subprocesses will be native encoded utf-8.
381+ put textDecode (it , "utf8" ) into tOutput
382+
383+ if item 1 of tOutput is "PASS" or \
384+ item 1 of tOutput is "XPASS" or \
385+ item 1 of tOutput is "FAIL" or \
386+ item 1 of tOutput is "XFAIL" then
387+ write logHighlight(item 1 of tOutput ) & ":" & item 2 to - 1 of tOutput to stdout
388+ else if tOutput begins with "not ok" then
389+ write tOutput to stdout
390+ end if
391+
392+ put tOutput after tTestOutput
393+ if the result is not empty then
394+ exit repeat
395+ end if
396+ end repeat
397+ set the itemDelimiter to comma
398+ close process tCommand
367399
368- -- The output from the subprocesses will be native encoded utf-8.
369- put textDecode (tTestOutput , "utf8" ) into tTestOutput
370-
371400 -- Check the exit status. If it suggests failure, add a "not ok" stanza
372401 -- to the tail of the TAP output
402+ -- !TODO Can't get exit status from open process
373403 if tTestExitStatus is not empty then
374404 put return after tTestOutput
375405 put "not ok # Subprocess exited with status" && \
376406 tTestExitStatus & return after tTestOutput
377407 end if
378408
379- local tUsefulOutput
380- repeat for each line tLine in tTestOutput
381- if tLine begins with "PASS:" then
382- put tLine & return after tUsefulOutput
383- else if tLine begins with "FAIL:" then
384- put tLine & return after tUsefulOutput
385- else if tLine begins with "not ok" then
386- put tLine & return after tUsefulOutput
387- end if
388- end repeat
389- write tUsefulOutput to stdout
390-
391409 runTestProcessOutput "IDE" , "All IDE tests" , tTestOutput
392410
393411 put TesterTapCombine(tAnalysis , the result ) into tAnalysis
0 commit comments