diff options
| author | William Deegan <bill@baddogconsulting.com> | 2015-09-21 17:03:12 (GMT) |
|---|---|---|
| committer | William Deegan <bill@baddogconsulting.com> | 2015-09-21 17:03:12 (GMT) |
| commit | 0941093e0e5a030faa49968457638a3a6aee7ad8 (patch) | |
| tree | 6d33513c14eb6eac0531dd050de0ecca4c39bd79 /test/CPPPATH | |
| download | SCons-2.4.0.zip SCons-2.4.0.tar.gz SCons-2.4.0.tar.bz2 | |
release 2.4.02.4.0
Diffstat (limited to 'test/CPPPATH')
| -rw-r--r-- | test/CPPPATH/CPPPATH.py | 310 | ||||
| -rw-r--r-- | test/CPPPATH/Dir.py | 85 | ||||
| -rw-r--r-- | test/CPPPATH/absolute-path.py | 101 | ||||
| -rw-r--r-- | test/CPPPATH/expand-object.py | 69 | ||||
| -rw-r--r-- | test/CPPPATH/function-expansion.py | 143 | ||||
| -rw-r--r-- | test/CPPPATH/list-expansion.py | 138 | ||||
| -rw-r--r-- | test/CPPPATH/match-dir.py | 74 | ||||
| -rw-r--r-- | test/CPPPATH/nested-lists.py | 83 | ||||
| -rw-r--r-- | test/CPPPATH/null.py | 61 | ||||
| -rw-r--r-- | test/CPPPATH/subdir-as-include.py | 98 |
10 files changed, 1162 insertions, 0 deletions
diff --git a/test/CPPPATH/CPPPATH.py b/test/CPPPATH/CPPPATH.py new file mode 100644 index 0000000..efa64d2 --- /dev/null +++ b/test/CPPPATH/CPPPATH.py @@ -0,0 +1,310 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os.path + +import TestSCons + +_exe = TestSCons._exe + +prog = 'prog' + _exe +subdir_prog = os.path.join('subdir', 'prog' + _exe) +variant_prog = os.path.join('variant', 'prog' + _exe) + +args = prog + ' ' + subdir_prog + ' ' + variant_prog + +test = TestSCons.TestSCons() + +test.subdir('foobar', + 'include', + 'subdir', + ['subdir', 'include'], + 'inc2') + +test.write('SConstruct', """ +env = Environment(CPPPATH = ['$FOO', '${TARGET.dir}', '${SOURCE.dir}'], + FOO='include') +obj = env.Object(target='foobar/prog', source='subdir/prog.c') +env.Program(target='prog', source=obj) +SConscript('subdir/SConscript', "env") + +VariantDir('variant', 'subdir', 0) +include = Dir('include') +env = Environment(CPPPATH=[include, '#foobar', '#subdir']) +SConscript('variant/SConscript', "env") +""") + +test.write(['subdir', 'SConscript'], +""" +Import("env") +env.Program(target='prog', source='prog.c') +""") + +test.write(['include', 'foo.h'], +r""" +#define FOO_STRING "include/foo.h 1\n" +#include <bar.h> +""") + +test.write(['include', 'bar.h'], +r""" +#define BAR_STRING "include/bar.h 1\n" +""") + +test.write(['subdir', 'sss.h'], +r""" +#define SSS_STRING "subdir/sss.h\n" +""") + +test.write(['foobar', 'ttt.h'], +r""" +#define TTT_STRING "foobar/ttt.h\n" +""") + +test.write(['subdir', 'ttt.h'], +r""" +#define TTT_STRING "subdir/ttt.h\n" +""") + +test.write(['subdir', 'prog.c'], +r""" +#include <foo.h> +#include <sss.h> +#include <ttt.h> +#include <stdio.h> + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("subdir/prog.c\n"); + printf(FOO_STRING); + printf(BAR_STRING); + printf(SSS_STRING); + printf(TTT_STRING); + return 0; +} +""") + +test.write(['subdir', 'include', 'foo.h'], +r""" +#define FOO_STRING "subdir/include/foo.h 1\n" +#include "bar.h" +""") + +test.write(['subdir', 'include', 'bar.h'], +r""" +#define BAR_STRING "subdir/include/bar.h 1\n" +""") + + + +test.run(arguments = args) + +test.run(program = test.workpath(prog), + stdout = """\ +subdir/prog.c +include/foo.h 1 +include/bar.h 1 +subdir/sss.h +foobar/ttt.h +""") + +test.run(program = test.workpath(subdir_prog), + stdout = """\ +subdir/prog.c +subdir/include/foo.h 1 +subdir/include/bar.h 1 +subdir/sss.h +subdir/ttt.h +""") + +test.run(program = test.workpath(variant_prog), + stdout = """\ +subdir/prog.c +include/foo.h 1 +include/bar.h 1 +subdir/sss.h +foobar/ttt.h +""") + + + +# Make sure we didn't duplicate the source file in the variant subdirectory. +test.must_not_exist(test.workpath('variant', 'prog.c')) + +test.up_to_date(arguments = args) + +test.write(['include', 'foo.h'], +r""" +#define FOO_STRING "include/foo.h 2\n" +#include "bar.h" +""") + +test.run(arguments = args) + +test.run(program = test.workpath(prog), + stdout = """\ +subdir/prog.c +include/foo.h 2 +include/bar.h 1 +subdir/sss.h +foobar/ttt.h +""") + +test.run(program = test.workpath(subdir_prog), + stdout = """\ +subdir/prog.c +subdir/include/foo.h 1 +subdir/include/bar.h 1 +subdir/sss.h +subdir/ttt.h +""") + +test.run(program = test.workpath(variant_prog), + stdout = """\ +subdir/prog.c +include/foo.h 2 +include/bar.h 1 +subdir/sss.h +foobar/ttt.h +""") + + + +# Make sure we didn't duplicate the source file in the variant subdirectory. +test.must_not_exist(test.workpath('variant', 'prog.c')) + +test.up_to_date(arguments = args) + + + +# +test.write(['include', 'bar.h'], +r""" +#define BAR_STRING "include/bar.h 2\n" +""") + +test.run(arguments = args) + +test.run(program = test.workpath(prog), + stdout = """\ +subdir/prog.c +include/foo.h 2 +include/bar.h 2 +subdir/sss.h +foobar/ttt.h +""") + +test.run(program = test.workpath(subdir_prog), + stdout = """\ +subdir/prog.c +subdir/include/foo.h 1 +subdir/include/bar.h 1 +subdir/sss.h +subdir/ttt.h +""") + +test.run(program = test.workpath(variant_prog), + stdout = """\ +subdir/prog.c +include/foo.h 2 +include/bar.h 2 +subdir/sss.h +foobar/ttt.h +""") + +# Make sure we didn't duplicate the source file in the variant subdirectory. +test.must_not_exist(test.workpath('variant', 'prog.c')) + +test.up_to_date(arguments = args) + + + +# Change CPPPATH and make sure we don't rebuild because of it. +test.write('SConstruct', """ +env = Environment(CPPPATH = Split('inc2 include ${TARGET.dir} ${SOURCE.dir}')) +obj = env.Object(target='foobar/prog', source='subdir/prog.c') +env.Program(target='prog', source=obj) +SConscript('subdir/SConscript', "env") + +VariantDir('variant', 'subdir', 0) +include = Dir('include') +env = Environment(CPPPATH=['inc2', include, '#foobar', '#subdir']) +SConscript('variant/SConscript', "env") +""") + +test.up_to_date(arguments = args) + + + +# +test.write(['inc2', 'foo.h'], +r""" +#define FOO_STRING "inc2/foo.h 1\n" +#include <bar.h> +""") + +test.run(arguments = args) + +test.run(program = test.workpath(prog), + stdout = """\ +subdir/prog.c +inc2/foo.h 1 +include/bar.h 2 +subdir/sss.h +foobar/ttt.h +""") + +test.run(program = test.workpath(subdir_prog), + stdout = """\ +subdir/prog.c +subdir/include/foo.h 1 +subdir/include/bar.h 1 +subdir/sss.h +subdir/ttt.h +""") + +test.run(program = test.workpath(variant_prog), + stdout = """\ +subdir/prog.c +include/foo.h 2 +include/bar.h 2 +subdir/sss.h +foobar/ttt.h +""") + +test.up_to_date(arguments = args) + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/Dir.py b/test/CPPPATH/Dir.py new file mode 100644 index 0000000..8b557dc --- /dev/null +++ b/test/CPPPATH/Dir.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that CPPPATH values with Dir nodes work correctly. +""" + +import TestSCons + +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +test.subdir('inc1', 'inc2', 'inc3', ['inc3', 'subdir']) + +test.write('SConstruct', """ +env = Environment(CPPPATH = [Dir('inc1'), '$INC2', '$INC3/subdir'], + INC2 = Dir('inc2'), + INC3 = Dir('inc3')) +env.Program('prog.c') +""") + +test.write('prog.c', """\ +#include <stdio.h> +#include <stdlib.h> + +#include "one.h" +#include "two.h" +#include "three.h" +int +main(int argc, char *argv[]) +{ + printf("%s\\n", ONE); + printf("%s\\n", TWO); + printf("%s\\n", THREE); + return (0); +} +""") + +test.write(['inc1', 'one.h'], """\ +#define ONE "1" +""") + +test.write(['inc2', 'two.h'], """\ +#define TWO "2" +""") + +test.write(['inc3', 'subdir', 'three.h'], """\ +#define THREE "3" +""") + +test.run(arguments = '.') + +test.run(program = test.workpath('prog' + _exe), stdout = "1\n2\n3\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/absolute-path.py b/test/CPPPATH/absolute-path.py new file mode 100644 index 0000000..f414e09 --- /dev/null +++ b/test/CPPPATH/absolute-path.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify the ability to #include a file with an absolute path name. (Which +is not strictly a test of using $CPPPATH, but it's in the ball park...) +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('include', 'work') + +inc1_h = test.workpath('include', 'inc1.h') +inc2_h = test.workpath('include', 'inc2.h') +does_not_exist_h = test.workpath('include', 'does_not_exist.h') + +# Verify that including an absolute path still works even if they +# double the separators in the input file. This can happen especially +# on Windows if they use \\ to represent an escaped backslash. +inc2_h = inc2_h.replace(os.sep, os.sep+os.sep) + +test.write(['work', 'SConstruct'], """\ +Program('prog.c') +""") + +test.write(['work', 'prog.c'], """\ +#include <stdio.h> +#include "%(inc1_h)s" +#include "%(inc2_h)s" +#if 0 +#include "%(does_not_exist_h)s" +#endif + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("%%s\\n", STRING1); + printf("%%s\\n", STRING2); + return 0; +} +""" % locals()) + +test.write(['include', 'inc1.h'], """\ +#define STRING1 "include/inc1.h A\\n" +""") + +test.write(['include', 'inc2.h'], """\ +#define STRING2 "include/inc2.h A\\n" +""") + +test.run(chdir = 'work', arguments = '.') + +test.up_to_date(chdir = 'work', arguments = '.') + +test.write(['include', 'inc1.h'], """\ +#define STRING1 "include/inc1.h B\\n" +""") + +test.not_up_to_date(chdir = 'work', arguments = '.') + +test.write(['include', 'inc2.h'], """\ +#define STRING2 "include/inc2.h B\\n" +""") + +test.not_up_to_date(chdir = 'work', arguments = '.') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/expand-object.py b/test/CPPPATH/expand-object.py new file mode 100644 index 0000000..8c811b7 --- /dev/null +++ b/test/CPPPATH/expand-object.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Make sure that $CPPPATH expands correctly if one of the subsidiary +expansions contains a stringable non-Node object. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +class XXX(object): + def __init__(self, value): + self.value = value + def __str__(self): + return 'XXX-' + self.value + '-XXX' +env = Environment(CPPPATH = ['#', + '$BUILDDIR', + '/tmp/xyzzy'], + BUILDDIR = '#scons_build/$EXPANSION', + EXPANSION = XXX('win32')) +env.Object('foo.c') +""") + +test.write('foo.c', """\ +#include <stdio.h> +void +foo(void) +{ + printf("foo.c\\n"); +} +""") + +test.run(arguments = '.') + +test.must_exist(test.workpath('foo' + TestSCons._obj)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/function-expansion.py b/test/CPPPATH/function-expansion.py new file mode 100644 index 0000000..8ddd23c --- /dev/null +++ b/test/CPPPATH/function-expansion.py @@ -0,0 +1,143 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that expansion of construction variables whose values are functions +(that return lists that contain Nodes, even) works as expected within +a $CPPPATH list definition. + +This used to cause TypeErrors when the _concat expansion tried to +join the Nodes with the strings. + +Test courtesy Konstantin Bozhikov. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('list_inc1', + 'list_inc2', + 'inc1', + 'inc2', + 'inc3', + ['inc3', 'subdir']) + +test.write('SConstruct', """\ +env = Environment() +def my_cpppaths( target, source, env, for_signature ): + return [ Dir('list_inc1'), Dir('list_inc2') ] + +env = Environment( CPPPATH = [Dir('inc1'), '$INC2', '$INC3/subdir', '$MY_CPPPATHS' ], + INC2 = Dir('inc2'), + INC3 = Dir('inc3'), + MY_CPPPATHS = my_cpppaths ) + +env.Program('prog.c') +""") + +test.write('prog.c', """\ +#include <stdio.h> +#include <stdlib.h> +#include "string_list_1.h" +#include "string_list_2.h" +#include "string_1.h" +#include "string_2.h" +#include "string_3.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("prog.c\\n"); + printf("%s\\n", STRING_LIST_1); + printf("%s\\n", STRING_LIST_2); + printf("%s\\n", STRING_1); + printf("%s\\n", STRING_2); + printf("%s\\n", STRING_3); + exit (0); +} +""") + +test.write(['list_inc1', 'string_list_1.h'], """\ +#define STRING_LIST_1 "list_inc1/string_list_1.h" +""") + +test.write(['list_inc2', 'string_list_2.h'], """\ +#define STRING_LIST_2 "list_inc2/string_list_2.h" +""") + +test.write(['inc1', 'string_1.h'], """\ +#define STRING_1 "inc1/string_1.h" +""") + +test.write(['inc2', 'string_2.h'], """\ +#define STRING_2 "inc2/string_2.h" +""") + +test.write(['inc3', 'subdir', 'string_3.h'], """\ +#define STRING_3 "inc3/subdir/string_3.h" +""") + +test.run() + +test.up_to_date(arguments = '.') + +expect = """\ +prog.c +list_inc1/string_list_1.h +list_inc2/string_list_2.h +inc1/string_1.h +inc2/string_2.h +inc3/subdir/string_3.h +""" + +test.run(program = test.workpath('prog' + TestSCons._exe), stdout=expect) + +test.write(['inc3', 'subdir', 'string_3.h'], """\ +#define STRING_3 "inc3/subdir/string_3.h 2" +""") + +test.not_up_to_date(arguments = '.') + +expect = """\ +prog.c +list_inc1/string_list_1.h +list_inc2/string_list_2.h +inc1/string_1.h +inc2/string_2.h +inc3/subdir/string_3.h 2 +""" + +test.run(program = test.workpath('prog' + TestSCons._exe), stdout=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/list-expansion.py b/test/CPPPATH/list-expansion.py new file mode 100644 index 0000000..cec333d --- /dev/null +++ b/test/CPPPATH/list-expansion.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that expansion of construction variables whose values are +lists works as expected within a $CPPPATH list definition. + +Previously, the stringification of the expansion of the individual +variables would turn a list like ['sub1', 'sub2'] below into "-Isub1 sub2" +on the command line. + +Test case courtesy Daniel Svensson. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('sub1', 'sub2', 'sub3', 'sub4') + +test.write('SConstruct', """\ +class _inc_test(object): + def __init__(self, name): + self.name = name + + def __call__(self, target, source, env, for_signature): + return env.something[self.name] + +env = Environment() + +env.something = {} +env.something['test'] = ['sub1', 'sub2'] + +env['INC_PATHS1'] = _inc_test + +env['INC_PATHS2'] = ['sub3', 'sub4'] + +env.Append(CPPPATH = ['${INC_PATHS1("test")}', '$INC_PATHS2']) +env.Program('test', 'test.c') +""") + +test.write('test.c', """\ +#include <stdio.h> +#include <stdlib.h> +#include "string1.h" +#include "string2.h" +#include "string3.h" +#include "string4.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("test.c\\n"); + printf("%s\\n", STRING1); + printf("%s\\n", STRING2); + printf("%s\\n", STRING3); + printf("%s\\n", STRING4); + exit (0); +} +""") + +test.write(['sub1', 'string1.h'], """\ +#define STRING1 "sub1/string1.h" +""") + +test.write(['sub2', 'string2.h'], """\ +#define STRING2 "sub2/string2.h" +""") + +test.write(['sub3', 'string3.h'], """\ +#define STRING3 "sub3/string3.h" +""") + +test.write(['sub4', 'string4.h'], """\ +#define STRING4 "sub4/string4.h" +""") + +test.run() + +test.up_to_date(arguments = '.') + +expect = """\ +test.c +sub1/string1.h +sub2/string2.h +sub3/string3.h +sub4/string4.h +""" + +test.run(program = test.workpath('test' + TestSCons._exe), stdout=expect) + +test.write(['sub2', 'string2.h'], """\ +#define STRING2 "sub2/string2.h 2" +""") + +test.not_up_to_date(arguments = '.') + +expect = """\ +test.c +sub1/string1.h +sub2/string2.h 2 +sub3/string3.h +sub4/string4.h +""" + +test.run(program = test.workpath('test' + TestSCons._exe), stdout=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/match-dir.py b/test/CPPPATH/match-dir.py new file mode 100644 index 0000000..6ec30b4 --- /dev/null +++ b/test/CPPPATH/match-dir.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that we don't blow up if there's a directory name within +$CPPPATH that matches a #include file name. +""" + +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +# TODO(sgk): get this to work everywhere by using fake compilers +if sys.platform.find('sunos') != -1: + msg = 'SunOS C compiler does not handle this case; skipping test.\n' + test.skip_test(msg) + +test.subdir(['src'], + ['src', 'inc'], + ['src', 'inc', 'inc2']) + +test.write('SConstruct', """\ +SConscript('src/SConscript', variant_dir = 'build', duplicate = 0) +""") + +test.write(['src', 'SConscript'], """\ +env = Environment(CPPPATH = ['#build/inc', '#build/inc/inc2']) +env.Object('foo.c') +""") + +test.write(['src', 'foo.c'], """\ +#include "inc1" +""") + +test.subdir(['src', 'inc', 'inc1']) + +test.write(['src', 'inc', 'inc2', 'inc1'], "\n") + +test.run(arguments = '.') + +test.up_to_date(arguments = '.') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/nested-lists.py b/test/CPPPATH/nested-lists.py new file mode 100644 index 0000000..aa48b92 --- /dev/null +++ b/test/CPPPATH/nested-lists.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that CPPPATH values consisting of nested lists work correctly. +""" + +import TestSCons + +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +test.subdir('inc1', 'inc2', 'inc3') + +test.write('SConstruct', """ +env = Environment(CPPPATH = ['inc1', ['inc2', ['inc3']]]) +env.Program('prog.c') +""") + +test.write('prog.c', """\ +#include <stdio.h> +#include <stdlib.h> + +#include "one.h" +#include "two.h" +#include "three.h" +int +main(int argc, char *argv[]) +{ + printf("%s\\n", ONE); + printf("%s\\n", TWO); + printf("%s\\n", THREE); + return (0); +} +""") + +test.write(['inc1', 'one.h'], """\ +#define ONE "1" +""") + +test.write(['inc2', 'two.h'], """\ +#define TWO "2" +""") + +test.write(['inc3', 'three.h'], """\ +#define THREE "3" +""") + +test.run(arguments = '.') + +test.run(program = test.workpath('prog' + _exe), stdout = "1\n2\n3\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/null.py b/test/CPPPATH/null.py new file mode 100644 index 0000000..e23f655 --- /dev/null +++ b/test/CPPPATH/null.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify that neither a null-string CPPPATH nor a +a CPPPATH containing null values blows up. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +env = Environment(CPPPATH = '') +env.Library('one', source = 'empty1.c') +env = Environment(CPPPATH = [None]) +env.Library('two', source = 'empty2.c') +env = Environment(CPPPATH = ['']) +env.Library('three', source = 'empty3.c') +""") + +test.write('empty1.c', "int a=0;\n") +test.write('empty2.c', "int b=0;\n") +test.write('empty3.c', "int c=0;\n") + +test.run(arguments = '.', + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall) + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/subdir-as-include.py b/test/CPPPATH/subdir-as-include.py new file mode 100644 index 0000000..06a1a58 --- /dev/null +++ b/test/CPPPATH/subdir-as-include.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +This is an obscure test case. When a file without a suffix is included in +a c++ build and there is a directory with the same name as that file in a +sub-build directory, verify that an Errno 21 is not thrown upon trying to +recursively scan the contents of includes. The Errno 21 indicates that +the directory with the same name was trying to be scanned as the include +file, which it clearly is not. +""" + +import TestSCons + +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +test.subdir('inc1', ['inc1', 'iterator']) + +test.write('SConstruct', """ +env = Environment(CPPPATH = [Dir('inc1')]) +env.Program('prog.cpp') + +Export('env') +SConscript('inc1/SConscript', variant_dir='inc1/build', duplicate=0) +""") + +test.write('prog.cpp', """\ +#include <stdio.h> +#include <stdlib.h> + +#include "one.h" +#include <iterator> +int main(int argc, char* argv[]) +{ + printf("%s\\n", ONE); + return 0; +} +""") + +test.write(['inc1', 'SConscript'], """\ +Import('env') +oneenv = env.Clone() +oneenv.Program('one.cpp') +""") + +test.write(['inc1', 'one.h'], """\ +#define ONE "1" +""") + +test.write(['inc1', 'one.cpp'], """\ +#include <iterator> +#include <stdio.h> +#include "one.h" + +int main(int argc, char* argv[]) +{ + printf("%s\\n", ONE); + return 0; +} +""") + +test.run(arguments = '.') + +test.run(program = test.workpath('prog' + _exe), stdout = "1\n") +test.run(program = test.workpath('inc1/build/one' + _exe), stdout = "1\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: |
