1-- 2-- tests/base/test_filename.lua 3-- Verify generation of project/workspace/rule filenames. 4-- Copyright (c) 2008-2014 Jason Perkins and the Premake project 5-- 6 7 local suite = test.declare("project_filename") 8 9 local p = premake 10 11 12 13-- 14-- Setup 15-- 16 17 local wks 18 19 function suite.setup() 20 wks = test.createWorkspace() 21 end 22 23 local function prepare() 24 prj = test.getproject(wks, 1) 25 end 26 27 28-- 29-- Should return name as an absolute path. 30-- 31 32 function suite.isAbsolutePath() 33 prepare() 34 test.isequal(os.getcwd(), path.getdirectory(p.filename(prj))) 35 end 36 37 38-- 39-- Should use the project name, if no filename was specified. 40-- 41 42 function suite.isProjectName_onNoFilename() 43 prepare() 44 test.isequal("MyProject", path.getname(p.filename(prj))) 45 end 46 47 48-- 49-- Should use filename, if set via API. 50-- 51 52 function suite.doesUseFilename() 53 filename "Howdy" 54 prepare() 55 test.isequal("Howdy", path.getname(p.filename(prj))) 56 end 57 58 59-- 60-- Appends file extension, if supplied. 61-- 62 63 function suite.doesUseExtension() 64 prepare() 65 test.isequal(".xc", path.getextension(p.filename(prj, ".xc"))) 66 end 67 68 69-- 70-- Should also work with workspaces. 71-- 72 73 function suite.worksWithWorkspace() 74 prepare() 75 test.isequal("MyWorkspace", path.getname(p.filename(wks))) 76 end 77 78 79-- 80-- Value should not propagate down to projects. 81-- 82 83 function suite.doesNotPropagate() 84 workspace ("MyWorkspace") 85 filename ("Howdy") 86 prepare() 87 test.isequal("MyProject", path.getname(p.filename(prj))) 88 end 89 90 91-- 92-- If extension is provided without a leading dot, it should override any 93-- project filename. 94-- 95 96 function suite.canOverrideFilename() 97 prepare() 98 test.isequal("Makefile", path.getname(p.filename(prj, "Makefile"))) 99 end 100