2011-12-04 19:47:59 +00:00
|
|
|
--
|
|
|
|
-- tests/base/test_include.lua
|
|
|
|
-- Test the include() function, for including external scripts
|
2014-09-17 23:19:47 +00:00
|
|
|
-- Copyright (c) 2011-2014 Jason Perkins and the Premake project
|
2011-12-04 19:47:59 +00:00
|
|
|
--
|
|
|
|
|
|
|
|
|
2017-04-25 05:44:13 +00:00
|
|
|
local p = premake
|
2013-03-12 22:18:47 +00:00
|
|
|
local suite = test.declare("include")
|
|
|
|
|
2011-12-04 19:47:59 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup and teardown
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.teardown()
|
|
|
|
-- clear the list of included files after each run
|
|
|
|
io._includedFiles = { }
|
|
|
|
end
|
2013-03-12 22:18:47 +00:00
|
|
|
|
|
|
|
|
2011-12-04 19:47:59 +00:00
|
|
|
--
|
|
|
|
-- Tests
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.include_findsPremakeFile_onFolderNameOnly()
|
2014-09-17 23:19:47 +00:00
|
|
|
include (_TESTS_DIR .. "/folder")
|
2017-04-25 05:44:13 +00:00
|
|
|
test.isequal("ok", p.captured())
|
2011-12-04 19:47:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function suite.include_onExactFilename()
|
2014-09-17 23:19:47 +00:00
|
|
|
include (_TESTS_DIR .. "/folder/premake5.lua")
|
2017-04-25 05:44:13 +00:00
|
|
|
test.isequal("ok", p.captured())
|
2011-12-04 19:47:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function suite.include_runsOnlyOnce_onMultipleIncludes()
|
2014-09-17 23:19:47 +00:00
|
|
|
include (_TESTS_DIR .. "/folder/premake5.lua")
|
|
|
|
include (_TESTS_DIR .. "/folder/premake5.lua")
|
2017-04-25 05:44:13 +00:00
|
|
|
test.isequal("ok", p.captured())
|
2011-12-04 19:47:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function suite.include_runsOnlyOnce_onMultipleIncludesWithDifferentPaths()
|
2014-09-17 23:19:47 +00:00
|
|
|
include (_TESTS_DIR .. "/folder/premake5.lua")
|
|
|
|
include (_TESTS_DIR .. "/../tests/folder/premake5.lua")
|
2017-04-25 05:44:13 +00:00
|
|
|
test.isequal("ok", p.captured())
|
2013-03-12 22:18:47 +00:00
|
|
|
end
|
2015-08-25 13:57:05 +00:00
|
|
|
|
|
|
|
function suite.includeexternal_runs()
|
|
|
|
includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
|
2017-04-25 05:44:13 +00:00
|
|
|
test.isequal("ok", p.captured())
|
2015-08-25 13:57:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.includeexternal_runsAfterInclude()
|
|
|
|
include (_TESTS_DIR .. "/folder/premake5.lua")
|
|
|
|
includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
|
2017-04-25 05:44:13 +00:00
|
|
|
test.isequal("okok", p.captured())
|
2015-08-25 13:57:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function suite.includeexternal_runsTwiceAfterInclude()
|
|
|
|
include (_TESTS_DIR .. "/folder/premake5.lua")
|
|
|
|
includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
|
|
|
|
includeexternal (_TESTS_DIR .. "/folder/premake5.lua")
|
2017-04-25 05:44:13 +00:00
|
|
|
test.isequal("okokok", p.captured())
|
2015-08-25 13:57:05 +00:00
|
|
|
end
|