2012-10-24 19:40:25 +00:00
|
|
|
--
|
2014-08-11 21:28:51 +00:00
|
|
|
-- tests/base/test_filename.lua
|
|
|
|
-- Verify generation of project/solution/rule filenames.
|
|
|
|
-- Copyright (c) 2008-2014 Jason Perkins and the Premake project
|
2012-10-24 19:40:25 +00:00
|
|
|
--
|
|
|
|
|
2014-08-11 21:28:51 +00:00
|
|
|
local suite = test.declare("project_filename")
|
|
|
|
|
|
|
|
local p = premake
|
2012-10-24 19:40:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup
|
|
|
|
--
|
|
|
|
|
2015-08-28 20:16:14 +00:00
|
|
|
local wks
|
2012-12-31 18:45:22 +00:00
|
|
|
|
2012-10-24 19:40:25 +00:00
|
|
|
function suite.setup()
|
2015-08-28 20:16:14 +00:00
|
|
|
wks = test.createWorkspace()
|
2012-10-24 19:40:25 +00:00
|
|
|
end
|
2012-12-31 18:45:22 +00:00
|
|
|
|
2012-10-24 19:40:25 +00:00
|
|
|
local function prepare()
|
2015-08-28 20:16:14 +00:00
|
|
|
prj = test.getproject(wks, 1)
|
2012-10-24 19:40:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Should return name as an absolute path.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.isAbsolutePath()
|
|
|
|
prepare()
|
2014-08-11 21:28:51 +00:00
|
|
|
test.isequal(os.getcwd(), path.getdirectory(p.filename(prj)))
|
2012-10-24 19:40:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Should use the project name, if no filename was specified.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.isProjectName_onNoFilename()
|
|
|
|
prepare()
|
2014-08-11 21:28:51 +00:00
|
|
|
test.isequal("MyProject", path.getname(p.filename(prj)))
|
2012-10-24 19:40:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Should use filename, if set via API.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.doesUseFilename()
|
|
|
|
filename "Howdy"
|
|
|
|
prepare()
|
2014-08-11 21:28:51 +00:00
|
|
|
test.isequal("Howdy", path.getname(p.filename(prj)))
|
2012-10-24 19:40:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Appends file extension, if supplied.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.doesUseExtension()
|
|
|
|
prepare()
|
2014-08-11 21:28:51 +00:00
|
|
|
test.isequal(".xc", path.getextension(p.filename(prj, ".xc")))
|
2012-10-24 19:40:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Should also work with solutions.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.worksWithSolution()
|
|
|
|
prepare()
|
2015-08-28 20:16:14 +00:00
|
|
|
test.isequal("MySolution", path.getname(p.filename(wks)))
|
2012-10-24 19:40:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Value should not propagate down to projects.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.doesNotPropagate()
|
|
|
|
solution ("MySolution")
|
|
|
|
filename ("Howdy")
|
|
|
|
prepare()
|
2014-08-11 21:28:51 +00:00
|
|
|
test.isequal("MyProject", path.getname(p.filename(prj)))
|
2012-10-24 19:40:25 +00:00
|
|
|
end
|
|
|
|
|
2012-12-31 18:45:22 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
-- If extension is provided without a leading dot, it should override any
|
|
|
|
-- project filename.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.canOverrideFilename()
|
|
|
|
prepare()
|
2014-08-11 21:28:51 +00:00
|
|
|
test.isequal("Makefile", path.getname(p.filename(prj, "Makefile")))
|
2012-12-31 18:45:22 +00:00
|
|
|
end
|