forked from livecode/livecode
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_lcruntests.livecodescript
More file actions
135 lines (109 loc) · 3.73 KB
/
_lcruntests.livecodescript
File metadata and controls
135 lines (109 loc) · 3.73 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
script "LcRunTestRunner"
/*
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/>. */
/*
These tests check basic lc-run command-line functionality. The LCB
test suite, which runs in lc-run, is an in-depth test of most of
lc-run's capabilities, but doesn't exercise all of the ways that
lc-run can be invoked.
Only add tests here that can't be written as an LCB test.
*/
on startup
try
LcRunTestMain
catch tError
write "ERROR: " & tError & return to stderr
quit 1
end try
quit 0
end startup
on LcRunTestMain
loadLibrary
-- Sanity check
if $LC_RUN is empty then
throw "LC_RUN environment variable must be set"
end if
if $LCM_DIR is empty then
throw "LCM_DIR environment variable must be set"
end if
if not (buildAssembly("_libs.lca", "_lib1.lcm,_lib2.lcm") and \
buildAssembly("_all.lca", "_main.lcm,_libs.lca")) then
throw "Failed to construct bytecode assemblies"
end if
local tSuccess
put true into tSuccess
-- Test basic functionality
put tSuccess and \
doRunTest("basic", "_lib1.lcm,_lib2.lcm", "_main.lcm", "12") into tSuccess
-- Test lib assembly
put tSuccess and \
doRunTest("libraries assembly", "_libs.lca", "_main.lcm", "12") into tSuccess
-- Test full assembly
put tSuccess and \
doRunTest("full assembly", empty, "_all.lca", "12") into tSuccess
if tSuccess then
quit 0
else
quit 1
end if
end LcRunTestMain
-- Construct a bytecode assembly by concatenating a bunch of LCB
-- module files
private function buildAssembly pAssembly, pInputs
local tAssemblyData, tInput
repeat for each item tInput in pInputs
put url ("binfile:" & getBuildPath(tInput)) after tAssemblyData
end repeat
put tAssemblyData into url ("binfile:" & getBuildPath(pAssembly))
return true
end buildAssembly
private function doRunTest pName, pLibs, pMain, pExpectedOutput
local tCommand, tLib
put $LC_RUN into tCommand
if pLibs is not empty then
repeat for each item tLib in pLibs
put getBuildPath(tLib) into tLib
put merge(" -l [[tLib]]") after tCommand
end repeat
end if
put " " & getBuildPath(pMain) after tCommand
local tOutput, tExitStatus
put shell(tCommand) into tOutput
put the result into tExitStatus
if tExitStatus is not 0 then
write tOutput & return to stdout
TesterLog "fail", merge("[[pName]] (exited: [[tExitStatus]])")
return false
else if tOutput is not pExpectedOutput then
write tOutput & return to stdout
TesterLog "fail", merge("[[pName]] (incorrect output)")
return false
else
TesterLog "pass", pName
return true
end if
end doRunTest
private function getBuildPath pBaseName
return $LCM_DIR & "/" & pBaseName
end getBuildPath
on loadLibrary
-- Find tester library filename...
local tTesterLibFile
set the itemDelimiter to "/"
put the filename of me into tTesterLibFile
put "_testerlib.livecodescript" into item -1 of tTesterLibFile
-- ...and load the stack
local tStackName
put the name of stack tTesterLibFile into tStackName
send "revLoadLibrary" to stack tStackName
end loadLibrary