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

Commit 318de49

Browse files
livecodealimontegoulding
authored andcommitted
[[ Log ]] Add tests for log command
This patch adds tests for using the log command when the log message is empty, and when it is set to the name of a public handler and a private handler.
1 parent 6eb37a4 commit 318de49

File tree

4 files changed

+117
-4
lines changed

4 files changed

+117
-4
lines changed

tests/_testlib.livecodescript

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,18 +610,21 @@ on TestRepeat pDesc, pHandler, pTarget, pTimeOut, pParamsArray
610610
end if
611611
end TestRepeat
612612

613-
on TestRunStack pOptions, pStackFilePath
613+
command TestRunStack pOptions, pStackFilePath, pArgs
614614
local tEnginePath
615615
set the itemDelimiter to ":"
616616
put item 2 of the address into tEnginePath
617617

618618
local tCommand
619-
put format("\"%s\" %s \"%s\"", tEnginePath, pOptions, pStackFilePath) into tCommand
619+
put format("\"%s\" %s \"%s\" %s", tEnginePath, pOptions, pStackFilePath, pArgs) into tCommand
620620

621621
local tOutput
622622
put shell(tCommand) into tOutput
623-
624-
return the result
623+
if the result is not empty then
624+
return the result for error
625+
else
626+
return tOutput for value
627+
end if
625628
end TestRunStack
626629

627630
function TestIsInStandalone

tests/lcs/core/debugging/_log.lc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!
2+
3+
set the logMessage to $0
4+
log $1
5+
quit 0
6+
7+
command log pValue
8+
write "Error: this should not be called" & return to stderr
9+
quit 1
10+
end log
11+
12+
private command logPublic pValue
13+
write pValue & return to stdout
14+
end logPublic
15+
16+
private command logPrivate pValue
17+
write pValue & return to stdout
18+
end logPrivate
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
script "CoreDebugging_Log"
2+
/*
3+
Copyright (C) 2017 LiveCode Ltd.
4+
5+
This file is part of LiveCode.
6+
7+
LiveCode is free software; you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License v3 as published by the Free
9+
Software Foundation.
10+
11+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
18+
19+
on startup
20+
set the logMessage to $2
21+
log $3
22+
quit 0
23+
end startup
24+
25+
command log pValue
26+
write "Error: this should not be called" & return to stderr
27+
quit 1
28+
end log
29+
30+
command logPublic pValue
31+
write pValue & return to stdout
32+
end logPublic
33+
34+
private command logPrivate pValue
35+
write pValue & return to stdout
36+
end logPrivate
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
script "log"
2+
/*
3+
Copyright (C) 2019 LiveCode Ltd.
4+
5+
This file is part of LiveCode.
6+
7+
LiveCode is free software; you can redistribute it and/or modify it under
8+
the terms of the GNU General Public License v3 as published by the Free
9+
Software Foundation.
10+
11+
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
12+
WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
18+
19+
on TestLog
20+
local tStackToRun
21+
put the effective filename of me into tStackToRun
22+
set the itemdelimiter to slash
23+
if the environment is "server" then
24+
put "_log.lc" into item -1 of tStackToRun
25+
else
26+
put "_log.livecodescript" into item -1 of tStackToRun
27+
end if
28+
29+
local tOptions
30+
if the environment contains "command line" then
31+
put "-ui" into tOptions
32+
end if
33+
set the itemdelimiter to comma
34+
35+
local tArgs, tResult, tUUID
36+
put uuid() into tUUID
37+
repeat for each item tLogMessage in "logPublic,logPrivate"
38+
put tLogMessage && tUUID into tArgs
39+
TestRunStack tOptions, tStackToRun, tArgs
40+
if the result is not empty then
41+
TestDiagnostic the result
42+
else
43+
TestDiagnostic it
44+
end if
45+
TestAssert "log message" && tLogMessage, tUUID is in it
46+
end repeat
47+
48+
put quote & quote && tUUID into tArgs
49+
TestRunStack tOptions, tStackToRun, tArgs
50+
if the result is not empty then
51+
TestDiagnostic the result
52+
else
53+
TestDiagnostic it
54+
end if
55+
TestAssert "log message" && tLogMessage, tUUID is not in it
56+
end TestLog

0 commit comments

Comments
 (0)