Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions modules/gmake/tests/cpp/test_make_pch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

local wks, prj
function suite.setup()
os.chdir(_TESTS_DIR)
wks, prj = test.createWorkspace()
end

Expand Down Expand Up @@ -71,15 +70,32 @@


--
-- The PCH can be specified relative the an includes search path.
-- The PCH can be specified relative to the includes search path.
--

function suite.pch_searchesIncludeDirs()
function suite.searchesIncludeDirs()
pchheader "premake.h"
includedirs { "../../../src/host" }
includedirs { "src/host" }
prepareVars()
test.capture [[
PCH = ../../../src/host/premake.h
PCH = src/host/premake.h
]]
end


--
-- The PCH can be specified relative to the includes search path.
-- Due to the location being different from _MAIN_SCRIPT_DIR,
-- the specified PCH path should be relative to the location.


function suite.searchesIncludeDirs_location()
location "MyProject"
pchheader "premake.h"
includedirs { "src/host" }
prepareVars()
test.capture [[
PCH = ../src/host/premake.h
]]
end

Expand Down Expand Up @@ -123,20 +139,3 @@ $(OBJECTS): | $(OBJDIR)
endif
]]
end



--
-- If the header is located on one of the include file
-- search directories, it should get found automatically.
--

function suite.findsPCH_onIncludeDirs()
location "MyProject"
pchheader "premake.h"
includedirs { "../../../src/host" }
prepareVars()
test.capture [[
PCH = ../../../../src/host/premake.h
]]
end
41 changes: 19 additions & 22 deletions modules/gmake2/tests/test_gmake2_pch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

local wks, prj
function suite.setup()
os.chdir(_TESTS_DIR)
gmake2.cpp.initialize()
wks, prj = test.createWorkspace()
end
Expand Down Expand Up @@ -95,15 +94,30 @@ GCH = $(PCH_PLACEHOLDER).gch


--
-- The PCH can be specified relative the an includes search path.
-- The PCH can be specified relative to the includes search path.
--

function suite.pch_searchesIncludeDirs()
function suite.searchesIncludeDirs()
pchheader "premake.h"
includedirs { "../../../src/host" }
includedirs { "src/host" }
prepareVars()
test.capture [[
PCH = ../../../src/host/premake.h
PCH = src/host/premake.h
]]
end

--
-- The PCH can be specified relative to the includes search path.
-- Due to the location being different from _MAIN_SCRIPT_DIR,
-- the specified PCH path should be relative to the location.

function suite.searchesIncludeDirs_location()
location "MyProject"
pchheader "premake.h"
includedirs { "src/host" }
prepareVars()
test.capture [[
PCH = ../src/host/premake.h
]]
end

Expand Down Expand Up @@ -160,23 +174,6 @@ endif
]]
end



--
-- If the header is located on one of the include file
-- search directories, it should get found automatically.
--

function suite.findsPCH_onIncludeDirs()
location "MyProject"
pchheader "premake.h"
includedirs { "../../../src/host" }
prepareVars()
test.capture [[
PCH = ../../../../src/host/premake.h
]]
end

--
-- If the header is located on one of the include file
-- search directories, it should get found automatically.
Expand Down
6 changes: 4 additions & 2 deletions modules/self-test/test_runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@

function _.runTest(test)
_.log(term.lightGreen, "[ RUN ]", string.format(" %s.%s", test.suiteName, test.testName))

-- Provide a consistent working directory to the tests.
os.chdir(_MAIN_SCRIPT_DIR)

local startTime = os.clock()
local cwd = os.getcwd()
local hooks = _.installTestingHooks()

_TESTS_DIR = test.suite._TESTS_DIR
Expand All @@ -105,7 +108,6 @@
err = err or terr

_.removeTestingHooks(hooks)
os.chdir(cwd)

if ok then
_.log(term.lightGreen, "[ OK ]", string.format(" %s.%s (%.0f ms)", test.suiteName, test.testName, (os.clock() - startTime) * 1000))
Expand Down
8 changes: 2 additions & 6 deletions tests/project/test_sources.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,11 @@

local wks, prj

local cwd = os.getcwd()
local oldcwd

function suite.setup()
wks, prj = test.createWorkspace()

-- We change the directory to get nice relative paths
oldcwd = os.getcwd()
os.chdir(cwd)
os.chdir(_SCRIPT_DIR)

-- Create a token to be used in search paths
p.api.register { name = "mytoken", kind = "string", scope = "config" }
Expand All @@ -32,13 +28,13 @@

function suite.teardown()
mytoken = nil
os.chdir(oldcwd)
end

local function run()
local cfg = test.getconfig(prj, "Debug")

local files = {}
local cwd = os.getcwd()
for _, file in ipairs(cfg.files) do
table.insert(files, path.getrelative(cwd, file))
end
Expand Down
1 change: 1 addition & 0 deletions tests/test_premake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

local wks, prj
function suite.setup()
os.chdir(_TESTS_DIR)
wks = test.createWorkspace()
location "MyLocation"
prj = p.workspace.getproject(wks, 1)
Expand Down