Skip to content

Commit 43c27d4

Browse files
committed
[[ Benchmarks ]] Ensure _benchrunner works in 6.7.
The benchrunner uses syntax which is not available in 6.7, so the places that it does so have been changed, or made conditional on engine version (using 'do' as appropriate).
1 parent 3e56ef1 commit 43c27d4

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

benchmarks/_benchmarkrunner.livecodescript

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,27 @@ end startup
3434

3535
private function getCommandLineInfo
3636
local tRawArg, tSelfCommand, tSelfScript, tInArgs, tArgs
37-
37+
3838
put false into tInArgs
39-
39+
4040
-- Treat everything up to & including the first
4141
-- ".livecodescript" file as the command for running the test
4242
-- runner, and everything after it as test runner arguments
43-
put the commandName into tSelfCommand[1]
44-
repeat for each element tRawArg in the commandArguments
45-
43+
local tCommandArguments
44+
if the version contains "6.7" then
45+
put $0 into tSelfCommand[1]
46+
if the environment is "command line" then
47+
put "-ui" into tCommandArguments[1]
48+
end if
49+
repeat with i = 1 to $#
50+
put value("$" & i) into tCommandArguments[the number of elements in tCommandArguments + 1]
51+
end repeat
52+
else
53+
do "put the commandName into tSelfCommand[1]"
54+
do "put the commandArguments into tCommandArguments"
55+
end if
56+
repeat for each element tRawArg in tCommandArguments
57+
4658
if tInArgs then
4759
put tRawArg into tArgs[1 + the number of elements in tArgs]
4860
else
@@ -52,14 +64,14 @@ private function getCommandLineInfo
5264
put true into tInArgs
5365
end if
5466
end if
55-
67+
5668
end repeat
57-
69+
5870
local tInfo
5971
put tSelfCommand into tInfo["self-command"]
6072
put tSelfScript into tInfo["self-script"]
6173
put tArgs into tInfo["args"]
62-
74+
6375
return tInfo
6476
end getCommandLineInfo
6577

@@ -289,15 +301,7 @@ private function runGetBenchmarkCommandNames pFilename
289301
local tScript
290302

291303
-- Get the contents of the file
292-
open file pFilename for "UTF-8" text read
293-
if the result is not empty then
294-
throw the result
295-
end if
296-
297-
read from file pFilename until end
298-
put it into tScript
299-
300-
close file pFilename
304+
put url ("file:" & pFilename) into tScript
301305

302306
-- Scan the file for "on Benchmark*" definitions
303307
local tCommandNames, tCount, tLine, tName

0 commit comments

Comments
 (0)