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
|
|
|
--
|
|
|
|
|
|
|
|
|
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")
|
2014-02-08 15:44:57 +00:00
|
|
|
test.isequal("ok", premake.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")
|
2014-02-08 15:44:57 +00:00
|
|
|
test.isequal("ok", premake.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")
|
2014-02-08 15:44:57 +00:00
|
|
|
test.isequal("ok", premake.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")
|
2014-02-08 15:44:57 +00:00
|
|
|
test.isequal("ok", premake.captured())
|
2013-03-12 22:18:47 +00:00
|
|
|
end
|