FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
livecode-ide/tests/_testrunner.livecodescript at develop · livecode/livecode-ide · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
livecode
/
livecode-ide
Public archive
Notifications
You must be signed in to change notification settings
Fork
71
Star
35
Code
Issues
28
Pull requests
42
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
livecode-ide
/
tests
/
_testrunner.livecodescript
Copy path
More file actions
More file actions
Latest commit
History
History
History
319 lines (255 loc) · 9.37 KB
Breadcrumbs
livecode-ide
/
tests
/
_testrunner.livecodescript
Copy path
File metadata and controls
319 lines (255 loc) · 9.37 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
script
"IDETestRunner
"
/*
Copyright (C) 2016 LiveCode Ltd.
This file is part of LiveCode.
LiveCode is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License v3 as published by the Free
Software Foundation.
LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with LiveCode. If not see <http://www.gnu.org/licenses/>.
*/
private
function
getTestRunnerBehavior
--
Compute the filename of the test runner
local
tRepoPath
,
tStack
set
the
itemdelimiter
to
"/"
put
item
1
to
-
4
of
the
effective
filename
of
me
into
tRepoPath
put
tRepoPath
&
"/tests/_testrunnerbehavior.livecodescript"
into
tStack
return
the
long
id
of
stack
tStack
end
getTestRunnerBehavior
local
sStarted
local
sTestsRun
=
false
private
command
startTestRunner
if
sStarted
then
exit startTestRunner
end if
put
true
into
sStarted
local
tTestRunner
put
getTestRunnerBehavior()
into
tTestRunner
set
the
behavior
of
me
to
tTestRunner
if
the
environment
begins with
"development"
then
if
not
sTestsRun
then
send
"TestRunnerImpl_DoInvoke"
to
me
in
0
end if
put
true
into
sTestsRun
else
send
"TestRunnerMain"
to
me
in
0
end if
end
startTestRunner
on
startup
local
tTarget
if
the
target
begins with
"card"
then
put
the
long
id
of
the
owner
of
the
target
into
tTarget
else
put
the
long
id
of
the
target
into
tTarget
end if
if
tTarget
is
the
long
id
of
me
then
startTestRunner
end if
end
startup
on
openStack
if
the
long
id
of
the
target
is
the
long
id
of
this card
of
me
then
startTestRunner
end if
end
openStack
--
--------------------------------------------------------------
--
Top-level actions
--
--------------------------------------------------------------
command
TestRunnerImpl_DoInvoke
pInfo
TestRunnerRunLoadLibraries
TestRunnerInvokeLoadLibraries
--
Don't output to stdout
TestOutputToVariable
if
pInfo
[
"invoke"
][
"script"
]
is not
empty
then
invokeTest
pInfo
else
invokeAllTests
end if
end
TestRunnerImpl_DoInvoke
command
TestRunnerImpl_DoRun
pInfo
runAllTests
pInfo
return
the
result
for
value
end
TestRunnerImpl_DoRun
private
command
TestRunnerImpl_DoUsage
pStatus
write
"Usage: _testrunner.livecodescript run DEV-ENGINE"
&
return
to
stderr
quit
pStatus
end
TestRunnerImpl_DoUsage
--
--------------------------------------------------------------
--
Support for invoking test commands
--
--------------------------------------------------------------
private
command
invokeLoadIDE
--
Compute the filename of the home stack
local
tFilename
put
the
filename
of
me
into
tFilename
set
the
itemDelimiter
to
slash
put
"Toolset/home.livecodescript"
into
item
-
2
to
-
1
of
tFilename
local
tStackName
--
load home stack
put
the
name
of
stack
tFilename
into
tStackName
--
Set the 'test environment' to true
dispatch
"revSetTestEnvironment"
to
stack
tStackName
with
true
insert
the
script
of
tStackName
into
back
dispatch
"startup"
to
tStackName
TestAssert
"IDE startup without error"
,
the
result
is
empty
open
tStackName
end
invokeLoadIDE
private
command
TestLoadIDE
if
there is not a
stack
"home"
then
local
tDefaultFolder
put
the
defaultFolder
into
tDefaultFolder
try
invokeLoadIDE
catch
tError
end try
TestAssert
"Home stack opens without error"
,
tError
is
empty
TestDiagnostic
tError
TestAssert
"IDE load preserves defaultFolder"
, \
the
defaultFolder
is
tDefaultFolder
TestDiagnostic
"original default folder:"
&&
tDefaultFolder
TestDiagnostic
"new default folder:"
&&
the
defaultFolder
end if
--
gRevDevelopment should be true by default
global
gRevDevelopment
put
true
into
gRevDevelopment
local
tStartupError
put
revEnvironmentGetStartupLog(
"Error"
)
into
tStartupError
TestAssert
"Home stack opens without error"
,
tStartupError
is
empty
if
tStartupError
is not
empty
then
TestDiagnostic revEnvironmentGetStartupLog(
"Message"
)
end if
local
tAnalysis
TestUpdateAnalysis
the
effective
filename
of
me, \
"TestLoadIDE"
,
tAnalysis
return
tAnalysis
end
TestLoadIDE
private
command
TestUpdateAnalysis
pFilename, pTestCommand, @xAnalysis
local
tOutput
put
TestFetchAndClearOutput()
into
tOutput
write
textEncode
(
tOutput
,
"utf-8"
)
to
stdout
TestRunnerProcessOutput
pFilename
,
pTestCommand
,
tOutput
put
TesterTapCombine(xAnalysis,
the
result
)
into
xAnalysis
end
TestUpdateAnalysis
private
command
appendToList
pElt, @xList
put
pElt
into
xList[
the
number
of
elements
in
xList
+
1
]
end
appendToList
private
function
getAllTestFileNames
local
tIDETests
,
tIDESupportTests
put
TestGetIDERepositoryPath()
&
"/tests"
into
tIDETests
put
TestGetEngineRepositoryPath()
&
"/tests/ide-support"
into
tIDESupportTests
local
tFiles
repeat
for
each
element
tFile
in
TesterGetTestFileNames(
tIDETests
)
appendToList
tIDETests
&
slash
&
tFile
,
tFiles
end repeat
repeat
for
each
element
tFile
in
TesterGetTestFileNames(
tIDESupportTests
)
appendToList
tIDESupportTests
&
slash
&
tFile
,
tFiles
end repeat
return
tFiles
end
getAllTestFileNames
private
command
invokeAllTests
local
tAnalysis
TestLoadIDE
put
the
result
into
tAnalysis
repeat
for
each
element
tFile
in
getAllTestFileNames()
invokeTestScript
tFile
put
TesterTapCombine(
tAnalysis
,
the
result
)
into
tAnalysis
end repeat
TesterRunPrintSummary
tAnalysis
quit
0
end
invokeAllTests
private
command
invokeTest
pInfo
local
tScriptFile
,
tCommand
--
This should auto-load the test script
put
pInfo
[
"invoke"
][
"script"
]
into
tScriptFile
put
pInfo
[
"invoke"
][
"command"
]
into
tCommand
TestRunnerInvokeTest
Command
tScriptFile
,
tCommand
end
invokeTest
--
Run the tests found in one specific script file
private
command
invokeTestScript
pScriptFile
--
Don't output to stdout
TestOutputToVariable
local
tCommand
,
tAnalysis
,
tOutput
repeat
for
each
element
tCommand
in
TesterParseTestCommandNames(
pScriptFile
)
invokeTest
Command
pScriptFile
,
tCommand
TestUpdateAnalysis
pScriptFile
,
tCommand
,
tAnalysis
end repeat
return
tAnalysis
end
invokeTestScript
--
Execute a test
private
command
invokeTestCommand
pScriptFile, pCommand
--
Try and remove any stacks that have been opened
local
tStacks
put
the
openstacks
into
tStacks
--
Make sure this is not the default stack
create
stack
set
the
defaultStack
to
the
short
name
of
it
TestRunnerInvokeTest
Command
pScriptFile
,
pCommand
--
Attempt to restore IDE to its pre-test state
global
gRevStackStatus
repeat
for
each
line
tStack
in
the
openstacks
if
tStack
is not among
the
lines
of
tStacks
then
--
Ensure IDE doesn't prompt for save
put
empty
into
gRevStackStatus
[
tStack
]
delete
stack
tStack
end if
end repeat
end
invokeTestCommand
--
--------------------------------------------------------------
--
Support for running tests
--
--------------------------------------------------------------
--
Launch this stack in the IDE
private
command
runAllTests
pInfo
local
tAnalysis
--
Invoke the test in a subprocess. This ensures that we can detect
--
if a crash occurs
local
tTestOutput
,
tTestExitStatus
,
tCommand
--
First put the target engine into the command to run
put
pInfo
[
"args"
][
2
]
into
tCommand
--
Add the command line args
repeat
with
x
=
3
to
the
number
of
elements
in
pInfo
[
"args"
]
put
tCommand
&&
pInfo
[
"args"
][x]
into
tCommand
end repeat
--
Add the target stack (this one)
put
tCommand
&&
pInfo
[
"self-script"
]
&&
"2>/dev/null"
into
tCommand
--
Execute the shell command
open
process
tCommand
for
text
read
set
the
itemDelimiter
to
":"
repeat
if
tCommand
is not among
the
lines
of
the
openProcesses
then
exit
repeat
end if
local
tResult
read from process
tCommand
for
1
line
put
the
result
into
tResult
local
tOutput
--
The output from the subprocesses will be native encoded utf-8.
put
textDecode
(
it
,
"utf8"
)
into
tOutput
if
item
1
of
tOutput
is
"PASS"
or
\
item
1
of
tOutput
is
"XPASS"
or
\
item
1
of
tOutput
is
"FAIL"
or
\
item
1
of
tOutput
is
"XFAIL"
then
TesterLog
item
1
of
tOutput
,
item
2
to
-
1
of
line
1
of
tOutput
else
if
tOutput
begins with
"not ok"
then
write
tOutput
to
stdout
end if
put
tOutput
after
tTestOutput
if
tResult
is not
empty
then
exit
repeat
end if
end repeat
set
the
itemDelimiter
to
comma
close process
tCommand
--
Check the exit status. If it suggests failure, add a "not ok" stanza
--
to the tail of the TAP output
--
!TODO Can't get exit status from open process
if
tTestExitStatus
is not
empty
then
put
return
after
tTestOutput
put
"not ok # Subprocess exited with status"
&&
\
tTestExitStatus
&
return
after
tTestOutput
end if
TestRunnerProcessOutput
"IDE"
,
"All IDE tests"
,
tTestOutput
put
TesterTapCombine(
tAnalysis
,
the
result
)
into
tAnalysis
TesterRunPrintSummary
tAnalysis
return
tAnalysis
end
runAllTests
Back
|
FazBrowse Home
|
New Git URL