From f368770a36cca36ba17a8510f20516498145fe05 Mon Sep 17 00:00:00 2001 From: Liam Devine Date: Tue, 23 Aug 2011 21:48:16 +0100 Subject: * Added debug environment variable support for Codeblocks using gdb Changes the name from environmentargs to debugenvs Effects VS flags EnvironmentArgsInherit and EnvironmentArgsDontMerge which become DebugEnvsInherit and DebugEnvsDontMerge respectively. --- tests/actions/codeblocks/environment_variables.lua | 59 ++++++++++++++++ tests/actions/vstudio/vc2010/test_debugdir.lua | 80 +++++++++++----------- tests/premake4.lua | 1 + 3 files changed, 100 insertions(+), 40 deletions(-) create mode 100644 tests/actions/codeblocks/environment_variables.lua (limited to 'tests') diff --git a/tests/actions/codeblocks/environment_variables.lua b/tests/actions/codeblocks/environment_variables.lua new file mode 100644 index 0000000..83602ad --- /dev/null +++ b/tests/actions/codeblocks/environment_variables.lua @@ -0,0 +1,59 @@ +-- +-- tests/actions/codeblocks/environment_variables.lua +-- Validate generation of files block in CodeLite C/C++ projects. +-- Copyright (c) 2011 Jason Perkins and the Premake project +-- + + T.codeblocks_environment = { } + local suite = T.codeblocks_environment + local codeblocks = premake.codeblocks + + local old_eol = io.eol + function suite.setup() + _OPTIONS.cc = 'gcc' + old_eol = io.eol + io.eol = '\n' + end + + function suite.teardown() + io.eol = old_eol + end + + function suite.withVar_bufferContainsDebugger() + local MockName = 'MockName' + codeblocks.debugenvs( {debugenvs = {'foo=bar'},language='C',longname=MockName} ) + test.string_contains(io.endcapture(), + '\t\t\t\n' .. + '\t\t\t\t\n' .. + '\t\t\t\t\t\n' .. + '\t\t\t\t\n' .. + '\t\t\t' + ) + end + + function suite.format_SetEnvKeyValuePair() + local env_arg = 'foo=bar' + codeblocks.debugenvs( {debugenvs = {env_arg},language='C',longname='DontCare'} ) + test.string_contains(io.endcapture(),'') + end + + function suite.format_mutipleValues_setEnvKeyValuePairEscapeSetEnvKeyValuePair() + local env_arg = { 'foo=bar','baz=qux'} + codeblocks.debugenvs( {debugenvs = env_arg,language='C',longname='DontCare'} ) + test.string_contains(io.endcapture(),'') + end + + --Why is this an error and not silent? Because I feel if you are setting environment variables + --and they are not getting set in your IDE, than that is a problem which premake should not be + --quite about. + --See codeblocks project generator source for the assumption that gcc has anything to do with this setting. + function suite.withVar_noneGccCompiler_willCallError() + _OPTIONS.cc = 'msc' + local called = 0 + local real_error = error + error = function() called = 1 end + codeblocks.debugenvs( {debugenvs = {'foo=bar'},language='C',longname='foo'} ) + error = real_error + test.isequal(1,called) + end \ No newline at end of file diff --git a/tests/actions/vstudio/vc2010/test_debugdir.lua b/tests/actions/vstudio/vc2010/test_debugdir.lua index 82d3d14..5651515 100755 --- a/tests/actions/vstudio/vc2010/test_debugdir.lua +++ b/tests/actions/vstudio/vc2010/test_debugdir.lua @@ -54,43 +54,43 @@ ]] end - - - T.vs2010_env_args = { } - local vs10_env_args = T.vs2010_env_args - local env_args = premake.vstudio.vc2010.environmentargs - - function vs10_env_args.environmentArgs_notSet_bufferDoesNotContainLocalDebuggerEnvironment() - env_args( {flags={}} ) - test.string_does_not_contain(io.endcapture(),'') - end - - function vs10_env_args.environmentArgs_set_bufferContainsLocalDebuggerEnvironment() - env_args({flags={},environmentargs ={'key=value'}} ) - test.string_contains(io.endcapture(),'') - end - - function vs10_env_args.environmentArgs_oneArgformat_openTagKeyValuePairCloseTag() - env_args({flags={},environmentargs ={'key=value'}} ) - test.string_contains(io.endcapture(),'key=value') - end - - function vs10_env_args.environmentArgs_twoArgformat_openTagKeyValueNewLineSecondPairCloseTag() - env_args({flags={},environmentargs ={'key=value','foo=bar'}} ) - test.string_contains(io.endcapture(),'key=value\nfoo=bar') - end - - function vs10_env_args.environmentArgs_withOutFlagEnvironmentArgsInherit_doesNotContainLocalDebuggerEnvironmentArg() - env_args({flags={},environmentargs ={'key=value'}} ) - test.string_does_not_contain(io.endcapture(),'%$%(LocalDebuggerEnvironment%)') - end - - function vs10_env_args.environmentArgs_withFlagEnvironmentArgsInherit_endsWithNewLineLocalDebuggerEnvironmentFollowedByClosedTag() - env_args({flags={EnvironmentArgsInherit=1},environmentargs ={'key=value'}} ) - test.string_contains(io.endcapture(),'\n%$%(LocalDebuggerEnvironment%)') - end - - function vs10_env_args.environmentArgs_withEnvironmentArgsDontMerge_localDebuggerMergeEnvironmentSetToFalse() - env_args({flags={EnvironmentArgsDontMerge=1},environmentargs ={'key=value'}} ) - test.string_contains(io.endcapture(),'false') - end + + + T.vs2010_debug_environment = { } + local vs10_debug_environment = T.vs2010_debug_environment + local vs2010 = premake.vstudio.vc2010 + + function vs10_debug_environment.config_noDebugEnvsTable_bufferDoesNotContainLocalDebuggerEnvironment() + vs2010.debugenvs( {flags={}} ) + test.string_does_not_contain(io.endcapture(),'') + end + + function vs10_debug_environment.config_NoneEmtpyDebugEnvTable_bufferContainsLocalDebuggerEnvironment() + vs2010.debugenvs({flags={},debugenvs ={'key=value'}} ) + test.string_contains(io.endcapture(),'') + end + + function vs10_debug_environment.format_listContainsOneEntry_openTagKeyValuePairCloseTag() + vs2010.debugenvs({flags={},debugenvs ={'key=value'}} ) + test.string_contains(io.endcapture(),'key=value') + end + + function vs10_debug_environment.format_listContainsTwoEntries_openTagFirstPairNewLineSecondPairCloseTag() + vs2010.debugenvs({flags={},debugenvs ={'key=value','foo=bar'}} ) + test.string_contains(io.endcapture(),'key=value\nfoo=bar') + end + + function vs10_debug_environment.flags_withOutEnvironmentArgsInherit_doesNotContainLocalDebuggerEnvironmentArg() + vs2010.debugenvs({flags={},environmentargs ={'key=value'}} ) + test.string_does_not_contain(io.endcapture(),'%$%(LocalDebuggerEnvironment%)') + end + + function vs10_debug_environment.flags_withDebugEnvsInherit_endsWithNewLineLocalDebuggerEnvironmentFollowedByClosedTag() + vs2010.debugenvs({flags={DebugEnvsInherit=1},debugenvs ={'key=value'}} ) + test.string_contains(io.endcapture(),'\n%$%(LocalDebuggerEnvironment%)') + end + + function vs10_debug_environment.flags_withDebugEnvsDontMerge_localDebuggerMergeEnvironmentSetToFalse() + vs2010.debugenvs({flags={DebugEnvsDontMerge=1},debugenvs ={'key=value'}} ) + test.string_contains(io.endcapture(),'false') + end diff --git a/tests/premake4.lua b/tests/premake4.lua index 00ce43f..e24b7eb 100644 --- a/tests/premake4.lua +++ b/tests/premake4.lua @@ -127,6 +127,7 @@ -- CodeBlocks tests dofile("actions/codeblocks/codeblocks_files.lua") dofile("actions/codeblocks/test_filters.lua") + dofile("actions/codeblocks/environment_variables.lua") -- -- Register a test action -- cgit v1.2.3