1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
--
-- tests/test_project.lua
-- Automated test suite for the project support functions.
-- Copyright (c) 2008-2010 Jason Perkins and the Premake project
--
local _project = premake.project
T.project = { }
local cfg, result
function T.project.setup()
_ACTION = "gmake"
cfg = {}
cfg.project = {}
cfg.language = "C++"
cfg.files = {}
cfg.trimpaths = {}
cfg.platform = "Native"
result = "\n"
end
--
-- findproject() tests
--
function T.project.findproject_IsCaseSensitive()
local sln = test.createsolution()
local prj = test.createproject(sln)
premake.bake.buildconfigs()
test.isnil(premake.findproject("myproject"))
end
--
-- getfilename() tests
--
function T.project.getfilename_ReturnsRelativePath()
local prj = { name = "project", location = "location" }
local r = _project.getfilename(prj, path.join(os.getcwd(), "../filename"))
test.isequal("../filename", r)
end
function T.project.getfilename_PerformsSubstitutions()
local prj = { name = "project", location = "location" }
local r = _project.getfilename(prj, "%%.prj")
test.isequal("location/project.prj", r)
end
--
-- premake.getlinks() tests
--
function T.project.getlinks_OnMscSystemLibs()
_OPTIONS.cc = "msc"
cfg.links = { "user32", "gdi32" }
result = premake.getlinks(cfg, "all", "fullpath")
test.isequal("user32.lib gdi32.lib", table.concat(result, " "))
end
--
-- premake.walksources() tests
--
local function walktest(prj, fname, state, nestlevel)
local item
if (state == "GroupStart") then
item = "<" .. fname .. ">"
elseif (state == "GroupEnd") then
item = "</" .. fname .. ">"
else
item = fname
end
result = result .. string.rep("-", nestlevel) .. item .. "\n"
end
function T.project.walksources_OnNoFiles()
premake.walksources(cfg, walktest)
test.isequal("\n"
.. ""
,result)
end
function T.project.walksources_OnSingleFile()
cfg.files = {
"hello.cpp"
}
premake.walksources(cfg, walktest)
test.isequal("\n"
.. "hello.cpp\n"
,result)
end
function T.project.walksources_OnNestedGroups()
cfg.files = {
"rootfile.c",
"level1/level1.c",
"level1/level2/level2.c"
}
premake.walksources(cfg, walktest)
test.isequal("\n"
.. "<level1>\n"
.. "-<level1/level2>\n"
.. "--level1/level2/level2.c\n"
.. "-</level1/level2>\n"
.. "-level1/level1.c\n"
.. "</level1>\n"
.. "rootfile.c\n"
,result)
end
function T.project.walksources_OnDottedFolders()
cfg.files = {
"src/lua-5.1.2/lapi.c"
}
premake.walksources(cfg, walktest)
test.isequal("\n"
.. "<src>\n"
.. "-<src/lua-5.1.2>\n"
.. "--src/lua-5.1.2/lapi.c\n"
.. "-</src/lua-5.1.2>\n"
.. "</src>\n"
,result)
end
function T.project.walksources_OnDotDotLeaders()
cfg.files = {
"../src/hello.c",
}
premake.walksources(cfg, walktest)
test.isequal("\n"
.. "<../src>\n"
.. "-../src/hello.c\n"
.. "</../src>\n"
,result)
end
|