--- -- 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 [[ ]] 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 [[ ]] end function suite.OnProjectCfg_Includes() includedirs { "dir/", "dir2" } prepare() codelite.project.compiler(cfg) test.capture [[ ]] end function suite.OnProjectCfg_Defines() defines { "TEST", "DEF", "VAL=1", "ESCAPE=\"WITH SPACE\"" } prepare() codelite.project.compiler(cfg) test.capture [[ ]] end function suite.OnProjectCfg_Linker() prepare() codelite.project.linker(cfg) test.capture [[ ]] end function suite.OnProjectCfg_LibPath() libdirs { "test/", "test2" } prepare() codelite.project.linker(cfg) test.capture [[ ]] end function suite.OnProjectCfg_Libs() links { "a", "b" } prepare() codelite.project.linker(cfg) test.capture [[ ]] end -- TODO: test sibling lib project links function suite.OnProjectCfg_ResCompiler() prepare() codelite.project.resourceCompiler(cfg) test.capture [[ ]] end function suite.OnProjectCfg_ResInclude() files { "x.rc" } resincludedirs { "dir/" } prepare() codelite.project.resourceCompiler(cfg) test.capture [[ ]] end function suite.OnProjectCfg_General() system "Windows" prepare() codelite.project.general(cfg) test.capture [[ ]] end function suite.OnProjectCfg_Environment() debugenvs { "ENV_ONE=1", "ENV_TWO=2" } prepare() codelite.project.environment(cfg) test.capture( ' \n' .. ' \n' .. ' ' ) end function suite.OnProjectCfg_EnvironmentEscaping() debugenvs { "\"ENV\"=<&>" } prepare() codelite.project.environment(cfg) test.capture( ' \n' .. ' ]]>\n' .. ' ' ) end function suite.OnProjectCfg_Debugger() prepare() codelite.project.debugger(cfg) test.capture [[ ]] 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 [[ search path connectcmd1 cmd2 startcmd1 cmd2 ]] end function suite.OnProjectCfg_DebuggerOptsEscaping() debugremotehost "localhost" debugport(2345) debugextendedprotocol(true) debugsearchpaths { "\"search\" && " } debugconnectcommands { "\"connect\" && " } debugstartupcommands { "\"start\" && " } prepare() codelite.project.debugger(cfg) test.capture [[ "search" && <path> "connect" && <cmd> "start" && <cmd> ]] end function suite.OnProjectCfg_PreBuild() prebuildcommands { "cmd0", "cmd1" } prepare() codelite.project.preBuild(prj) test.capture [[ cmd0 cmd1 ]] end function suite.OnProjectCfg_PreBuild_Escaped() prebuildcommands { "touch \"./build/copyright\" && echo OK", "cat \"./lib/copyright\" >> \"./build/copyright\"" } prepare() codelite.project.preBuild(prj) test.capture [[ touch "./build/copyright" && echo OK cat "./lib/copyright" >> "./build/copyright" ]] end function suite.OnProjectCfg_PostBuild() postbuildcommands { "cmd0", "cmd1" } prepare() codelite.project.postBuild(prj) test.capture [[ cmd0 cmd1 ]] end function suite.OnProjectCfg_PostBuild_Escaped() postbuildcommands { "touch \"./build/copyright\" && echo OK", "cat \"./lib/copyright\" >> \"./build/copyright\"" } prepare() codelite.project.postBuild(prj) test.capture [[ touch "./build/copyright" && echo OK cat "./lib/copyright" >> "./build/copyright" ]] end -- TODO: test custom build function suite.OnProjectCfg_AdditionalRules() prepare() codelite.project.additionalRules(prj) test.capture [[ ]] end function suite.OnProjectCfg_Completion() language "C++" cppdialect "C++11" prepare() codelite.project.completion(prj) test.capture [[ ]] end function suite.OnProjectCfg_UnsignedCharOn() unsignedchar "On" prepare() codelite.project.compiler(cfg) test.capture [[ ]] end function suite.OnProjectCfg_UnsignedCharOff() unsignedchar "Off" prepare() codelite.project.compiler(cfg) test.capture [[ ]] end