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

Commit 4c3a4d7

Browse files
committed
[[ Tests ]] Add helper function for getting built module file
Also correct spelling of TestLoadAuxiliaryExtension, and add resource path parameter to it.
1 parent c40e63d commit 4c3a4d7

File tree

3 files changed

+44
-25
lines changed

3 files changed

+44
-25
lines changed

tests/_testlib.livecodescript

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,13 @@ on TestLoadExternal pExternal
394394
end TestLoadExternal
395395

396396
private function __GetCaller
397-
get item 1 to -3 of line -3 of the executionContexts
397+
local tLineNum
398+
put -1 into tLineNum
399+
repeat while item 1 of line tLineNum of the executionContexts \
400+
is the long id of this me
401+
subtract 1 from tLineNum
402+
end repeat
403+
get item 1 to -3 of line tLineNum of the executionContexts
398404
if there is not an it then
399405
delete item -1 of it
400406
end if
@@ -409,23 +415,38 @@ end __StackOfObject
409415

410416
-- This loads an extension whose lcb source sits in the same folder as the
411417
-- current test.
412-
on TestLoadAuxillaryExtension pName
413-
local tBasePath, tExtraPath
414-
set the itemDelimiter to slash
415-
put item 1 to -2 of the effective filename of __StackOfObject(__GetCaller()) into tBasePath
416-
repeat while the last item of tBasePath is not "tests"
417-
put item -1 of tBasePath & slash before tExtraPath
418-
delete the last item of tBasePath
419-
end repeat
420-
421-
local tModuleFile
422-
put tBasePath & "/../_tests/_build/" & tExtraPath & pName & ".lcm" into tModuleFile
423-
424-
load extension from data url ("binfile:" & tModuleFile)
425-
if the result is not empty then
426-
throw "Failed to load auxillary extension:" && the result && tModuleFile
427-
end if
428-
end TestLoadAuxillaryExtension
418+
on TestLoadAuxiliaryExtension pName, pResourceFolder
419+
local tBytecodeFile
420+
put TestGetBuiltBytecodeFile(pName) into tBytecodeFile
421+
if pResourceFolder is empty then
422+
load extension from data url ("binfile:" & tBytecodeFile)
423+
else
424+
load extension from data url ("binfile:" & tBytecodeFile) \
425+
with resource path pResourceFolder
426+
end if
427+
428+
if the result is not empty then
429+
throw "Failed to load auxiliary extension:" && \
430+
the result && tBytecodeFile
431+
end if
432+
end TestLoadAuxiliaryExtension
433+
434+
constant kBytecodePathPrefix = "_tests/_build/"
435+
function TestGetBuiltBytecodeFile pName
436+
local tBasePath, tExtraPath
437+
set the itemDelimiter to slash
438+
put item 1 to -2 of the effective filename of \
439+
__StackOfObject(__GetCaller()) into tBasePath
440+
repeat while the last item of tBasePath is not "tests"
441+
put item -1 of tBasePath & slash before tExtraPath
442+
delete the last item of tBasePath
443+
end repeat
444+
445+
local tModuleFile
446+
put tBasePath & "/../" & kBytecodePathPrefix & tExtraPath & pName \
447+
& ".lcm" into tModuleFile
448+
return tModuleFile
449+
end TestGetBuiltBytecodeFile
429450

430451
on TestLoadAllExtensions
431452
local tExtFolder

tests/lcs/core/engine/extension.livecodescript

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ for more details.
1616
You should have received a copy of the GNU General Public License
1717
along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
1818

19-
constant kBytecodePath = "../_tests/_build/lcs/core/engine"
20-
2119
local sTestExtension
2220

2321
on TestSetup
@@ -42,7 +40,7 @@ private command buildMultiModuleExtension pInputs, pOutput
4240
-- Build a multi-module extension
4341
local tBasename, tBytecode, tFile, tResult
4442
repeat for each item tBasename in pInputs
45-
put merge("[[kBytecodePath]]/[[tBasename]].lcm") into tFile
43+
put TestGetBuiltBytecodeFile(tBasename) into tFile
4644
put url("binfile:" & tFile) after tBytecode
4745
put the result into tResult
4846
if tResult is not empty then

tests/lcs/core/engine/widget.livecodescript

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ along with LiveCode. If not see <http://www.gnu.org/licenses/>. */
2121
on TestSetup
2222
TestSkipIfNot "lcb"
2323

24-
TestLoadAuxillaryExtension "_widget"
25-
TestLoadAuxillaryExtension "_widget_support"
26-
TestLoadAuxillaryExtension "_widgetthrow"
24+
TestLoadAuxiliaryExtension "_widget"
25+
TestLoadAuxiliaryExtension "_widget_support"
26+
TestLoadAuxiliaryExtension "_widgetthrow"
2727
end TestSetup
2828

2929
//////////
@@ -104,7 +104,7 @@ on TestWidgetRetainRep
104104
save stack "WidgetRetainRepTest" as tPath
105105
delete stack "WidgetRetainRepTest"
106106

107-
TestLoadAuxillaryExtension "_widget_save"
107+
TestLoadAuxiliaryExtension "_widget_save"
108108

109109
go stack tPath
110110

0 commit comments

Comments
 (0)