diff options
Diffstat (limited to 'test')
28 files changed, 1850 insertions, 239 deletions
diff --git a/test/CXX/CC-variables.py b/test/CXX/CC-variables.py new file mode 100644 index 0000000..93aa315 --- /dev/null +++ b/test/CXX/CC-variables.py @@ -0,0 +1,50 @@ +#!/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 initializing a construction environment with just the +g++ tool uses the CCFLAGS. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +env = Environment(tools = ['g++']) +env.Object(target = 'test.obj', source = 'test.cxx') +env.MergeFlags('+for_CCFLAGS -Wp,-for_CPPFLAGS') +""") + +test.write('test.cxx', "test.cxx\n") + +expect = """\ +g++ -o test.obj -c +for_CCFLAGS -Wp,-for_CPPFLAGS test.cxx +""" + +test.run(arguments = '-Q -n test.obj', stdout=expect) + +test.pass_test() diff --git a/test/CacheDir/NoCache.py b/test/CacheDir/NoCache.py new file mode 100644 index 0000000..44e51a0 --- /dev/null +++ b/test/CacheDir/NoCache.py @@ -0,0 +1,75 @@ +#!/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 the NoCache environment method works. +""" + +import TestSCons, os.path + +test = TestSCons.TestSCons() + +test.subdir('cache', 'alpha', 'beta') + +sconstruct = """ +import os +CacheDir(r'%s') + + +# This is bad form, but the easiest way to produce a test case. +# Obviously, this could be cached if the inputs were passed in a +# reasonable fashion. +g = '%s' + +def ActionWithUndeclaredInputs(target,source,env): + open(target[0].abspath,'w').write(g) + +Command('foo_cached', [], ActionWithUndeclaredInputs) +NoCache(Command('foo_notcached', [], ActionWithUndeclaredInputs)) +Command('bar_cached', [], ActionWithUndeclaredInputs) +Command('bar_notcached', [], ActionWithUndeclaredInputs) +NoCache('bar_notcached') + +# Make sure NoCache doesn't vomit when applied to a Dir +NoCache(Command(Dir('aoeu'), [], Mkdir('$TARGET'))) +""" + +test.write('alpha/SConstruct', sconstruct % (test.workpath('cache'), 'alpha')) + +test.write('beta/SConstruct', sconstruct % (test.workpath('cache'), 'beta')) + +# First build, would populate the cache without NoCache +test.run(chdir = 'alpha', arguments = '.') + +# Second build, without NoCache there would be a cache hit +test.run(chdir = 'beta', arguments = '.') + +test.must_match(['beta','foo_cached'], 'alpha') +test.must_match(['beta','foo_notcached'], 'beta') +test.must_match(['beta','bar_cached'], 'alpha') +test.must_match(['beta','bar_notcached'], 'beta') + +test.pass_test() diff --git a/test/Install/no-top-relative.py b/test/Install/no-top-relative.py new file mode 100644 index 0000000..51538ea --- /dev/null +++ b/test/Install/no-top-relative.py @@ -0,0 +1,53 @@ +#!/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 can install a file if its file name portion begins +with a '#'. (A previous bug re-interpreted that as relative to +the top-level SConstruct directory.) + +Thanks to Dave Weber for the test case. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir(['test']) + +test.write(['SConstruct'], """\ +env = Environment() +i = env.Install("#/install", "#/test/#testfile.txt#"); +env.Default(i); +""") + +test.write(['test', '#testfile.txt#'], "test/#testfile.txt#\n") + +test.run() + +test.must_match(['install', '#testfile.txt#'], "test/#testfile.txt#\n") + +test.pass_test() diff --git a/test/Java/JARCHDIR.py b/test/Java/JARCHDIR.py index 3ee3dee..9250843 100644 --- a/test/Java/JARCHDIR.py +++ b/test/Java/JARCHDIR.py @@ -58,7 +58,13 @@ env = Environment(tools = ['javac', 'jar'], JARCHDIR = dir) bin = env.Java(dir, Dir('./')) jar = env.Jar(File('c.jar', dir), bin) -Default(bin, jar) + +# Make sure we handle class files with $ in them, such as typically +# created for inner classes. +env = env.Clone(JARCHDIR = '.') +inner = env.Jar('inner.jar', 'Inner$$Class.class') + +Default(bin, jar, inner) """ % locals()) test.write('a.java', """\ @@ -71,6 +77,8 @@ package foo.bar; public class b {} """) +test.write('Inner$Class.class', "Inner$Class.class\n") + test.run(arguments = '.') test.pass_test() diff --git a/test/Options/BoolOption.py b/test/Options/BoolOption.py index 7af9bfd..aab2b20 100644 --- a/test/Options/BoolOption.py +++ b/test/Options/BoolOption.py @@ -31,6 +31,12 @@ Test the BoolOption canned Option type. import os.path import string +try: + True, False +except NameError: + True = (0 == 0) + False = (0 != 0) + import TestSCons test = TestSCons.TestSCons() @@ -64,10 +70,10 @@ Default(env.Alias('dummy', None)) test.run() -check(['1', '0']) +check([str(True), str(False)]) test.run(arguments='warnings=0 profile=no profile=true') -check(['0', '1']) +check([str(False), str(True)]) expect_stderr = """ scons: *** Error converting option: warnings diff --git a/test/Options/PackageOption.py b/test/Options/PackageOption.py index 81f7003..d285338 100644 --- a/test/Options/PackageOption.py +++ b/test/Options/PackageOption.py @@ -31,6 +31,12 @@ Test the PackageOption canned Option type. import os.path import string +try: + True, False +except NameError: + True = (0 == 0) + False = (0 != 0) + import TestSCons test = TestSCons.TestSCons() @@ -61,10 +67,16 @@ Default(env.Alias('dummy', None)) """) test.run() -check(['1']) -test.run(arguments='x11=no'); check(['0']) -test.run(arguments='x11=0'); check(['0']) -test.run(arguments=['x11=%s' % test.workpath()]); check([test.workpath()]) +check([str(True)]) + +test.run(arguments='x11=no') +check([str(False)]) + +test.run(arguments='x11=0') +check([str(False)]) + +test.run(arguments=['x11=%s' % test.workpath()]) +check([test.workpath()]) expect_stderr = """ scons: *** Path does not exist for option x11: /non/existing/path/ diff --git a/test/Options/help.py b/test/Options/help.py index 5ef5622..d3fa9ad 100644 --- a/test/Options/help.py +++ b/test/Options/help.py @@ -31,6 +31,15 @@ Test the Options help messages. import os.path import string +try: + True, False +except NameError: + True = (0 == 0) + False = (0 != 0) + +str_True = str(True) +str_False = str(False) + import TestSCons test = TestSCons.TestSCons() @@ -50,7 +59,7 @@ from SCons.Options import BoolOption, EnumOption, ListOption, \ PackageOption, PathOption list_of_libs = Split('x11 gl qt ical') -qtdir = r'%(qtdir)s' +qtdir = r'%(qtpath)s' opts = Options(args=ARGUMENTS) opts.AddOptions( @@ -85,23 +94,23 @@ print env['warnings'] print env['profile'] Default(env.Alias('dummy', None)) -""" % {'qtdir': qtpath, 'libdirvar': libdirvar, 'libdir': libpath}) +""" % locals()) test.run(arguments='-h', stdout = """\ scons: Reading SConscript files ... -1 -0 +%(str_True)s +%(str_False)s scons: done reading SConscript files. warnings: compilation with -Wall and similiar (yes|no) default: 1 - actual: 1 + actual: %(str_True)s profile: create profiling informations (yes|no) default: 0 - actual: 0 + actual: %(str_False)s debug: debug output and symbols (yes|no|full) default: no @@ -124,19 +133,18 @@ shared: libraries to build as shared libraries x11: use X11 installed here (yes = search some places) ( yes | no | /path/to/x11 ) default: yes - actual: 1 + actual: %(str_True)s qtdir: where the root of Qt is installed ( /path/to/qtdir ) - default: %(qtdir)s - actual: %(qtdir)s + default: %(qtpath)s + actual: %(qtpath)s qt_libraries: where the Qt library is installed ( /path/to/qt_libraries ) - default: %(qtdir_lib)s - actual: %(libdir)s + default: %(libdirvar)s + actual: %(libpath)s Use scons -H for help about command-line options. -""" % {'qtdir': qtpath, 'qtdir_lib' : os.path.join('$qtdir', 'lib'), - 'libdirvar': libdirvar, 'libdir': libpath}) +""" % locals()) diff --git a/test/ParseConfig.py b/test/ParseConfig.py index f142783..ed22276 100644 --- a/test/ParseConfig.py +++ b/test/ParseConfig.py @@ -55,8 +55,9 @@ test.write(test_config3, """\ print "-L foo -L lib_dir -isysroot /tmp -arch ppc -arch i386" """) -test.write('SConstruct', """ -env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], CCFLAGS = '') +test.write('SConstruct1', """ +env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], + CCFLAGS = '-pipe -Wall') env.ParseConfig([r'%(_python_)s', r"%(test_config1)s", "--libs --cflags"]) env.ParseConfig([r'%(_python_)s', r"%(test_config2)s", "--libs --cflags"]) print env['CPPPATH'] @@ -66,7 +67,8 @@ print env['CCFLAGS'] """ % locals()) test.write('SConstruct2', """ -env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], CCFLAGS = '', +env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], + CCFLAGS = '-pipe -Wall', PYTHON = r'%(_python_)s') env.ParseConfig(r"$PYTHON %(test_config1)s --libs --cflags") env.ParseConfig(r"$PYTHON %(test_config2)s --libs --cflags") @@ -77,7 +79,8 @@ print env['CCFLAGS'] """ % locals()) test.write('SConstruct3', """ -env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], CCFLAGS = '', +env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], + CCFLAGS = '-pipe -Wall', PYTHON = r'%(_python_)s') env.ParseConfig(r"$PYTHON %(test_config3)s --libs --cflags") print env['CPPPATH'] @@ -86,24 +89,24 @@ print map(lambda x: str(x), env['LIBS']) print env['CCFLAGS'] """ % locals()) -good_stdout = test.wrap_stdout(read_str = """\ +good_stdout = """\ ['/usr/include/fum', 'bar'] ['/usr/fax', 'foo', 'lib_dir'] ['xxx', 'abc'] -['-X', ('-arch', 'i386')] -""", build_str = "scons: `.' is up to date.\n") +['-pipe', '-Wall', '-X', ('-arch', 'i386')] +""" -stdout3 = test.wrap_stdout(read_str = """\ +stdout3 = """\ [] ['foo', 'lib_dir'] [] -[('-isysroot', '/tmp'), ('-arch', 'ppc'), ('-arch', 'i386')] -""", build_str = "scons: `.' is up to date.\n") +['-pipe', '-Wall', ('-isysroot', '/tmp'), ('-arch', 'ppc'), ('-arch', 'i386')] +""" -test.run(arguments = ".", stdout = good_stdout) +test.run(arguments = "-q -Q -f SConstruct1 .", stdout = good_stdout) -test.run(arguments = "-f SConstruct2 .", stdout = good_stdout) +test.run(arguments = "-q -Q -f SConstruct2 .", stdout = good_stdout) -test.run(arguments = "-f SConstruct3 .", stdout = stdout3) +test.run(arguments = "-q -Q -f SConstruct3 .", stdout = stdout3) test.pass_test() diff --git a/test/SPAWN.py b/test/SPAWN.py index f73ab11..2a3632e 100644 --- a/test/SPAWN.py +++ b/test/SPAWN.py @@ -46,21 +46,42 @@ test.write('SConstruct', """ import os import string import sys -def my_spawn(sh, escape, cmd, args, env): - s = string.join(args + ['extra.txt']) +def my_spawn1(sh, escape, cmd, args, env): + s = string.join(args + ['extra1.txt']) if sys.platform in ['win32']: s = '"' + s + '"' os.system(s) -env = Environment(SPAWN = my_spawn) -env.Command('file.out', 'file.in', '%(_python_)s cat.py $TARGET $SOURCES') -env = Environment() +def my_spawn2(sh, escape, cmd, args, env): + s = string.join(args + ['extra2.txt']) + if sys.platform in ['win32']: + s = '"' + s + '"' + os.system(s) +env = Environment(MY_SPAWN1 = my_spawn1, + MY_SPAWN2 = my_spawn2, + COMMAND = r'%(_python_)s cat.py $TARGET $SOURCES') +env1 = env.Clone(SPAWN = my_spawn1) +env1.Command('file1.out', 'file1.in', '$COMMAND') + +env2 = env.Clone(SPAWN = '$MY_SPAWN2') +env2.Command('file2.out', 'file2.in', '$COMMAND') + +env3 = env.Clone(SPAWN = '${USE_TWO and MY_SPAWN2 or MY_SPAWN1}') +env3.Command('file3.out', 'file3.in', '$COMMAND', USE_TWO=0) +env3.Command('file4.out', 'file4.in', '$COMMAND', USE_TWO=1) """ % locals()) -test.write('file.in', "file.in\n") -test.write('extra.txt', "extra.txt\n") +test.write('file1.in', "file1.in\n") +test.write('file2.in', "file2.in\n") +test.write('file3.in', "file3.in\n") +test.write('file4.in', "file4.in\n") +test.write('extra1.txt', "extra1.txt\n") +test.write('extra2.txt', "extra2.txt\n") test.run(arguments = '.') -test.must_match('file.out', "file.in\nextra.txt\n") +test.must_match('file1.out', "file1.in\nextra1.txt\n") +test.must_match('file2.out', "file2.in\nextra2.txt\n") +test.must_match('file3.out', "file3.in\nextra1.txt\n") +test.must_match('file4.out', "file4.in\nextra2.txt\n") test.pass_test() diff --git a/test/SWIG/SWIG.py b/test/SWIG/SWIG.py index 791d0e0..dfee5ef 100644 --- a/test/SWIG/SWIG.py +++ b/test/SWIG/SWIG.py @@ -24,6 +24,10 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +""" +Verify that the swig tool generates file names that we expect. +""" + import os import string import sys @@ -37,19 +41,11 @@ if sys.platform =='darwin': python = "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python" _python_ = '"' + python + '"' else: - python = TestSCons.python _python_ = TestSCons._python_ _exe = TestSCons._exe _obj = TestSCons._obj -# swig-python expects specific filenames. -# the platform specific suffix won't necessarily work. -if sys.platform == 'win32': - _dll = '.dll' -else: - _dll = '.so' - test = TestSCons.TestSCons() @@ -105,168 +101,13 @@ swig test.run(arguments = '.', stderr = None) test.run(program = test.workpath('test1' + _exe), stdout = "test1.i\n") -test.fail_test(not os.path.exists(test.workpath('test1_wrap.c'))) -test.fail_test(not os.path.exists(test.workpath('test1_wrap' + _obj))) +test.must_exist(test.workpath('test1_wrap.c')) +test.must_exist(test.workpath('test1_wrap' + _obj)) -test.fail_test(test.read('test2_wrap.c') != "test2.i\n") +test.must_match('test2_wrap.c', "test2.i\n") test.run(program = test.workpath('test3' + _exe), stdout = "test3.i\n") -test.fail_test(not os.path.exists(test.workpath('test3_wrap.cc'))) -test.fail_test(not os.path.exists(test.workpath('test3_wrap' + _obj))) - - - -swig = test.where_is('swig') - -if swig: - - version = sys.version[:3] # see also sys.prefix documentation - - # handle testing on other platforms: - ldmodule_prefix = '_' - - frameworks = '' - platform_sys_prefix = sys.prefix - if sys.platform == 'darwin': - # OS X has a built-in Python but no static libpython - # so you should link to it using apple's 'framework' scheme. - # (see top of file for further explanation) - frameworks = '-framework Python' - platform_sys_prefix = '/System/Library/Frameworks/Python.framework/Versions/%s/' % version - - test.write("wrapper.py", -"""import os -import string -import sys -open('%s', 'wb').write("wrapper.py\\n") -os.system(string.join(sys.argv[1:], " ")) -""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) - - test.write('SConstruct', """ -foo = Environment(SWIGFLAGS='-python', - CPPPATH='%(platform_sys_prefix)s/include/python%(version)s/', - LDMODULEPREFIX='%(ldmodule_prefix)s', - LDMODULESUFFIX='%(_dll)s', - FRAMEWORKSFLAGS='%(frameworks)s', - ) - -swig = foo.Dictionary('SWIG') -bar = foo.Clone(SWIG = r'%(_python_)s wrapper.py ' + swig) -foo.LoadableModule(target = 'foo', source = ['foo.c', 'foo.i']) -bar.LoadableModule(target = 'bar', source = ['bar.c', 'bar.i']) -""" % locals()) - - test.write("foo.c", """\ -char * -foo_string() -{ - return "This is foo.c!"; -} -""") - - test.write("foo.i", """\ -%module foo -%{ -/* Put header files here (optional) */ -%} - -extern char *foo_string(); -""") - - test.write("bar.c", """\ -char * -bar_string() -{ - return "This is bar.c!"; -} -""") - - test.write("bar.i", """\ -%module \t bar -%{ -/* Put header files here (optional) */ -%} - -extern char *bar_string(); -""") - - test.run(arguments = ldmodule_prefix+'foo' + _dll) - - test.must_not_exist(test.workpath('wrapper.out')) - - test.run(program = python, stdin = """\ -import foo -print foo.foo_string() -""", stdout="""\ -This is foo.c! -""") - - test.up_to_date(arguments = ldmodule_prefix+'foo' + _dll) - - test.run(arguments = ldmodule_prefix+'bar' + _dll) - - test.must_match('wrapper.out', "wrapper.py\n") - - test.run(program = python, stdin = """\ -import foo -import bar -print foo.foo_string() -print bar.bar_string() -""", stdout="""\ -This is foo.c! -This is bar.c! -""") - - test.up_to_date(arguments = '.') - - # Test that swig-generated modules are removed - # The %module directive specifies the module name - test.write("module.i", """\ -%module modulename -""") - test.write('SConstruct', """ -foo = Environment(SWIGFLAGS='-python', - CPPPATH='%(platform_sys_prefix)s/include/python%(version)s/', - LDMODULEPREFIX='%(ldmodule_prefix)s', - LDMODULESUFFIX='%(_dll)s', - FRAMEWORKSFLAGS='%(frameworks)s', - ) - -foo.LoadableModule(target = 'modulename', source = ['module.i']) -""" % locals()) - test.run() - test.must_exist(test.workpath("modulename.py")) - test.run(arguments = "-c") - test.must_not_exist(test.workpath("modulename.py")) - - # Test that implicit dependencies are caught - - test.write("dependency.i", """\ -%module dependency -""") - test.write("dependent.i", """\ -%module dependent - -%include dependency.i -""") - test.write('SConstruct', """ -foo = Environment(SWIGFLAGS='-python', - CPPPATH='%(platform_sys_prefix)s/include/python%(version)s/', - LDMODULEPREFIX='%(ldmodule_prefix)s', - LDMODULESUFFIX='%(_dll)s', - FRAMEWORKSFLAGS='%(frameworks)s', - ) - -swig = foo.Dictionary('SWIG') -bar = foo.Clone(SWIG = r'%(_python_)s wrapper.py ' + swig) -foo.CFile(target = 'dependent', source = ['dependent.i']) -""" % locals()) - - test.run() - test.write("dependency.i", """%module dependency - -extern char *dependency_string(); -""") - test.not_up_to_date(arguments = "dependent_wrap.c") +test.must_exist(test.workpath('test3_wrap.cc')) +test.must_exist(test.workpath('test3_wrap' + _obj)) test.pass_test() diff --git a/test/SWIG/implicit-dependencies.py b/test/SWIG/implicit-dependencies.py new file mode 100644 index 0000000..55645a4 --- /dev/null +++ b/test/SWIG/implicit-dependencies.py @@ -0,0 +1,110 @@ +#!/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 SWIG implicit dependencies are caught. +""" + +import sys + +import TestSCons + +if sys.platform =='darwin': + # change to make it work with stock OS X python framework + # we can't link to static libpython because there isn't one on OS X + # so we link to a framework version. However, testing must also + # use the same version, or else you get interpreter errors. + python = "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python" + _python_ = '"' + python + '"' +else: + python = TestSCons.python + _python_ = TestSCons._python_ + +# swig-python expects specific filenames. +# the platform specific suffix won't necessarily work. +if sys.platform == 'win32': + _dll = '.dll' +else: + _dll = '.so' + +test = TestSCons.TestSCons() + +swig = test.where_is('swig') + +if not swig: + test.skip_test('Can not find installed "swig", skipping test.\n') + + + +version = sys.version[:3] # see also sys.prefix documentation + +# handle testing on other platforms: +ldmodule_prefix = '_' + +frameworks = '' +platform_sys_prefix = sys.prefix +if sys.platform == 'darwin': + # OS X has a built-in Python but no static libpython + # so you should link to it using apple's 'framework' scheme. + # (see top of file for further explanation) + frameworks = '-framework Python' + platform_sys_prefix = '/System/Library/Frameworks/Python.framework/Versions/%s/' % version + +test.write("dependency.i", """\ +%module dependency +""") + +test.write("dependent.i", """\ +%module dependent + +%include dependency.i +""") + +test.write('SConstruct', """ +foo = Environment(SWIGFLAGS='-python', + CPPPATH='%(platform_sys_prefix)s/include/python%(version)s/', + LDMODULEPREFIX='%(ldmodule_prefix)s', + LDMODULESUFFIX='%(_dll)s', + FRAMEWORKSFLAGS='%(frameworks)s', + ) + +swig = foo.Dictionary('SWIG') +bar = foo.Clone(SWIG = r'%(_python_)s wrapper.py ' + swig) +foo.CFile(target = 'dependent', source = ['dependent.i']) +""" % locals()) + +test.run() + +test.write("dependency.i", """%module dependency + +extern char *dependency_string(); +""") + +test.not_up_to_date(arguments = "dependent_wrap.c") + + + +test.pass_test() diff --git a/test/SWIG/live.py b/test/SWIG/live.py new file mode 100644 index 0000000..c6b45d2 --- /dev/null +++ b/test/SWIG/live.py @@ -0,0 +1,164 @@ +#!/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__" + +""" +Test SWIG behavior with a live, installed SWIG. +""" + +import string +import sys + +import TestSCons + +if sys.platform =='darwin': + # change to make it work with stock OS X python framework + # we can't link to static libpython because there isn't one on OS X + # so we link to a framework version. However, testing must also + # use the same version, or else you get interpreter errors. + python = "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python" + _python_ = '"' + python + '"' +else: + python = TestSCons.python + _python_ = TestSCons._python_ + +# swig-python expects specific filenames. +# the platform specific suffix won't necessarily work. +if sys.platform == 'win32': + _dll = '.dll' +else: + _dll = '.so' + +test = TestSCons.TestSCons() + +swig = test.where_is('swig') + +if not swig: + test.skip_test('Can not find installed "swig", skipping test.\n') + + + +version = sys.version[:3] # see also sys.prefix documentation + +# handle testing on other platforms: +ldmodule_prefix = '_' + +frameworks = '' +platform_sys_prefix = sys.prefix +if sys.platform == 'darwin': + # OS X has a built-in Python but no static libpython + # so you should link to it using apple's 'framework' scheme. + # (see top of file for further explanation) + frameworks = '-framework Python' + platform_sys_prefix = '/System/Library/Frameworks/Python.framework/Versions/%s/' % version + +test.write("wrapper.py", +"""import os +import string +import sys +open('%s', 'wb').write("wrapper.py\\n") +os.system(string.join(sys.argv[1:], " ")) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) + +test.write('SConstruct', """ +foo = Environment(SWIGFLAGS='-python', + CPPPATH='%(platform_sys_prefix)s/include/python%(version)s/', + LDMODULEPREFIX='%(ldmodule_prefix)s', + LDMODULESUFFIX='%(_dll)s', + FRAMEWORKSFLAGS='%(frameworks)s', + ) + +swig = foo.Dictionary('SWIG') +bar = foo.Clone(SWIG = r'%(_python_)s wrapper.py ' + swig) +foo.LoadableModule(target = 'foo', source = ['foo.c', 'foo.i']) +bar.LoadableModule(target = 'bar', source = ['bar.c', 'bar.i']) +""" % locals()) + +test.write("foo.c", """\ +char * +foo_string() +{ + return "This is foo.c!"; +} +""") + +test.write("foo.i", """\ +%module foo +%{ +/* Put header files here (optional) */ +%} + +extern char *foo_string(); +""") + +test.write("bar.c", """\ +char * +bar_string() +{ + return "This is bar.c!"; +} +""") + +test.write("bar.i", """\ +%module \t bar +%{ +/* Put header files here (optional) */ +%} + +extern char *bar_string(); +""") + +test.run(arguments = ldmodule_prefix+'foo' + _dll) + +test.must_not_exist(test.workpath('wrapper.out')) + +test.run(program = python, stdin = """\ +import foo +print foo.foo_string() +""", stdout="""\ +This is foo.c! +""") + +test.up_to_date(arguments = ldmodule_prefix+'foo' + _dll) + +test.run(arguments = ldmodule_prefix+'bar' + _dll) + +test.must_match('wrapper.out', "wrapper.py\n") + +test.run(program = python, stdin = """\ +import foo +import bar +print foo.foo_string() +print bar.bar_string() +""", stdout="""\ +This is foo.c! +This is bar.c! +""") + +test.up_to_date(arguments = '.') + + + +test.pass_test() diff --git a/test/SWIG/noproxy.py b/test/SWIG/noproxy.py new file mode 100644 index 0000000..c0f6da6 --- /dev/null +++ b/test/SWIG/noproxy.py @@ -0,0 +1,108 @@ +#!/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 SCons realizes the -noproxy option means no .py file will +be created. +""" + +import sys + +import TestSCons + +if sys.platform =='darwin': + # change to make it work with stock OS X python framework + # we can't link to static libpython because there isn't one on OS X + # so we link to a framework version. However, testing must also + # use the same version, or else you get interpreter errors. + python = "/System/Library/Frameworks/Python.framework/Versions/Current/bin/python" + _python_ = '"' + python + '"' +else: + python = TestSCons.python + _python_ = TestSCons._python_ + +# swig-python expects specific filenames. +# the platform specific suffix won't necessarily work. +if sys.platform == 'win32': + _dll = '.dll' +else: + _dll = '.so' + +test = TestSCons.TestSCons() + +swig = test.where_is('swig') + +if not swig: + test.skip_test('Can not find installed "swig", skipping test.\n') + + + +version = sys.version[:3] # see also sys.prefix documentation + +# handle testing on other platforms: +ldmodule_prefix = '_' + +frameworks = '' +platform_sys_prefix = sys.prefix +if sys.platform == 'darwin': + # OS X has a built-in Python but no static libpython + # so you should link to it using apple's 'framework' scheme. + # (see top of file for further explanation) + frameworks = '-framework Python' + platform_sys_prefix = '/System/Library/Frameworks/Python.framework/Versions/%s/' % version + +test.write("dependency.i", """\ +%module dependency +""") + +test.write("dependent.i", """\ +%module dependent + +%include dependency.i +""") + +test.write('SConstruct', """ +foo = Environment(SWIGFLAGS=['-python', '-noproxy'], + CPPPATH='%(platform_sys_prefix)s/include/python%(version)s/', + LDMODULEPREFIX='%(ldmodule_prefix)s', + LDMODULESUFFIX='%(_dll)s', + FRAMEWORKSFLAGS='%(frameworks)s', + ) + +swig = foo.Dictionary('SWIG') +bar = foo.Clone(SWIG = r'%(_python_)s wrapper.py ' + swig) +foo.CFile(target = 'dependent', source = ['dependent.i']) +""" % locals()) + +test.run(arguments = '.') + +# If we mistakenly depend on the .py file that SWIG didn't create +# (suppressed by the -noproxy option) then the build won't be up-to-date. +test.up_to_date(arguments = '.') + + + +test.pass_test() diff --git a/test/SWIG/remove-modules.py b/test/SWIG/remove-modules.py new file mode 100644 index 0000000..cac9677 --- /dev/null +++ b/test/SWIG/remove-modules.py @@ -0,0 +1,92 @@ +#!/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 swig-generated modules are removed. +The %module directive specifies the module name. +""" + +import sys + +import TestSCons + +# swig-python expects specific filenames. +# the platform specific suffix won't necessarily work. +if sys.platform == 'win32': + _dll = '.dll' +else: + _dll = '.so' + +test = TestSCons.TestSCons() + +swig = test.where_is('swig') + +if not swig: + test.skip_test('Can not find installed "swig", skipping test.\n') + + + +version = sys.version[:3] # see also sys.prefix documentation + +# handle testing on other platforms: +ldmodule_prefix = '_' + +frameworks = '' +platform_sys_prefix = sys.prefix +if sys.platform == 'darwin': + # OS X has a built-in Python but no static libpython + # so you should link to it using apple's 'framework' scheme. + # (see top of file for further explanation) + frameworks = '-framework Python' + platform_sys_prefix = '/System/Library/Frameworks/Python.framework/Versions/%s/' % version + + +test.write("module.i", """\ +%module modulename +""") + +test.write('SConstruct', """ +foo = Environment(SWIGFLAGS='-python', + CPPPATH='%(platform_sys_prefix)s/include/python%(version)s/', + LDMODULEPREFIX='%(ldmodule_prefix)s', + LDMODULESUFFIX='%(_dll)s', + FRAMEWORKSFLAGS='%(frameworks)s', + ) + +foo.LoadableModule(target = 'modulename', source = ['module.i']) +""" % locals()) + +test.run() + +test.must_exist(test.workpath("modulename.py")) + +test.run(arguments = "-c") + +test.must_not_exist(test.workpath("modulename.py")) + + + +test.pass_test() diff --git a/test/Scanner/dictionary.py b/test/Scanner/dictionary.py new file mode 100644 index 0000000..62fda9b --- /dev/null +++ b/test/Scanner/dictionary.py @@ -0,0 +1,199 @@ +#!/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 +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.write('build.py', r""" +import sys +input = open(sys.argv[1], 'rb') +output = open(sys.argv[2], 'wb') + +include_prefix = 'include%s ' % sys.argv[1][-1] + +def process(infp, outfp): + for line in infp.readlines(): + if line[:len(include_prefix)] == include_prefix: + file = line[len(include_prefix):-1] + process(open(file, 'rb'), outfp) + else: + outfp.write(line) + +process(input, output) + +sys.exit(0) +""") + +# Execute a subsidiary SConscript just to make sure we can +# get at the Scanner keyword from there. + +test.write('SConstruct', """ +SConscript('SConscript') +""") + +test.write('SConscript', """ +import re + +include1_re = re.compile(r'^include1\s+(\S+)$', re.M) +include2_re = re.compile(r'^include2\s+(\S+)$', re.M) +include3_re = re.compile(r'^include3\s+(\S+)$', re.M) + +def kfile_scan1(node, env, scanpaths, arg=None): + contents = node.get_contents() + includes = include1_re.findall(contents) + return includes + +def kfile_scan2(node, env, scanpaths, arg=None): + contents = node.get_contents() + includes = include2_re.findall(contents) + return includes + +def kfile_scan3(node, env, scanpaths, arg=None): + contents = node.get_contents() + includes = include3_re.findall(contents) + return includes + +scan1 = Scanner(kfile_scan1) + +scan2 = Scanner(kfile_scan2) + +scan3 = Scanner(kfile_scan3) + +kscanner = Scanner({'.k1' : scan1, '.k2': scan2}) + +env = Environment(SCANNERS = [kscanner]) + +kscanner.add_scanner('.k3', scan3) + +env.Command('aaa', 'aaa.k1', r'%(_python_)s build.py $SOURCES $TARGET') +env.Command('bbb', 'bbb.k2', r'%(_python_)s build.py $SOURCES $TARGET') +env.Command('ccc', 'ccc.k3', r'%(_python_)s build.py $SOURCES $TARGET') +""" % locals()) + +test.write('aaa.k1', +"""aaa.k1 1 +line 2 +include1 xxx +include2 yyy +include3 zzz +line 6 +""") + +test.write('bbb.k2', +"""bbb.k2 1 +line 2 +include1 xxx +include2 yyy +include3 zzz +line 6 +""") + +test.write('ccc.k3', +"""ccc.k3 1 +line 2 +include1 xxx +include2 yyy +include3 zzz +line 6 +""") + +test.write('xxx', "xxx 1\n") +test.write('yyy', "yyy 1\n") +test.write('zzz', "zzz 1\n") + + + + +expect = test.wrap_stdout("""\ +%(_python_)s build.py aaa.k1 aaa +%(_python_)s build.py bbb.k2 bbb +%(_python_)s build.py ccc.k3 ccc +""" % locals()) + +test.run(stdout=expect) + +expect_aaa = 'aaa.k1 1\nline 2\nxxx 1\ninclude2 yyy\ninclude3 zzz\nline 6\n' +expect_bbb = 'bbb.k2 1\nline 2\ninclude1 xxx\nyyy 1\ninclude3 zzz\nline 6\n' +expect_ccc = 'ccc.k3 1\nline 2\ninclude1 xxx\ninclude2 yyy\nzzz 1\nline 6\n' + +test.must_match('aaa', expect_aaa) +test.must_match('bbb', expect_bbb) +test.must_match('ccc', expect_ccc) + +test.up_to_date(arguments = '.') + + + +test.write('zzz', "zzz 2\n") + +expect = test.wrap_stdout("""\ +%(_python_)s build.py ccc.k3 ccc +""" % locals()) + +test.run(stdout=expect) + +expect_ccc = 'ccc.k3 1\nline 2\ninclude1 xxx\ninclude2 yyy\nzzz 2\nline 6\n' + +test.must_match('bbb', expect_bbb) + + + +test.write('yyy', "yyy 2\n") + +expect = test.wrap_stdout("""\ +%(_python_)s build.py bbb.k2 bbb +""" % locals()) + +test.run(stdout=expect) + +expect_bbb = 'bbb.k2 1\nline 2\ninclude1 xxx\nyyy 2\ninclude3 zzz\nline 6\n' + +test.must_match('bbb', expect_bbb) + + + +test.write('xxx', "xxx 2\n") + +expect = test.wrap_stdout("""\ +%(_python_)s build.py aaa.k1 aaa +""" % locals()) + +test.run(stdout=expect) + +expect_aaa = 'aaa.k1 1\nline 2\nxxx 2\ninclude2 yyy\ninclude3 zzz\nline 6\n' + +test.must_match('bbb', expect_bbb) + + + +test.pass_test() diff --git a/test/Script-import.py b/test/Script-import.py index 4dd8d91..544960b 100644 --- a/test/Script-import.py +++ b/test/Script-import.py @@ -65,12 +65,12 @@ SCons.Script.OptParser SCons.Script.SConscriptSettableOptions SCons.Script.keep_going_on_error -SCons.Script.print_dtree +#SCons.Script.print_dtree SCons.Script.print_explanations SCons.Script.print_includes SCons.Script.print_objects SCons.Script.print_time -SCons.Script.print_tree +#SCons.Script.print_tree SCons.Script.memory_stats SCons.Script.ignore_errors #SCons.Script.sconscript_time diff --git a/test/option/debug-stree.py b/test/option/debug-stree.py index 8ffadc6..21ca386 100644 --- a/test/option/debug-stree.py +++ b/test/option/debug-stree.py @@ -73,40 +73,41 @@ test.write('bar.h', """ """) stree = """ -[E B C ]+-foo.xxx -[E B C ] +-foo.ooo -[E ] | +-foo.c -[E ] | +-foo.h -[E ] | +-bar.h -[E B C ] +-bar.ooo -[E ] +-bar.c -[E ] +-bar.h -[E ] +-foo.h +[E B C ]+-foo.xxx +[E B C ] +-foo.ooo +[E ] | +-foo.c +[E ] | +-foo.h +[E ] | +-bar.h +[E B C ] +-bar.ooo +[E ] +-bar.c +[E ] +-bar.h +[E ] +-foo.h """ test.run(arguments = "--debug=stree foo.xxx") test.fail_test(string.find(test.stdout(), stree) == -1) stree2 = """ - E = exists - R = exists in repository only - b = implicit builder - B = explicit builder - S = side effect - P = precious - A = always build - C = current - N = no clean - -[ B ]+-foo.xxx -[ B ] +-foo.ooo -[E ] | +-foo.c -[E ] | +-foo.h -[E ] | +-bar.h -[ B ] +-bar.ooo -[E ] +-bar.c -[E ] +-bar.h -[E ] +-foo.h + E = exists + R = exists in repository only + b = implicit builder + B = explicit builder + S = side effect + P = precious + A = always build + C = current + N = no clean + H = no cache + +[ B ]+-foo.xxx +[ B ] +-foo.ooo +[E ] | +-foo.c +[E ] | +-foo.h +[E ] | +-bar.h +[ B ] +-bar.ooo +[E ] +-bar.c +[E ] +-bar.h +[E ] +-foo.h """ test.run(arguments = '-c foo.xxx') diff --git a/test/option/repository.py b/test/option/repository.py new file mode 100644 index 0000000..d30cbec --- /dev/null +++ b/test/option/repository.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 the --srcdir option works to fetch things from a repository. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('repository', 'work1') + +repository = test.workpath('repository') + +test.write(['repository', 'SConstruct'], """\ +env = Environment() +env.Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE')) +""") + +test.write(['repository', 'file.in'], "repository/file.in\n") + +opts = '--repository ' + repository + +# Make the entire repository non-writable, so we'll detect +# if we try to write into it accidentally. +test.writable('repository', 0) + +test.run(chdir = 'work1', options = opts, arguments = '.') + +test.must_match(['work1', 'file.out'], "repository/file.in\n") + +test.up_to_date(chdir = 'work1', options = opts, arguments = '.') + + + +# +test.pass_test() diff --git a/test/option/srcdir.py b/test/option/srcdir.py new file mode 100644 index 0000000..b6bcc59 --- /dev/null +++ b/test/option/srcdir.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 the --srcdir option works to fetch things from a repository. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('repository', 'work1') + +repository = test.workpath('repository') + +test.write(['repository', 'SConstruct'], r""" +env = Environment() +env.Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE')) +""") + +test.write(['repository', 'file.in'], "repository/file.in\n") + +opts = '--srcdir ' + repository + +# Make the entire repository non-writable, so we'll detect +# if we try to write into it accidentally. +test.writable('repository', 0) + +test.run(chdir = 'work1', options = opts, arguments = '.') + +test.must_match(['work1', 'file.out'], "repository/file.in\n") + +test.up_to_date(chdir = 'work1', options = opts, arguments = '.') + + + +# +test.pass_test() diff --git a/test/option/tree-all.py b/test/option/tree-all.py new file mode 100644 index 0000000..92b9065 --- /dev/null +++ b/test/option/tree-all.py @@ -0,0 +1,190 @@ +#!/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__" + +""" +Test that the --tree=all option prints a tree representation of the +complete dependencies of a target. +""" + +import TestSCons +import sys +import string +import re +import time + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +env = Environment(OBJSUFFIX = '.ooo', PROGSUFFIX = '.xxx') +env.Program('Foo', Split('Foo.c Bar.c')) +""") + +# N.B.: We use upper-case file names (Foo* and Bar*) so that the sorting +# order with our upper-case SConstruct file is the same on case-sensitive +# (UNIX/Linux) and case-insensitive (Windows) systems. + +test.write('Foo.c', r""" +#include <stdio.h> +#include <stdlib.h> +#include "Foo.h" +int main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("f1.c\n"); + exit (0); +} +""") + +test.write('Bar.c', """ +#include "Bar.h" +""") + +test.write('Foo.h', """ +#ifndef FOO_H +#define FOO_H +#include "Bar.h" +#endif +""") + +test.write('Bar.h', """ +#ifndef BAR_H +#define BAR_H +#include "Foo.h" +#endif +""") + +tree1 = """ ++-Foo.xxx + +-Foo.ooo + | +-Foo.c + | +-Foo.h + | +-Bar.h + +-Bar.ooo + +-Bar.c + +-Bar.h + +-Foo.h +""" + +test.run(arguments = "--tree=all Foo.xxx") +test.fail_test(string.find(test.stdout(), tree1) == -1) + +tree2 = """ ++-. + +-Bar.c + +-Bar.ooo + | +-Bar.c + | +-Bar.h + | +-Foo.h + +-Foo.c + +-Foo.ooo + | +-Foo.c + | +-Foo.h + | +-Bar.h + +-Foo.xxx + | +-Foo.ooo + | | +-Foo.c + | | +-Foo.h + | | +-Bar.h + | +-Bar.ooo + | +-Bar.c + | +-Bar.h + | +-Foo.h + +-SConstruct +""" + +test.run(arguments = "--tree=all .") +test.fail_test(string.find(test.stdout(), tree2) == -1) + +tree3 = """ ++-. + +-Bar.c + +-Bar.ooo + | +-[Bar.c] + | +-Bar.h + | +-Foo.h + +-Foo.c + +-Foo.ooo + | +-[Foo.c] + | +-[Foo.h] + | +-[Bar.h] + +-Foo.xxx + | +-[Foo.ooo] + | +-[Bar.ooo] + +-SConstruct +""" + +test.run(arguments = "--tree=all,prune .") +test.fail_test(string.find(test.stdout(), tree3) == -1) + +test.run(arguments = "--tree=prune .") +test.fail_test(string.find(test.stdout(), tree3) == -1) + +tree4 = """ + E = exists + R = exists in repository only + b = implicit builder + B = explicit builder + S = side effect + P = precious + A = always build + C = current + N = no clean + H = no cache + +[ B ]+-Foo.xxx +[ B ] +-Foo.ooo +[E ] | +-Foo.c +[E ] | +-Foo.h +[E ] | +-Bar.h +[ B ] +-Bar.ooo +[E ] +-Bar.c +[E ] +-Bar.h +[E ] +-Foo.h +""" + +test.run(arguments = '-c Foo.xxx') + +test.run(arguments = "--no-exec --tree=all,status Foo.xxx") +test.fail_test(string.find(test.stdout(), tree4) == -1) + +test.run(arguments = "--no-exec --tree=status Foo.xxx") +test.fail_test(string.find(test.stdout(), tree4) == -1) + +# Make sure we print the debug stuff even if there's a build failure. +test.write('Bar.h', """ +#ifndef BAR_H +#define BAR_H +#include "Foo.h" +#endif +THIS SHOULD CAUSE A BUILD FAILURE +""") + +test.run(arguments = "--tree=all Foo.xxx", + status = 2, + stderr = None) +test.fail_test(string.find(test.stdout(), tree1) == -1) + +test.pass_test() diff --git a/test/option/tree-derived.py b/test/option/tree-derived.py new file mode 100644 index 0000000..a10faa2 --- /dev/null +++ b/test/option/tree-derived.py @@ -0,0 +1,144 @@ +#!/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__" + +""" +Test that the --debug=dtree option correctly prints just the explicit +dependencies (sources or Depends()) of a target. +""" + +import TestSCons +import sys +import string +import re +import time + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +env = Environment(OBJSUFFIX = '.ooo', PROGSUFFIX = '.xxx') +env.Program('foo', Split('foo.c bar.c')) +""") + +test.write('foo.c', r""" +#include <stdio.h> +#include <stdlib.h> +#include "foo.h" +int main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("f1.c\n"); + exit (0); +} +""") + +test.write('bar.c', """ +#include "bar.h" +""") + +test.write('foo.h', """ +#ifndef FOO_H +#define FOO_H +#include "bar.h" +#endif +""") + +test.write('bar.h', """ +#ifndef BAR_H +#define BAR_H +#include "foo.h" +#endif +""") + +dtree1 = """ ++-foo.xxx + +-foo.ooo + +-bar.ooo +""" + +test.run(arguments = "--tree=derived foo.xxx") +test.fail_test(string.find(test.stdout(), dtree1) == -1) + +dtree2 = """ ++-. + +-bar.ooo + +-foo.ooo + +-foo.xxx + +-foo.ooo + +-bar.ooo +""" + +test.run(arguments = "--tree=derived .") +test.fail_test(string.find(test.stdout(), dtree2) == -1) + +dtree3 = """ ++-. + +-bar.ooo + +-foo.ooo + +-foo.xxx + +-[foo.ooo] + +-[bar.ooo] +""" + +test.run(arguments = "--tree=derived,prune .") +test.fail_test(string.find(test.stdout(), dtree3) == -1) + +dtree4 = """ + E = exists + R = exists in repository only + b = implicit builder + B = explicit builder + S = side effect + P = precious + A = always build + C = current + N = no clean + H = no cache + +[ B ]+-foo.xxx +[ B ] +-foo.ooo +[ B ] +-bar.ooo +""" + +test.run(arguments = '-c foo.xxx') + +test.run(arguments = "--no-exec --tree=derived,status foo.xxx") +test.fail_test(string.find(test.stdout(), dtree4) == -1) + +# Make sure we print the debug stuff even if there's a build failure. +test.write('bar.h', """ +#ifndef BAR_H +#define BAR_H +#include "foo.h" +#endif +THIS SHOULD CAUSE A BUILD FAILURE +""") + +test.run(arguments = "--tree=derived foo.xxx", + status = 2, + stderr = None) +test.fail_test(string.find(test.stdout(), dtree1) == -1) + +test.pass_test() diff --git a/test/site_scons/basic.py b/test/site_scons/basic.py new file mode 100644 index 0000000..ed2e1d5 --- /dev/null +++ b/test/site_scons/basic.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__" + +import TestSCons + +""" +Verify basic functionality of the site_scons dir and +site_scons/site_init.py file: +Make sure the site_scons/site_init.py file gets loaded, +and make sure a tool can be loaded from the site_scons/site_tools subdir, +even when executing out of a subdirectory. +""" + +test = TestSCons.TestSCons() + +test.subdir('site_scons', ['site_scons', 'site_tools']) + +test.write(['site_scons', 'site_init.py'], """ +from SCons.Script import * +print "Hi there, I am in site_scons/site_init.py!" +""") + +test.write(['site_scons', 'site_tools', 'mytool.py'], """ +import SCons.Tool +def generate(env): + env['MYTOOL']='mytool' +def exists(env): + return 1 +""") + + +test.write('SConstruct', """ +e=Environment(tools=['default', 'mytool']) +print e.subst('My site tool is $MYTOOL') +""") + +test.run(arguments = '-Q .', + stdout = """Hi there, I am in site_scons/site_init.py! +My site tool is mytool +scons: `.' is up to date.\n""") + + + +test.pass_test() + +# end of file diff --git a/test/site_scons/no-site-dir.py b/test/site_scons/no-site-dir.py new file mode 100644 index 0000000..6f2f26e --- /dev/null +++ b/test/site_scons/no-site-dir.py @@ -0,0 +1,82 @@ +#!/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 use of the --no-site-dir option: +the site_scons/site_init.py script should NOT be loaded. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('site_scons', ['site_scons', 'site_tools']) + +test.write(['site_scons', 'site_init.py'], """ +from SCons.Script import * +print "Hi there, I am in site_scons/site_init.py!" +""") + +test.write(['site_scons', 'site_tools', 'mytool.py'], """ +import SCons.Tool +def generate(env): + env['MYTOOL']='mytool' +def exists(env): + return 1 +""") + +test.write(['site_scons', 'site_tools', 'm4.py'], """ +import SCons.Tool +def generate(env): + env['M4']='my_m4' + env['M4_MINE']=1 +def exists(env): + return 1 +""") + +test.write('SConstruct', """ +e=Environment() +""") + +test.run(arguments = '-Q --no-site-dir .', + stdout = "scons: `.' is up to date.\n") + +# With --no-site-dir, shouldn't override default m4 tool + +test.write('SConstruct', """ +e=Environment() +print e.subst('no site: M4 is $M4, M4_MINE is $M4_MINE') +""") + +test.run(arguments = '-Q --no-site-dir .', +stdout = """no site: M4 is m4, M4_MINE is +scons: `.' is up to date.\n""") + + + +test.pass_test() + +# end of file diff --git a/test/site_scons/nonexistent.py b/test/site_scons/nonexistent.py new file mode 100644 index 0000000..2185304 --- /dev/null +++ b/test/site_scons/nonexistent.py @@ -0,0 +1,47 @@ +#!/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 specifying --site-dir= with a nonexistent directory +gives an error and nonzero status. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', "\n") + +test.run(arguments = '-Q --site-dir=whatever .', + stderr = r".*site dir .*whatever not found.*", + status = 2, + match = TestSCons.match_re_dotall) + + + +test.pass_test() + +# end of file diff --git a/test/site_scons/override.py b/test/site_scons/override.py new file mode 100644 index 0000000..ebe56a6 --- /dev/null +++ b/test/site_scons/override.py @@ -0,0 +1,62 @@ +#!/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 a that a tool module in site_tools overrides base tool. + +Use 'm4' as test tool since it's likely to be found, +and not commonly overridden by platform-specific stuff the way cc is. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('site_scons', ['site_scons', 'site_tools']) + +test.write(['site_scons', 'site_tools', 'm4.py'], """ +import SCons.Tool +def generate(env): + env['M4']='my_m4' + env['M4_MINE']=1 +def exists(env): + return 1 +""") + +test.write('SConstruct', """ +e=Environment() +print e.subst('M4 is $M4, M4_MINE is $M4_MINE') +""") +test.run(arguments = '-Q .', + stdout = """M4 is my_m4, M4_MINE is 1 +scons: `.' is up to date.\n""") + + + +test.pass_test() + +# end of file diff --git a/test/site_scons/site-dir.py b/test/site_scons/site-dir.py new file mode 100644 index 0000000..a05817e --- /dev/null +++ b/test/site_scons/site-dir.py @@ -0,0 +1,73 @@ +#!/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 --site-dir=otherdir loads the site_init.py script +from the other dir; +the usual site_scons/site_init.py should NOT be loaded. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('site_scons', ['site_scons', 'site_tools']) + +test.write(['site_scons', 'site_init.py'], """ +from SCons.Script import * +print "Hi there, I am in site_scons/site_init.py!" +""") + +test.write(['site_scons', 'site_tools', 'mytool.py'], """ +import SCons.Tool +def generate(env): + env['MYTOOL']='mytool' +def exists(env): + return 1 +""") + + + +test.subdir('alt_site', ['alt_site', 'site_tools']) + +test.write(['alt_site', 'site_init.py'], """ +from SCons.Script import * +print "Hi there, I am in alt_site/site_init.py!" +""") + +test.write('SConstruct', """ +e=Environment() +""") + +test.run(arguments = '-Q --site-dir=alt_site .', + stdout = """Hi there, I am in alt_site/site_init.py! +scons: `.' is up to date.\n""") + + + +test.pass_test() + +# end of file diff --git a/test/toolpath/BuildDir.py b/test/toolpath/BuildDir.py new file mode 100644 index 0000000..a8b8b8a --- /dev/null +++ b/test/toolpath/BuildDir.py @@ -0,0 +1,71 @@ +#!/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 toolpath works with BuildDir() for an SConscript. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('subdir', ['subdir', 'src'], ['subdir', 'src', 'tools']) + +test.write('SConstruct', """\ +BuildDir('build', 'subdir', duplicate=0) +SConscript('build/SConscript') +""") + +test.write(['subdir', 'SConscript'], """\ +env = Environment(tools = ['MyBuilder'], toolpath = ['src/tools']) +env.MyCopy('src/file.out', 'src/file.in') +""") + +test.write(['subdir', 'src', 'file.in'], "subdir/src/file.in\n") + +test.write(['subdir', 'src', 'tools', 'MyBuilder.py'], """\ +from SCons.Script import Builder +def generate(env): + def my_copy(target, source, env): + content = open(str(source[0]), 'rb').read() + open(str(target[0]), 'wb').write(content) + env['BUILDERS']['MyCopy'] = Builder(action = my_copy) + +def exists(env): + return 1 +""") + +test.run() + +test.must_match(['build', 'src', 'file.out'], "subdir/src/file.in\n") + +# We should look for the underlying tool in both the build/src/tools +# (which doesn't exist) and subdir/src/tools (which still does). If we +# don't, the following would fail because the execution directory is +# now relative to the created BuildDir. +test.run() + +test.pass_test() diff --git a/test/toolpath.py b/test/toolpath/basic.py index 7e08f8a..7e08f8a 100644 --- a/test/toolpath.py +++ b/test/toolpath/basic.py |