2012-10-24 19:40:25 +00:00
|
|
|
--
|
|
|
|
-- tests/project/test_filename.lua
|
|
|
|
-- Verify generation of project (and solution) filenames.
|
|
|
|
-- Copyright (c) 2008-2012 Jason Perkins and the Premake project
|
|
|
|
--
|
|
|
|
|
|
|
|
T.project_filename = {}
|
|
|
|
local suite = T.project_filename
|
|
|
|
|
|
|
|
local project = premake5.project
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Setup
|
|
|
|
--
|
|
|
|
|
|
|
|
local sln
|
2012-12-31 18:45:22 +00:00
|
|
|
|
2012-10-24 19:40:25 +00:00
|
|
|
function suite.setup()
|
|
|
|
sln, prj = test.createsolution()
|
|
|
|
end
|
2012-12-31 18:45:22 +00:00
|
|
|
|
2012-10-24 19:40:25 +00:00
|
|
|
local function prepare()
|
|
|
|
prj = premake.solution.getproject_ng(sln, 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Should return name as an absolute path.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.isAbsolutePath()
|
|
|
|
prepare()
|
|
|
|
test.isequal(os.getcwd(), path.getdirectory(project.getfilename(prj)))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Should use the project name, if no filename was specified.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.isProjectName_onNoFilename()
|
|
|
|
prepare()
|
|
|
|
test.isequal("MyProject", path.getname(project.getfilename(prj)))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Should use filename, if set via API.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.doesUseFilename()
|
|
|
|
filename "Howdy"
|
|
|
|
prepare()
|
|
|
|
test.isequal("Howdy", path.getname(project.getfilename(prj)))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Appends file extension, if supplied.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.doesUseExtension()
|
|
|
|
prepare()
|
|
|
|
test.isequal(".xc", path.getextension(project.getfilename(prj, ".xc")))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Should also work with solutions.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.worksWithSolution()
|
|
|
|
prepare()
|
|
|
|
test.isequal("MySolution", path.getname(project.getfilename(sln)))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
-- Value should not propagate down to projects.
|
|
|
|
--
|
|
|
|
|
|
|
|
function suite.doesNotPropagate()
|
|
|
|
solution ("MySolution")
|
|
|
|
filename ("Howdy")
|
|
|
|
prepare()
|
|
|
|
test.isequal("MyProject", path.getname(project.getfilename(prj)))
|
|
|
|
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()
|
|
|
|
test.isequal("Makefile", path.getname(project.getfilename(prj, "Makefile")))
|
|
|
|
end
|
|
|
|
|