This repository was archived by the owner on Aug 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 227
Expand file tree
/
Copy pathframework.livecode
More file actions
321 lines (282 loc) · 12.1 KB
/
framework.livecode
File metadata and controls
321 lines (282 loc) · 12.1 KB
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
320
321
REVO5500 ö ExecTestFramework @ ½‡Š
5S • ÿÿÿÿ cRevStandaloneSettings &scriptLibraries Internet
Geometry
PrintingMacOSX true OSX,name ExecTestFrameworkUNIX,fileSelector trueWindows trueWindows,LegalCopyright #2012 All rights reserved worldwideUNIX,pageSetup trueOSX,documentType Linux trueinclusions searchWindows,documenticonFile aC:/Program Files/RunRev/LiveCode 5.5.3/Runtime/Windows/x86-32/Support/Sample Icons/genericdoc.ico
answerDialog trueOSX,documentExtension Windows,FileDescription %ExecTestFramework 1.0.0.0 for WindowsOSX,longVersion ExecTestFramework 1.0.0.0UNIX,printerChooser trueOSX,copyright #2012 All rights reserved worldwideOSX,identifier com..exectestframeworkname ExecTestFrameworkOSX,shortVersion 1.0.0.0Windows,fileversion1 1Windows,fileversion2 0Windows,productversion1 1Windows,fileversion3 0Windows,productversion2 0Windows,fileversion4 0Windows,productversion3 0cursors falseWindows,productversion4 0 OSX,info !ExecTestFramework Version 1.0.0.0MacOSX PowerPC-32 false
askDialog trueWindows,iconFile aC:/Program Files/RunRev/LiveCode 5.5.3/Runtime/Windows/x86-32/Support/Sample Icons/genericapp.icoOSX,signature ????Windows,ProductName ExecTestFrameworkUNIX,colorChooser trueMacOSX x86-32 falseWindows,companyname cREVGeometryCache stackID 1014 cREVGeneral breakpointconditions breakpoints breakpointstates stackfileversion 5.5AlreadyHidden false ê P!3on preOpenCard
put "<all>" & return & listModules() into button "Modules"
end preOpenCard
----------------------------------------------------------------------------------------
command runTests pMode, pTestToRun
put empty into field "Log"
-- The path to the engine we want is a mode engine within the checked-out
-- branch we have.
local tBuildFolder, tInputEngine, tOutputEngine
set the itemDelimiter to slash
put item 1 to -4 of the filename of this stack & slash & "_build/" & pMode into tBuildFolder
put tBuildFolder & "/standalone.exe" into tInputEngine
put tBuildFolder & "/exec-tests.exe" into tOutputEngine
if there is no file tInputEngine then
answer "Cannot find standalone engine - " && tInputEngine
exit runTests
end if
if there is a file tOutputEngine then
delete file tOutputEngine
if there is a file tOutputEngine then
answer "Cannot build tests as cannot delete existing test engine - " & tOutputEngine
exit runTests
end if
end if
local tTestIndex
put 1 into tTestIndex
local tTestScript
put the script of button "Template" & return after tTestScript
local tModules
if pTestToRun is empty then
if the label of button "Modules" is "<all>" then
put listModules() into tModules
else
put the label of button "Modules" into tModules
end if
else
set the itemDelimiter to "."
put item 1 of pTestToRun into tModules
set the itemDelimiter to comma
end if
local tSuccess
put true into tSuccess
repeat for each line tModule in tModules
repeat for each line tTest in listTestsForModule(tModule)
if pTestToRun is not empty and (pTestToRun & ".test") is not (tModule & "." & tTest) then
next repeat
end if
get processTest(tModule, tTest, tTestIndex)
if it is not empty then
put it & return after tTestScript
else
put false into tSuccess
end if
end repeat
end repeat
if not tSuccess then
exit runTests
end if
create stack "__TESTS__"
set the script of stack "__TESTS__" to tTestScript
copy button "revLibURL" of stack "revLibrary" to card 1 of stack "__TESTS__"
set the name of it to "revLibUrl"
save stack "__TESTS__" as tBuildFolder & slash & "exec-tests.livecode"
delete stack "__TESTS__"
local tDeployInfo
put tInputEngine into tDeployInfo["engine"]
put tBuildFolder & slash & "exec-tests.livecode" into tDeployInfo["stackfile"]
put tOutputEngine into tDeployInfo["output"]
_internal deploy windows tDeployInfo
if the result is not empty then
answer "Cannot build test engine due to -" && the result
exit runTests
end if
/*local tNextTestIndex, tProcessOutputs
put 1 into tNextTestIndex
repeat forever
repeat for each line tProcess in the openProcesses
read from process tProcess until empty
if it is not empty then
put it after tProcessOutputs[tProcess]
end if
if the result is not empty then
close process tProcess
put tProcessOutputs[tProcess] after field "Log"
delete variable tProcessOutputs[tProcess]
end if
end repeat
repeat while the number of lines in the openProcesses < 16
if tNextTestIndex > tTestIndex then
exit repeat
end if
open process (tOutputEngine && tNextTestIndex) for binary read
add 1 to tNextTestIndex
end repeat
if the openProcesses is empty then
exit repeat
end if
end repeat*/
set the hideConsoleWindows to true
repeat with i = 1 to tTestIndex
get shell(tOutputEngine && i)
put it after field "Log"
set the vScroll of field "log" to the formattedHeight of field "log"
end repeat
end runTests
function processTest pModule, pTest, @pIndex
local tInput, tOutput
put url ("file:" & testsPath() & slash & pModule & slash & pTest) into tInput
if tInput is empty then
return return
end if
local tLineIndex
put 1 into tLineIndex
repeat for each line tLine in tInput
switch word 1 of tLine
case "setup"
put "command runTest_" & pIndex & return after tOutput
processTestSetupLine tOutput, pModule, pTest, tLineIndex, word 2 to -1 of tLine
break
case "teardown"
processTestTeardownLine tOutput, pModule, pTest, tLineIndex, word 2 to -1 of tLine
put "end runTest_" & pIndex & return & return after tOutput
add 1 to pIndex
break
case "test"
processTestTestLine tOutput, pModule, pTest, tLineIndex, word 2 to -1 of tLine
break
case "test-error"
processTestTestErrorLine tOutput, pModule, pTest, tLineIndex, word 2 to -1 of tLine
break
case "test-no-error"
processTestTestNoErrorLine tOutput, pModule, pTest, tLineIndex, word 2 to -1 of tLine
break
default
put "/*"&tLineIndex&"*/" && tLine & return after tOutput
break
end switch
add 1 to tLineIndex
end repeat
set the script of button "Test Compile" to tOutput
if the result is not empty then
put the result
log pModule & "." & pTest & ", line " & char 3 to -3 of word 1 of line (item 2 of the result) of tOutput & ":" && "compile error"
return empty
end if
return tOutput
end processTest
command processTestSetupLine @xOutput, pModule, pTest, pLineIndex, pLine
put "local ___temp___, ___error___" & return after xOutput
if pLine is empty then
get "functionality"
else
get char 2 to -2 of pLine
end if
put "log" && quote & (pModule & "." & pTest) & ":" && it & quote & return after xOutput
end processTestSetupLine
command processTestTeardownLine @xOutput, pModule, pTest, pLineIndex, pLine
end processTestTeardownLine
command processTestTestLine @xOutput, pModule, pTest, pLineIndex, pLine
put "/*"&pLineIndex&"*/ if not (" & pLine & ") then log" && quote & " failure - line" && pLineIndex & quote & ";else;end if;" & return after xOutput
end processTestTestLine
command processTestTestErrorLine @xOutput, pModule, pTest, pLineIndex, pLine
put "put empty into ___error___" & return after xOutput
put "try" & return after xOutput
put "/*"&pLineIndex&"*/ put (" & pLine & ") into ___temp___" & return after xOutput
put "catch ___error___" & return after xOutput
put "end try" & return after xOutput
put "if __error__ is empty then log" && quote & " failure - line" && pLineIndex & quote & ";else;end if;" & return after xOutput
end processTestTestErrorLine
command processTestTestNoErrorLine @xOutput, pModule, pTest, pLineIndex, pLine
put "put empty into ___error___" & return after xOutput
put "try" & return after xOutput
put "/*"&pLineIndex&"*/ put (" & pLine & ") into ___temp___" & return after xOutput
put "catch ___error___" & return after xOutput
put "end try" & return after xOutput
put "if ___error___ is not empty then log" && quote & " failure - line" && pLineIndex & quote & ";else;end if;" & return after xOutput
end processTestTestNoErrorLine
----------------------------------------------------------------------------------------
command log pMessage
put pMessage & return after field "Log"
end log
----------------------------------------------------------------------------------------
function listModules
return listFolders(testsPath())
end listModules
function listTestsForModule pModule
return listFiles(testsPath() & slash & pModule)
end listTestsForModule
function testsPath
set the itemDelimiter to slash
return item 1 to -2 of the filename of this stack
end testsPath
----------------------------------------------------------------------------------------
function listFiles pFolder
local tOldFolder
put the folder into tOldFolder
set the folder to pFolder
get the files
set the folder to tOldFolder
return it
end listFiles
function listFolders pFolder
local tOldFolder
put the folder into tOldFolder
set the folder to pFolder
get the folders
filter it without ".*"
set the folder to tOldFolder
return it
end listFolders
----------------------------------------------------------------------------------------
€ ‡Š cREVGeneral scripteditorvscroll 1690scripteditorselection 7390 cREVGeometryCacheIDs 1337778958150 10061343307582076 10131337781157440 10091337778944808 10041337787028791 1011 cREVGeometrycache order
total 5 ì î ñ ó õ ì Test àE‹p ,on mouseUp
runTests "debug"
end mouseUp
€ R 2 cREVGeneral revUniqueID
1337778944808scripteditorvscroll 0scripteditorselection 22
î Log ƒ)` € ˆn ¶ cREVGeneral scripteditorvscroll 0revUniqueID
1337778958150scripteditorselection 0 ê ï ` @ { l ´ ñ Template àE‹p;on startup
create stack "Test"
insert script of me into back
--insert the script of button "revLibURL" of me into back
send "postStartup" to me in 0 millisecs
end startup
on postStartup
try
dispatch "runTest_" & $1 to stack "Test"
catch tError
repeat for each line tLine in tError
log " failure - " & tLine
end repeat
end try
delete stack "Test"
quit 0
end postStartup
command log pMessage
write pMessage & return to stdout
end log
command use pLib
insert the script of button pLib of me into back
end use
€ 8 R 6 cREVGeneral revUniqueID
1337781157440scripteditorvscroll 0scripteditorselection 311 ó
Test Compile àE‹p«command runTest_12
local ___temp___, ___error___
log "network.ExecUnloadUrl.test: functionality"
/*2*/
/*3*/ load URL "http://www.google.com/"
/*4*/
/*5*/ ---wait until the cachedUrls contains "http://www.google.com/" with messages
/*6*/
/*7*/ unload URL "http://www.google.com/"
/*8*/
/*9*/ if not (not (the cachedURLs contains "http://www.google.com")) then log " failure - line 9";else;end if;
/*10*/
end runTest_12
€ â R 4 cREVGeneral revUniqueID
1337787028791scripteditorvscroll 0scripteditorselection 439 õ Modules Àåe € Z „ 2 <all> ’<all>
arrays
datetime
engine
files
filters
graphics
ide
interface
legacy
logic
math
multimedia
network
pasteboard
scripting
security
strings
text cREVGeneral revUniqueID
1343307582076scripteditorvscroll 0scripteditorselection 0