Initial community commit
This commit is contained in:
8
Src/external_dependencies/openmpt-trunk/include/premake/modules/codelite/tests/_tests.lua
vendored
Normal file
8
Src/external_dependencies/openmpt-trunk/include/premake/modules/codelite/tests/_tests.lua
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
require ("codelite")
|
||||
|
||||
return {
|
||||
"test_codelite_workspace.lua",
|
||||
"test_codelite_project.lua",
|
||||
"test_codelite_config.lua",
|
||||
"test_codelite_additional_rules.lua",
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
---
|
||||
-- codelite/tests/test_codelite_config.lua
|
||||
-- Automated test suite for CodeLite project generation.
|
||||
-- Copyright (c) 2021 Joris Dauphin and the Premake project
|
||||
---
|
||||
|
||||
local suite = test.declare("codelite_cproj_additional_rules")
|
||||
local p = premake
|
||||
local codelite = p.modules.codelite
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Setup/Teardown
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
local wks, prj, cfg
|
||||
|
||||
local function prepare_rule()
|
||||
rule "TestRule"
|
||||
display "Test Rule"
|
||||
fileextension ".rule"
|
||||
|
||||
propertydefinition {
|
||||
name = "TestProperty",
|
||||
kind = "boolean",
|
||||
value = false,
|
||||
switch = "-p"
|
||||
}
|
||||
|
||||
propertydefinition {
|
||||
name = "TestProperty2",
|
||||
kind = "boolean",
|
||||
value = false,
|
||||
switch = "-p2"
|
||||
}
|
||||
|
||||
propertydefinition {
|
||||
name = "TestListProperty",
|
||||
kind = "list"
|
||||
}
|
||||
propertydefinition {
|
||||
name = "TestListPropertyWithSwitch",
|
||||
kind = "list",
|
||||
switch = "-S"
|
||||
}
|
||||
propertydefinition {
|
||||
name = "TestListPropertySeparator",
|
||||
kind = "list",
|
||||
separator = ","
|
||||
}
|
||||
propertydefinition {
|
||||
name = "TestListPropertySeparatorWithSwitch",
|
||||
kind = "list",
|
||||
separator = ",",
|
||||
switch = "-O"
|
||||
}
|
||||
propertydefinition {
|
||||
name = "TestEnumProperty",
|
||||
values = { [0] = "V0", [1] = "V1"},
|
||||
switch = { [0] = "S0", [1] = "S1"},
|
||||
value = 0
|
||||
}
|
||||
|
||||
buildmessage 'Rule-ing %{file.name}'
|
||||
buildcommands 'dorule %{TestProperty} %{TestProperty2} %{TestListProperty} %{TestListPropertyWithSwitch} %{TestListPropertySeparator} %{TestListPropertySeparatorWithSwitch} %{TestEnumProperty} "%{file.path}"'
|
||||
buildoutputs { "%{file.basename}.obj" }
|
||||
end
|
||||
|
||||
function suite.setup()
|
||||
p.action.set("codelite")
|
||||
p.escaper(codelite.esc)
|
||||
p.indent(" ")
|
||||
prepare_rule()
|
||||
wks = test.createWorkspace()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
prj = test.getproject(wks, 1)
|
||||
cfg = test.getconfig(prj, "Debug")
|
||||
end
|
||||
|
||||
function suite.customRuleEmpty()
|
||||
prepare()
|
||||
codelite.project.additionalRules(prj)
|
||||
test.capture [[
|
||||
<AdditionalRules>
|
||||
<CustomPostBuild/>
|
||||
<CustomPreBuild/>
|
||||
</AdditionalRules>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.customRuleWithPropertyDefinition()
|
||||
rules { "TestRule" }
|
||||
|
||||
files { "test.rule", "test2.rule" }
|
||||
|
||||
testRuleVars {
|
||||
TestProperty = true
|
||||
}
|
||||
|
||||
filter "files:test2.rule"
|
||||
testRuleVars {
|
||||
TestProperty2 = true
|
||||
}
|
||||
|
||||
prepare()
|
||||
codelite.project.additionalRules(cfg)
|
||||
|
||||
test.capture [[
|
||||
<AdditionalRules>
|
||||
<CustomPostBuild/>
|
||||
<CustomPreBuild>test.obj test2.obj
|
||||
test.obj: test.rule
|
||||
@echo Rule-ing test.rule
|
||||
dorule -p "test.rule"
|
||||
|
||||
test2.obj: test2.rule
|
||||
@echo Rule-ing test2.rule
|
||||
dorule -p -p2 "test2.rule"
|
||||
</CustomPreBuild>
|
||||
</AdditionalRules>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.customRuleWithPropertyDefinitionSeparator()
|
||||
|
||||
rules { "TestRule" }
|
||||
|
||||
files { "test.rule", "test2.rule", "test3.rule", "test4.rule" }
|
||||
|
||||
filter "files:test.rule"
|
||||
testRuleVars {
|
||||
TestListProperty = { "testValue1", "testValue2" }
|
||||
}
|
||||
|
||||
filter "files:test2.rule"
|
||||
testRuleVars {
|
||||
TestListPropertyWithSwitch = { "testValue1", "testValue2" }
|
||||
}
|
||||
|
||||
filter "files:test3.rule"
|
||||
testRuleVars {
|
||||
TestListPropertySeparator = { "testValue1", "testValue2" }
|
||||
}
|
||||
|
||||
filter "files:test4.rule"
|
||||
testRuleVars {
|
||||
TestListPropertySeparatorWithSwitch = { "testValue1", "testValue2" }
|
||||
}
|
||||
|
||||
prepare()
|
||||
codelite.project.additionalRules(cfg)
|
||||
|
||||
test.capture [[
|
||||
<AdditionalRules>
|
||||
<CustomPostBuild/>
|
||||
<CustomPreBuild>test.obj test2.obj test3.obj test4.obj
|
||||
test.obj: test.rule
|
||||
@echo Rule-ing test.rule
|
||||
dorule testValue1 testValue2 "test.rule"
|
||||
|
||||
test2.obj: test2.rule
|
||||
@echo Rule-ing test2.rule
|
||||
dorule -StestValue1 -StestValue2 "test2.rule"
|
||||
|
||||
test3.obj: test3.rule
|
||||
@echo Rule-ing test3.rule
|
||||
dorule testValue1,testValue2 "test3.rule"
|
||||
|
||||
test4.obj: test4.rule
|
||||
@echo Rule-ing test4.rule
|
||||
dorule -OtestValue1,testValue2 "test4.rule"
|
||||
</CustomPreBuild>
|
||||
</AdditionalRules>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.customRuleWithPropertyDefinitionEnum()
|
||||
rules { "TestRule" }
|
||||
|
||||
files { "test.rule", "test2.rule" }
|
||||
|
||||
testRuleVars {
|
||||
TestEnumProperty = "V0"
|
||||
}
|
||||
|
||||
filter "files:test2.rule"
|
||||
testRuleVars {
|
||||
TestEnumProperty = "V1"
|
||||
}
|
||||
|
||||
prepare()
|
||||
codelite.project.additionalRules(cfg)
|
||||
|
||||
test.capture [[
|
||||
<AdditionalRules>
|
||||
<CustomPostBuild/>
|
||||
<CustomPreBuild>test.obj test2.obj
|
||||
test.obj: test.rule
|
||||
@echo Rule-ing test.rule
|
||||
dorule S0 "test.rule"
|
||||
|
||||
test2.obj: test2.rule
|
||||
@echo Rule-ing test2.rule
|
||||
dorule S1 "test2.rule"
|
||||
</CustomPreBuild>
|
||||
</AdditionalRules>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.buildCommand()
|
||||
files {"foo.txt", "bar.txt"}
|
||||
buildinputs { "toto.txt", "extra_dependency" }
|
||||
buildoutputs { "toto.c" }
|
||||
buildcommands { "test", "test toto.c" }
|
||||
buildmessage "Some message"
|
||||
prepare()
|
||||
codelite.project.additionalRules(cfg)
|
||||
test.capture [[
|
||||
<AdditionalRules>
|
||||
<CustomPostBuild/>
|
||||
<CustomPreBuild>toto.c
|
||||
toto.c: toto.txt extra_dependency
|
||||
@echo Some message
|
||||
test
|
||||
test toto.c
|
||||
</CustomPreBuild>
|
||||
</AdditionalRules>]]
|
||||
end
|
||||
|
||||
function suite.buildCommandPerFile()
|
||||
files {"foo.txt", "bar.txt"}
|
||||
filter "files:**.txt"
|
||||
buildinputs { "%{file.basename}.h", "extra_dependency" }
|
||||
buildoutputs { "%{file.basename}.c" }
|
||||
buildcommands { "test", "test %{file.basename}" }
|
||||
buildmessage "Some message"
|
||||
prepare()
|
||||
codelite.project.additionalRules(cfg)
|
||||
test.capture [[
|
||||
<AdditionalRules>
|
||||
<CustomPostBuild/>
|
||||
<CustomPreBuild>bar.c foo.c
|
||||
bar.c: bar.txt bar.h extra_dependency
|
||||
@echo Some message
|
||||
test
|
||||
test bar
|
||||
|
||||
foo.c: foo.txt foo.h extra_dependency
|
||||
@echo Some message
|
||||
test
|
||||
test foo
|
||||
</CustomPreBuild>
|
||||
</AdditionalRules>]]
|
||||
end
|
||||
|
||||
@@ -0,0 +1,377 @@
|
||||
---
|
||||
-- codelite/tests/test_codelite_config.lua
|
||||
-- Automated test suite for CodeLite project generation.
|
||||
-- Copyright (c) 2015 Manu Evans and the Premake project
|
||||
---
|
||||
|
||||
|
||||
local suite = test.declare("codelite_cproj_config")
|
||||
local p = premake
|
||||
local codelite = p.modules.codelite
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Setup/Teardown
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
local wks, prj, cfg
|
||||
|
||||
function suite.setup()
|
||||
p.action.set("codelite")
|
||||
p.escaper(codelite.esc)
|
||||
p.indent(" ")
|
||||
wks = test.createWorkspace()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
prj = test.getproject(wks,1)
|
||||
cfg = test.getconfig(prj, "Debug")
|
||||
end
|
||||
|
||||
|
||||
function suite.OnProjectCfg_Compiler()
|
||||
prepare()
|
||||
codelite.project.compiler(cfg)
|
||||
test.capture [[
|
||||
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
||||
</Compiler>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_Flags()
|
||||
optimize "Debug"
|
||||
exceptionhandling "Off"
|
||||
rtti "Off"
|
||||
pic "On"
|
||||
symbols "On"
|
||||
language "C++"
|
||||
cppdialect "C++11"
|
||||
flags { "NoBufferSecurityCheck" }
|
||||
forceincludes { "forced_include1.h", "forced_include2.h" }
|
||||
buildoptions { "-opt1", "-opt2" }
|
||||
prepare()
|
||||
codelite.project.compiler(cfg)
|
||||
test.capture [[
|
||||
<Compiler Options="-O0;-fPIC;-g;-std=c++11;-fno-exceptions;-fno-stack-protector;-fno-rtti;-include forced_include1.h;-include forced_include2.h;-opt1;-opt2" C_Options="-O0;-fPIC;-g;-include forced_include1.h;-include forced_include2.h;-opt1;-opt2" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
||||
</Compiler>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_Includes()
|
||||
includedirs { "dir/", "dir2" }
|
||||
prepare()
|
||||
codelite.project.compiler(cfg)
|
||||
test.capture [[
|
||||
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
||||
<IncludePath Value="dir"/>
|
||||
<IncludePath Value="dir2"/>
|
||||
</Compiler>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_SysIncludes()
|
||||
sysincludedirs { "sysdir", "sysdir2/"}
|
||||
prepare()
|
||||
codelite.project.compiler(cfg)
|
||||
test.capture [[
|
||||
<Compiler Options="-isystem sysdir;-isystem sysdir2" C_Options="-isystem sysdir;-isystem sysdir2" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
||||
</Compiler>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.OnProjectCfg_Defines()
|
||||
defines { "TEST", "DEF", "VAL=1", "ESCAPE=\"WITH SPACE\"" }
|
||||
prepare()
|
||||
codelite.project.compiler(cfg)
|
||||
test.capture [[
|
||||
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
||||
<Preprocessor Value="TEST"/>
|
||||
<Preprocessor Value="DEF"/>
|
||||
<Preprocessor Value="VAL=1"/>
|
||||
<Preprocessor Value="ESCAPE="WITH\ SPACE""/>
|
||||
</Compiler>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_Pch()
|
||||
pchheader "pch.h"
|
||||
prepare()
|
||||
codelite.project.compiler(cfg)
|
||||
test.capture [[
|
||||
<Compiler Options="" C_Options="" Assembler="" Required="yes" PreCompiledHeader="pch.h" PCHInCommandLine="yes" UseDifferentPCHFlags="no" PCHFlags="">
|
||||
</Compiler>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_Linker()
|
||||
prepare()
|
||||
codelite.project.linker(cfg)
|
||||
test.capture [[
|
||||
<Linker Required="yes" Options="">
|
||||
</Linker>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_LibPath()
|
||||
libdirs { "test/", "test2" }
|
||||
prepare()
|
||||
codelite.project.linker(cfg)
|
||||
test.capture [[
|
||||
<Linker Required="yes" Options="">
|
||||
<LibraryPath Value="test"/>
|
||||
<LibraryPath Value="test2"/>
|
||||
</Linker>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_Libs()
|
||||
links { "a", "b" }
|
||||
prepare()
|
||||
codelite.project.linker(cfg)
|
||||
test.capture [[
|
||||
<Linker Required="yes" Options="-la;-lb">
|
||||
</Linker>
|
||||
]]
|
||||
end
|
||||
|
||||
-- TODO: test sibling lib project links
|
||||
|
||||
|
||||
function suite.OnProjectCfg_ResCompiler()
|
||||
prepare()
|
||||
codelite.project.resourceCompiler(cfg)
|
||||
test.capture [[
|
||||
<ResourceCompiler Options="" Required="no"/>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_ResInclude()
|
||||
files { "x.rc" }
|
||||
resincludedirs { "dir/" }
|
||||
prepare()
|
||||
codelite.project.resourceCompiler(cfg)
|
||||
test.capture [[
|
||||
<ResourceCompiler Options="" Required="yes">
|
||||
<IncludePath Value="dir"/>
|
||||
</ResourceCompiler>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_ResRegularInclude()
|
||||
files { "x.rc" }
|
||||
includedirs { "regulardir/" }
|
||||
prepare()
|
||||
codelite.project.resourceCompiler(cfg)
|
||||
test.capture [[
|
||||
<ResourceCompiler Options="" Required="yes">
|
||||
<IncludePath Value="regulardir"/>
|
||||
</ResourceCompiler>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_ResSysInclude()
|
||||
files { "x.rc" }
|
||||
sysincludedirs { "sysdir/" }
|
||||
prepare()
|
||||
codelite.project.resourceCompiler(cfg)
|
||||
test.capture [[
|
||||
<ResourceCompiler Options="" Required="yes">
|
||||
<IncludePath Value="sysdir"/>
|
||||
</ResourceCompiler>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_PreBuildMessage()
|
||||
prebuildmessage "test"
|
||||
prepare()
|
||||
codelite.project.preBuild(cfg)
|
||||
test.capture [[
|
||||
<PreBuild>
|
||||
<Command Enabled="yes">@echo test</Command>
|
||||
</PreBuild>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_PostBuildMessage()
|
||||
postbuildmessage "test"
|
||||
prepare()
|
||||
codelite.project.postBuild(cfg)
|
||||
test.capture [[
|
||||
<PostBuild>
|
||||
<Command Enabled="yes">@echo test</Command>
|
||||
</PostBuild>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_General()
|
||||
system "Windows"
|
||||
prepare()
|
||||
codelite.project.general(cfg)
|
||||
test.capture [[
|
||||
<General OutputFile="bin/Debug/MyProject.exe" IntermediateDirectory="obj/Debug" Command="bin/Debug/MyProject.exe" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_Environment()
|
||||
debugenvs { "ENV_ONE=1", "ENV_TWO=2" }
|
||||
prepare()
|
||||
codelite.project.environment(cfg)
|
||||
test.capture(
|
||||
' <Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">\n' ..
|
||||
' <![CDATA[ENV_ONE=1\n' ..
|
||||
'ENV_TWO=2]]>\n' ..
|
||||
' </Environment>'
|
||||
)
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_EnvironmentEscaping()
|
||||
debugenvs { "\"ENV\"=<&>" }
|
||||
prepare()
|
||||
codelite.project.environment(cfg)
|
||||
test.capture(
|
||||
' <Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">\n' ..
|
||||
' <![CDATA["ENV"=<&>]]>\n' ..
|
||||
' </Environment>'
|
||||
)
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_Debugger()
|
||||
prepare()
|
||||
codelite.project.debugger(cfg)
|
||||
test.capture [[
|
||||
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
|
||||
<DebuggerSearchPaths/>
|
||||
<PostConnectCommands/>
|
||||
<StartupCommands/>
|
||||
</Debugger>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_DebuggerOpts()
|
||||
debugremotehost "localhost"
|
||||
debugport(2345)
|
||||
debugextendedprotocol(true)
|
||||
debugsearchpaths { "search/", "path" }
|
||||
debugconnectcommands { "connectcmd1", "cmd2" }
|
||||
debugstartupcommands { "startcmd1", "cmd2" }
|
||||
prepare()
|
||||
codelite.project.debugger(cfg)
|
||||
test.capture [[
|
||||
<Debugger IsRemote="yes" RemoteHostName="localhost" RemoteHostPort="2345" DebuggerPath="" IsExtended="yes">
|
||||
<DebuggerSearchPaths>search
|
||||
path</DebuggerSearchPaths>
|
||||
<PostConnectCommands>connectcmd1
|
||||
cmd2</PostConnectCommands>
|
||||
<StartupCommands>startcmd1
|
||||
cmd2</StartupCommands>
|
||||
</Debugger>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_DebuggerOptsEscaping()
|
||||
debugremotehost "localhost"
|
||||
debugport(2345)
|
||||
debugextendedprotocol(true)
|
||||
debugsearchpaths { "\"search\" && <path>" }
|
||||
debugconnectcommands { "\"connect\" && <cmd>" }
|
||||
debugstartupcommands { "\"start\" && <cmd>" }
|
||||
prepare()
|
||||
codelite.project.debugger(cfg)
|
||||
test.capture [[
|
||||
<Debugger IsRemote="yes" RemoteHostName="localhost" RemoteHostPort="2345" DebuggerPath="" IsExtended="yes">
|
||||
<DebuggerSearchPaths>"search" && <path></DebuggerSearchPaths>
|
||||
<PostConnectCommands>"connect" && <cmd></PostConnectCommands>
|
||||
<StartupCommands>"start" && <cmd></StartupCommands>
|
||||
</Debugger>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_PreBuild()
|
||||
prebuildcommands { "cmd0", "cmd1" }
|
||||
prepare()
|
||||
codelite.project.preBuild(prj)
|
||||
test.capture [[
|
||||
<PreBuild>
|
||||
<Command Enabled="yes">cmd0</Command>
|
||||
<Command Enabled="yes">cmd1</Command>
|
||||
</PreBuild>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_PreBuild_Escaped()
|
||||
prebuildcommands {
|
||||
"touch \"./build/copyright\" && echo OK",
|
||||
"cat \"./lib/copyright\" >> \"./build/copyright\""
|
||||
}
|
||||
prepare()
|
||||
codelite.project.preBuild(prj)
|
||||
test.capture [[
|
||||
<PreBuild>
|
||||
<Command Enabled="yes">touch "./build/copyright" && echo OK</Command>
|
||||
<Command Enabled="yes">cat "./lib/copyright" >> "./build/copyright"</Command>
|
||||
</PreBuild>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_PostBuild()
|
||||
postbuildcommands { "cmd0", "cmd1" }
|
||||
prepare()
|
||||
codelite.project.postBuild(prj)
|
||||
test.capture [[
|
||||
<PostBuild>
|
||||
<Command Enabled="yes">cmd0</Command>
|
||||
<Command Enabled="yes">cmd1</Command>
|
||||
</PostBuild>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_PostBuild_Escaped()
|
||||
postbuildcommands {
|
||||
"touch \"./build/copyright\" && echo OK",
|
||||
"cat \"./lib/copyright\" >> \"./build/copyright\""
|
||||
}
|
||||
prepare()
|
||||
codelite.project.postBuild(prj)
|
||||
test.capture [[
|
||||
<PostBuild>
|
||||
<Command Enabled="yes">touch "./build/copyright" && echo OK</Command>
|
||||
<Command Enabled="yes">cat "./lib/copyright" >> "./build/copyright"</Command>
|
||||
</PostBuild>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_Completion()
|
||||
language "C++"
|
||||
cppdialect "C++11"
|
||||
prepare()
|
||||
codelite.project.completion(prj)
|
||||
test.capture [[
|
||||
<Completion EnableCpp11="yes" EnableCpp14="no">
|
||||
<ClangCmpFlagsC/>
|
||||
<ClangCmpFlags/>
|
||||
<ClangPP/>
|
||||
<SearchPaths/>
|
||||
</Completion>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProjectCfg_UnsignedCharOn()
|
||||
unsignedchar "On"
|
||||
prepare()
|
||||
codelite.project.compiler(cfg)
|
||||
test.capture [[
|
||||
<Compiler Options="-funsigned-char" C_Options="-funsigned-char" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
||||
</Compiler>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
function suite.OnProjectCfg_UnsignedCharOff()
|
||||
unsignedchar "Off"
|
||||
prepare()
|
||||
codelite.project.compiler(cfg)
|
||||
test.capture [[
|
||||
<Compiler Options="-fno-unsigned-char" C_Options="-fno-unsigned-char" Assembler="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
|
||||
</Compiler>
|
||||
]]
|
||||
end
|
||||
@@ -0,0 +1,102 @@
|
||||
---
|
||||
-- codelite/tests/test_codelite_project.lua
|
||||
-- Automated test suite for CodeLite project generation.
|
||||
-- Copyright (c) 2015 Manu Evans and the Premake project
|
||||
---
|
||||
|
||||
|
||||
local suite = test.declare("codelite_cproj")
|
||||
local p = premake
|
||||
local codelite = p.modules.codelite
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
-- Setup/Teardown
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
local wks, prj
|
||||
|
||||
function suite.setup()
|
||||
p.action.set("codelite")
|
||||
p.escaper(codelite.esc)
|
||||
p.indent(" ")
|
||||
wks = test.createWorkspace()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
wks = p.oven.bakeWorkspace(wks)
|
||||
prj = test.getproject(wks, 1)
|
||||
end
|
||||
|
||||
|
||||
function suite.OnProject_Header()
|
||||
prepare()
|
||||
codelite.project.header(prj)
|
||||
test.capture [[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Project Name="MyProject" InternalType="Console">
|
||||
]]
|
||||
end
|
||||
function suite.OnProject_Header_Windowed()
|
||||
kind "WindowedApp"
|
||||
prepare()
|
||||
codelite.project.header(prj)
|
||||
test.capture [[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Project Name="MyProject" InternalType="Console">
|
||||
]]
|
||||
end
|
||||
function suite.OnProject_Header_Shared()
|
||||
kind "SharedLib"
|
||||
prepare()
|
||||
codelite.project.header(prj)
|
||||
test.capture [[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Project Name="MyProject" InternalType="Library">
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProject_Plugins()
|
||||
prepare()
|
||||
codelite.project.plugins(prj)
|
||||
test.capture [[
|
||||
<Plugins/>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProject_Description()
|
||||
prepare()
|
||||
codelite.project.description(prj)
|
||||
test.capture [[
|
||||
<Description/>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.OnProject_Dependencies()
|
||||
prepare()
|
||||
codelite.project.dependencies(prj)
|
||||
test.capture [[
|
||||
<Dependencies Name="Debug"/>
|
||||
<Dependencies Name="Release"/>
|
||||
]]
|
||||
end
|
||||
|
||||
-- TODO: dependencies with actual dependencies...
|
||||
|
||||
|
||||
-- GlobalSettings is currently constants, so we'll just test it here
|
||||
function suite.OnProject_Settings()
|
||||
prepare()
|
||||
codelite.project.settings(prj)
|
||||
test.capture [[
|
||||
<Settings Type="Executable">
|
||||
<GlobalSettings>
|
||||
<Compiler Options="" C_Options="" Assembler="">
|
||||
<IncludePath Value="."/>
|
||||
</Compiler>
|
||||
<Linker Options="">
|
||||
<LibraryPath Value="."/>
|
||||
</Linker>
|
||||
<ResourceCompiler Options=""/>
|
||||
</GlobalSettings>
|
||||
]]
|
||||
end
|
||||
@@ -0,0 +1,224 @@
|
||||
---
|
||||
-- codelite/tests/test_codelite_workspace.lua
|
||||
-- Validate generation for CodeLite workspaces.
|
||||
-- Author Manu Evans
|
||||
-- Copyright (c) 2015 Manu Evans and the Premake project
|
||||
---
|
||||
|
||||
local suite = test.declare("codelite_workspace")
|
||||
local p = premake
|
||||
local codelite = p.modules.codelite
|
||||
|
||||
|
||||
--
|
||||
-- Setup
|
||||
--
|
||||
|
||||
local wks, prj
|
||||
|
||||
function suite.setup()
|
||||
p.action.set("codelite")
|
||||
p.escaper(codelite.esc)
|
||||
p.indent(" ")
|
||||
wks = test.createWorkspace()
|
||||
end
|
||||
|
||||
local function prepare()
|
||||
wks = test.getWorkspace(wks)
|
||||
codelite.workspace.generate(wks)
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Check the basic structure of a workspace.
|
||||
--
|
||||
|
||||
function suite.onEmptyWorkspace()
|
||||
wks.projects = {}
|
||||
prepare()
|
||||
test.capture [[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
|
||||
<BuildMatrix>
|
||||
<WorkspaceConfiguration Name="Debug" Selected="yes">
|
||||
</WorkspaceConfiguration>
|
||||
<WorkspaceConfiguration Name="Release" Selected="no">
|
||||
</WorkspaceConfiguration>
|
||||
</BuildMatrix>
|
||||
</CodeLite_Workspace>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onDefaultWorkspace()
|
||||
prepare()
|
||||
test.capture [[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
|
||||
<Project Name="MyProject" Path="MyProject.project"/>
|
||||
<BuildMatrix>
|
||||
<WorkspaceConfiguration Name="Debug" Selected="yes">
|
||||
<Project Name="MyProject" ConfigName="Debug"/>
|
||||
</WorkspaceConfiguration>
|
||||
<WorkspaceConfiguration Name="Release" Selected="no">
|
||||
<Project Name="MyProject" ConfigName="Release"/>
|
||||
</WorkspaceConfiguration>
|
||||
</BuildMatrix>
|
||||
</CodeLite_Workspace>
|
||||
]]
|
||||
end
|
||||
|
||||
function suite.onMultipleProjects()
|
||||
test.createproject(wks)
|
||||
prepare()
|
||||
test.capture [[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
|
||||
<Project Name="MyProject" Path="MyProject.project"/>
|
||||
<Project Name="MyProject2" Path="MyProject2.project"/>
|
||||
<BuildMatrix>
|
||||
<WorkspaceConfiguration Name="Debug" Selected="yes">
|
||||
<Project Name="MyProject" ConfigName="Debug"/>
|
||||
<Project Name="MyProject2" ConfigName="Debug"/>
|
||||
</WorkspaceConfiguration>
|
||||
<WorkspaceConfiguration Name="Release" Selected="no">
|
||||
<Project Name="MyProject" ConfigName="Release"/>
|
||||
<Project Name="MyProject2" ConfigName="Release"/>
|
||||
</WorkspaceConfiguration>
|
||||
</BuildMatrix>
|
||||
</CodeLite_Workspace>
|
||||
]]
|
||||
end
|
||||
|
||||
|
||||
--
|
||||
-- Projects should include relative path from workspace.
|
||||
--
|
||||
|
||||
function suite.onNestedProjectPath()
|
||||
location "MyProject"
|
||||
prepare()
|
||||
test.capture([[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
|
||||
<Project Name="MyProject" Path="MyProject/MyProject.project"/>
|
||||
<BuildMatrix>
|
||||
<WorkspaceConfiguration Name="Debug" Selected="yes">
|
||||
<Project Name="MyProject" ConfigName="Debug"/>
|
||||
</WorkspaceConfiguration>
|
||||
<WorkspaceConfiguration Name="Release" Selected="no">
|
||||
<Project Name="MyProject" ConfigName="Release"/>
|
||||
</WorkspaceConfiguration>
|
||||
</BuildMatrix>
|
||||
</CodeLite_Workspace>
|
||||
]])
|
||||
end
|
||||
|
||||
function suite.onExternalProjectPath()
|
||||
location "../MyProject"
|
||||
prepare()
|
||||
test.capture([[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
|
||||
<Project Name="MyProject" Path="../MyProject/MyProject.project"/>
|
||||
<BuildMatrix>
|
||||
<WorkspaceConfiguration Name="Debug" Selected="yes">
|
||||
<Project Name="MyProject" ConfigName="Debug"/>
|
||||
</WorkspaceConfiguration>
|
||||
<WorkspaceConfiguration Name="Release" Selected="no">
|
||||
<Project Name="MyProject" ConfigName="Release"/>
|
||||
</WorkspaceConfiguration>
|
||||
</BuildMatrix>
|
||||
</CodeLite_Workspace>
|
||||
]])
|
||||
end
|
||||
|
||||
|
||||
function suite.onActiveProject()
|
||||
workspace("MyWorkspace")
|
||||
startproject "MyProject"
|
||||
prepare()
|
||||
test.capture([[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
|
||||
<Project Name="MyProject" Path="MyProject.project" Active="Yes"/>
|
||||
<BuildMatrix>
|
||||
<WorkspaceConfiguration Name="Debug" Selected="yes">
|
||||
<Project Name="MyProject" ConfigName="Debug"/>
|
||||
</WorkspaceConfiguration>
|
||||
<WorkspaceConfiguration Name="Release" Selected="no">
|
||||
<Project Name="MyProject" ConfigName="Release"/>
|
||||
</WorkspaceConfiguration>
|
||||
</BuildMatrix>
|
||||
</CodeLite_Workspace>
|
||||
]])
|
||||
end
|
||||
|
||||
|
||||
function suite.onGroupedProjects()
|
||||
wks.projects = {}
|
||||
project "MyGrouplessProject"
|
||||
group "MyGroup"
|
||||
project "MyGroupedProject"
|
||||
group "My/Nested/Group"
|
||||
project "MyNestedGroupedProject"
|
||||
prepare()
|
||||
test.capture([[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
|
||||
<VirtualDirectory Name="My">
|
||||
<VirtualDirectory Name="Nested">
|
||||
<VirtualDirectory Name="Group">
|
||||
<Project Name="MyNestedGroupedProject" Path="MyNestedGroupedProject.project"/>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
<VirtualDirectory Name="MyGroup">
|
||||
<Project Name="MyGroupedProject" Path="MyGroupedProject.project"/>
|
||||
</VirtualDirectory>
|
||||
<Project Name="MyGrouplessProject" Path="MyGrouplessProject.project"/>
|
||||
<BuildMatrix>
|
||||
<WorkspaceConfiguration Name="Debug" Selected="yes">
|
||||
<Project Name="MyNestedGroupedProject" ConfigName="Debug"/>
|
||||
<Project Name="MyGroupedProject" ConfigName="Debug"/>
|
||||
<Project Name="MyGrouplessProject" ConfigName="Debug"/>
|
||||
</WorkspaceConfiguration>
|
||||
<WorkspaceConfiguration Name="Release" Selected="no">
|
||||
<Project Name="MyNestedGroupedProject" ConfigName="Release"/>
|
||||
<Project Name="MyGroupedProject" ConfigName="Release"/>
|
||||
<Project Name="MyGrouplessProject" ConfigName="Release"/>
|
||||
</WorkspaceConfiguration>
|
||||
</BuildMatrix>
|
||||
</CodeLite_Workspace>
|
||||
]])
|
||||
end
|
||||
|
||||
---
|
||||
-- Test handling of platforms
|
||||
---
|
||||
|
||||
function suite.onPlatforms()
|
||||
workspace "MyWorkspace"
|
||||
platforms { "x86_64", "x86" }
|
||||
|
||||
prepare()
|
||||
test.capture [[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Workspace Name="MyWorkspace" Database="" SWTLW="No">
|
||||
<Project Name="MyProject" Path="MyProject.project"/>
|
||||
<BuildMatrix>
|
||||
<WorkspaceConfiguration Name="x86_64-Debug" Selected="yes">
|
||||
<Project Name="MyProject" ConfigName="x86_64-Debug"/>
|
||||
</WorkspaceConfiguration>
|
||||
<WorkspaceConfiguration Name="x86-Debug" Selected="no">
|
||||
<Project Name="MyProject" ConfigName="x86-Debug"/>
|
||||
</WorkspaceConfiguration>
|
||||
<WorkspaceConfiguration Name="x86_64-Release" Selected="no">
|
||||
<Project Name="MyProject" ConfigName="x86_64-Release"/>
|
||||
</WorkspaceConfiguration>
|
||||
<WorkspaceConfiguration Name="x86-Release" Selected="no">
|
||||
<Project Name="MyProject" ConfigName="x86-Release"/>
|
||||
</WorkspaceConfiguration>
|
||||
</BuildMatrix>
|
||||
</CodeLite_Workspace>
|
||||
]]
|
||||
end
|
||||
Reference in New Issue
Block a user