From f8bb7b9fbf65402159d4822f0e0026a4ec35372d Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 27 May 2024 21:26:10 -0700 Subject: [PATCH] minimize tool initialization in tests --- test/Configure/Builder-call.py | 128 +++++----- test/Configure/CONFIGUREDIR.py | 114 ++++----- test/Configure/CONFIGURELOG.py | 136 +++++------ test/Configure/SConscript.py | 160 ++++++------- test/Configure/Streamer1.py | 170 +++++++------- test/Configure/VariantDir-SConscript.py | 10 +- test/Configure/VariantDir.py | 197 ++++++++-------- test/Configure/VariantDir2.py | 10 +- test/Configure/basic.py | 1 + test/Configure/build-fail.py | 194 +++++++-------- test/Configure/cache-not-ok.py | 204 ++++++++-------- test/Configure/cache-ok.py | 252 ++++++++++---------- test/Configure/clean.py | 168 ++++++------- test/Configure/config-h.py | 1 + test/Configure/custom-tests.py | 402 ++++++++++++++++---------------- test/Configure/from-SConscripts.py | 126 +++++----- test/Configure/help.py | 188 +++++++-------- test/Configure/implicit-cache.py | 8 +- test/Configure/option--Q.py | 104 ++++----- test/Configure/option--config.py | 13 +- 20 files changed, 1297 insertions(+), 1289 deletions(-) diff --git a/test/Configure/Builder-call.py b/test/Configure/Builder-call.py index b4c9d334d..3427fafde 100644 --- a/test/Configure/Builder-call.py +++ b/test/Configure/Builder-call.py @@ -1,64 +1,64 @@ -#!/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 calling normal Builders from an actual Configure -context environment works correctly. -""" - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.write('mycommand.py', r""" -import sys -sys.stderr.write( 'Hello World on stderr\n' ) -sys.stdout.write( 'Hello World on stdout\n' ) -with open(sys.argv[1], 'w') as f: - f.write( 'Hello World\n' ) -""") - -test.write('SConstruct', """\ -env = Environment() -def CustomTest(*args): - return 0 -conf = env.Configure(custom_tests = {'MyTest' : CustomTest}) -if not conf.MyTest(): - env.Command("hello", [], r'%(_python_)s mycommand.py $TARGET') -env = conf.Finish() -""" % locals()) - -test.run(stderr="Hello World on stderr\n") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Verify that calling normal Builders from an actual Configure +context environment works correctly. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.write('mycommand.py', r""" +import sys +sys.stderr.write( 'Hello World on stderr\n' ) +sys.stdout.write( 'Hello World on stdout\n' ) +with open(sys.argv[1], 'w') as f: + f.write( 'Hello World\n' ) +""") + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) +def CustomTest(*args): + return 0 +conf = env.Configure(custom_tests = {'MyTest' : CustomTest}) +if not conf.MyTest(): + env.Command("hello", [], r'%(_python_)s mycommand.py $TARGET') +env = conf.Finish() +""" % locals()) + +test.run(stderr="Hello World on stderr\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/Configure/CONFIGUREDIR.py b/test/Configure/CONFIGUREDIR.py index 4b5a02e0d..61d0b56e7 100644 --- a/test/Configure/CONFIGUREDIR.py +++ b/test/Configure/CONFIGUREDIR.py @@ -1,57 +1,57 @@ -#!/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 configure context directory can be specified by -setting the $CONFIGUREDIR construction variable. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write("SConstruct", """\ -def CustomTest(context): - context.Message('Executing Custom Test ... ') - context.Result(1) - -env = Environment(CONFIGUREDIR = 'custom_config_dir') -conf = Configure(env, custom_tests = {'CustomTest' : CustomTest}) -conf.CustomTest(); -env = conf.Finish() -""") - -test.run() - -test.must_exist('custom_config_dir') - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Test that the configure context directory can be specified by +setting the $CONFIGUREDIR construction variable. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write("SConstruct", """\ +DefaultEnvironment(tools=[]) +def CustomTest(context): + context.Message('Executing Custom Test ... ') + context.Result(1) + +env = Environment(tools=[], CONFIGUREDIR = 'custom_config_dir') +conf = Configure(env, custom_tests = {'CustomTest' : CustomTest}) +conf.CustomTest(); +env = conf.Finish() +""") + +test.run() + +test.must_exist('custom_config_dir') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/CONFIGURELOG.py b/test/Configure/CONFIGURELOG.py index 9b6221bee..e10a0aa2f 100644 --- a/test/Configure/CONFIGURELOG.py +++ b/test/Configure/CONFIGURELOG.py @@ -1,68 +1,68 @@ -#!/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 configure context log file name can be specified by -setting the $CONFIGURELOG construction variable. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -SConstruct_path = test.workpath('SConstruct') - -test.write(SConstruct_path, """\ -def CustomTest(context): - context.Message('Executing Custom Test ...') - context.Result(1) - -env = Environment(CONFIGURELOG = 'custom.logfile') -conf = Configure(env, custom_tests = {'CustomTest' : CustomTest}) -conf.CustomTest(); -env = conf.Finish() -""") - -test.run() - -expect = """\ -file %(SConstruct_path)s,line 6: -\tConfigure(confdir = .sconf_temp) -scons: Configure: Executing Custom Test ... -scons: Configure: (cached) yes - - -""" % locals() - -test.must_match('custom.logfile', expect, mode='r') - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Test that the configure context log file name can be specified by +setting the $CONFIGURELOG construction variable. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +SConstruct_path = test.workpath('SConstruct') + +test.write(SConstruct_path, """\ +DefaultEnvironment(tools=[]) +def CustomTest(context): + context.Message('Executing Custom Test ...') + context.Result(1) + +env = Environment(tools=[], CONFIGURELOG = 'custom.logfile') +conf = Configure(env, custom_tests = {'CustomTest' : CustomTest}) +conf.CustomTest(); +env = conf.Finish() +""") + +test.run() + +expect = """\ +file %(SConstruct_path)s,line 7: +\tConfigure(confdir = .sconf_temp) +scons: Configure: Executing Custom Test ... +scons: Configure: (cached) yes + + +""" % locals() + +test.must_match('custom.logfile', expect, mode='r') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/SConscript.py b/test/Configure/SConscript.py index 73afef766..4bca8c134 100644 --- a/test/Configure/SConscript.py +++ b/test/Configure/SConscript.py @@ -1,80 +1,80 @@ -#!/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 Configure contexts from multiple subsidiary SConscript -files work without error. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir(['dir1'], - ['dir2'], - ['dir2', 'sub1'], - ['dir2', 'sub1', 'sub2']) - -test.write('SConstruct', """\ -env = Environment() -SConscript(dirs=['dir1', 'dir2'], exports="env") -""") - -test.write(['dir1', 'SConscript'], """ -Import("env") -conf = env.Configure() -conf.Finish() -""") - -test.write(['dir2', 'SConscript'], """ -Import("env") -conf = env.Configure() -conf.Finish() -SConscript(dirs=['sub1'], exports="env") -""") - -test.write(['dir2', 'sub1', 'SConscript'], """ -Import("env") -conf = env.Configure() -conf.Finish() -SConscript(dirs=['sub2'], exports="env") -""") - -test.write(['dir2', 'sub1', 'sub2', 'SConscript'], """ -Import("env") -conf = env.Configure() -conf.Finish() -""") - -test.run() - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Verify that Configure contexts from multiple subsidiary SConscript +files work without error. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir(['dir1'], + ['dir2'], + ['dir2', 'sub1'], + ['dir2', 'sub1', 'sub2']) + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) +SConscript(dirs=['dir1', 'dir2'], exports="env") +""") + +test.write(['dir1', 'SConscript'], """ +Import("env") +conf = env.Configure() +conf.Finish() +""") + +test.write(['dir2', 'SConscript'], """ +Import("env") +conf = env.Configure() +conf.Finish() +SConscript(dirs=['sub1'], exports="env") +""") + +test.write(['dir2', 'sub1', 'SConscript'], """ +Import("env") +conf = env.Configure() +conf.Finish() +SConscript(dirs=['sub2'], exports="env") +""") + +test.write(['dir2', 'sub1', 'sub2', 'SConscript'], """ +Import("env") +conf = env.Configure() +conf.Finish() +""") + +test.run() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/Streamer1.py b/test/Configure/Streamer1.py index 318a9361d..2b29c40ad 100644 --- a/test/Configure/Streamer1.py +++ b/test/Configure/Streamer1.py @@ -1,85 +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__" - -""" -Test for BitBucket PR 126: - -SConf doesn't work well with 'io' module on pre-3.0 Python. This is because -io.StringIO (used by SCons.SConf.Streamer) accepts only unicode strings. -Non-unicode input causes it to raise an exception. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -# SConstruct -# -# The CheckHello should return 'yes' if everything works fine. Otherwise it -# returns 'failed'. -# -def hello(target, source, env): - import traceback - try: - print('hello!\\n') # this breaks the script - with open(env.subst('$TARGET', target = target),'w') as f: - f.write('yes') - except: - # write to file, as stdout/stderr is broken - traceback.print_exc(file=open('traceback','w')) - return 0 - -def CheckHello(context): - import sys - context.Display('Checking whether hello works... ') - stat,out = context.TryAction(hello,'','.in') - if stat and out: - context.Result(out) - else: - context.Result('failed') - return out - -env = Environment() -cfg = Configure(env) - -cfg.AddTest('CheckHello', CheckHello) -cfg.CheckHello() - -env = cfg.Finish() -""") - -test.run(arguments = '.') -test.must_contain_all_lines(test.stdout(), ['Checking whether hello works... yes']) -test.must_not_exist('traceback') - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Test for BitBucket PR 126: + +SConf doesn't work well with 'io' module on pre-3.0 Python. This is because +io.StringIO (used by SCons.SConf.Streamer) accepts only unicode strings. +Non-unicode input causes it to raise an exception. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +# SConstruct +# +# The CheckHello should return 'yes' if everything works fine. Otherwise it +# returns 'failed'. +# +def hello(target, source, env): + import traceback + try: + print('hello!\\n') # this breaks the script + with open(env.subst('$TARGET', target = target),'w') as f: + f.write('yes') + except: + # write to file, as stdout/stderr is broken + traceback.print_exc(file=open('traceback','w')) + return 0 + +def CheckHello(context): + import sys + context.Display('Checking whether hello works... ') + stat,out = context.TryAction(hello,'','.in') + if stat and out: + context.Result(out) + else: + context.Result('failed') + return out + +env = Environment(tools=[]) +cfg = Configure(env) + +cfg.AddTest('CheckHello', CheckHello) +cfg.CheckHello() + +env = cfg.Finish() +""") + +test.run(arguments = '.') +test.must_contain_all_lines(test.stdout(), ['Checking whether hello works... yes']) +test.must_not_exist('traceback') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/VariantDir-SConscript.py b/test/Configure/VariantDir-SConscript.py index 5818fc779..cb50d3afe 100644 --- a/test/Configure/VariantDir-SConscript.py +++ b/test/Configure/VariantDir-SConscript.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -19,10 +21,7 @@ # 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__" +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE """ Verify that Configure calls in SConscript files work when used @@ -45,6 +44,7 @@ NCF = test.NCF # non-cached build failure CF = test.CF # cached build failure test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) opts = Variables() opts.Add('chdir') env = Environment(options=opts) diff --git a/test/Configure/VariantDir.py b/test/Configure/VariantDir.py index 2c54b8440..0296d1c7f 100644 --- a/test/Configure/VariantDir.py +++ b/test/Configure/VariantDir.py @@ -1,98 +1,99 @@ -#!/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 Configure contexts work with basic use of VariantDir. -""" - -import os - -import TestSCons - -_obj = TestSCons._obj - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -NCR = test.NCR # non-cached rebuild -CR = test.CR # cached rebuild (up to date) -NCF = test.NCF # non-cached build failure -CF = test.CF # cached build failure - -test.write('SConstruct', """\ -env = Environment(LOGFILE='build/config.log') -import os -env.AppendENVPath('PATH', os.environ['PATH']) -VariantDir('build', '.') -conf = env.Configure(conf_dir='build/config.tests', log_file='$LOGFILE') -r1 = conf.CheckCHeader('math.h') -r2 = conf.CheckCHeader('no_std_c_header.h') # leads to compile error -env = conf.Finish() -Export('env') -# with open('build/config.log') as f: -# print f.readlines() -SConscript('build/SConscript') -""") - -test.write('SConscript', """\ -Import('env') -env.Program('TestProgram', 'TestProgram.c') -""") - -test.write('TestProgram.c', """\ -#include - -int main(void) { - printf("Hello\\n"); -} -""") - -test.run() -test.checkLogAndStdout(["Checking for C header file math.h... ", - "Checking for C header file no_std_c_header.h... "], - ["yes", "no"], - [[((".c", NCR), (_obj, NCR))], - [((".c", NCR), (_obj, NCF))]], - os.path.join("build", "config.log"), - os.path.join("build", "config.tests"), - "SConstruct") - -test.run() -test.checkLogAndStdout(["Checking for C header file math.h... ", - "Checking for C header file no_std_c_header.h... "], - ["yes", "no"], - [[((".c", CR), (_obj, CR))], - [((".c", CR), (_obj, CF))]], - os.path.join("build", "config.log"), - os.path.join("build", "config.tests"), - "SConstruct") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Verify that Configure contexts work with basic use of VariantDir. +""" + +import os + +import TestSCons + +_obj = TestSCons._obj + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +NCR = test.NCR # non-cached rebuild +CR = test.CR # cached rebuild (up to date) +NCF = test.NCF # non-cached build failure +CF = test.CF # cached build failure + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) + +env = Environment(LOGFILE='build/config.log') +import os +env.AppendENVPath('PATH', os.environ['PATH']) +VariantDir('build', '.') +conf = env.Configure(conf_dir='build/config.tests', log_file='$LOGFILE') +r1 = conf.CheckCHeader('math.h') +r2 = conf.CheckCHeader('no_std_c_header.h') # leads to compile error +env = conf.Finish() +Export('env') +# with open('build/config.log') as f: +# print f.readlines() +SConscript('build/SConscript') +""") + +test.write('SConscript', """\ +Import('env') +env.Program('TestProgram', 'TestProgram.c') +""") + +test.write('TestProgram.c', """\ +#include + +int main(void) { + printf("Hello\\n"); +} +""") + +test.run() +test.checkLogAndStdout(["Checking for C header file math.h... ", + "Checking for C header file no_std_c_header.h... "], + ["yes", "no"], + [[((".c", NCR), (_obj, NCR))], + [((".c", NCR), (_obj, NCF))]], + os.path.join("build", "config.log"), + os.path.join("build", "config.tests"), + "SConstruct") + +test.run() +test.checkLogAndStdout(["Checking for C header file math.h... ", + "Checking for C header file no_std_c_header.h... "], + ["yes", "no"], + [[((".c", CR), (_obj, CR))], + [((".c", CR), (_obj, CF))]], + os.path.join("build", "config.log"), + os.path.join("build", "config.tests"), + "SConstruct") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/VariantDir2.py b/test/Configure/VariantDir2.py index 98f4ccde8..e640fac3c 100644 --- a/test/Configure/VariantDir2.py +++ b/test/Configure/VariantDir2.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -19,10 +21,7 @@ # 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__" +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE """ Verify that Configure contexts work with SConstruct/SConscript structure @@ -34,6 +33,7 @@ import TestSCons test = TestSCons.TestSCons() test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) SConscript('SConscript', variant_dir='build', src='.') """) diff --git a/test/Configure/basic.py b/test/Configure/basic.py index b68890e17..d2f7111d8 100644 --- a/test/Configure/basic.py +++ b/test/Configure/basic.py @@ -39,6 +39,7 @@ NCF = test.NCF # non-cached build failure CF = test.CF # cached build failure test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) env = Environment() import os env.AppendENVPath('PATH', os.environ['PATH']) diff --git a/test/Configure/build-fail.py b/test/Configure/build-fail.py index 218cf1807..b835cb741 100644 --- a/test/Configure/build-fail.py +++ b/test/Configure/build-fail.py @@ -1,97 +1,97 @@ -#!/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 Configure tests work even after an earlier test fails. - -This was broken in 0.98.3 because we'd mark the /usr/bin/g++ compiler -as having failed (because it was on the candidates list as the implicit -command dependency for both the object file and executable generated -for the configuration test) and then avoid trying to rebuild anything -else that used the "failed" Node. - -Thanks to Ben Webb for the test case. -""" - -import os -import re - -import TestSCons - -_obj = TestSCons._obj - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.subdir('a', 'b') - -a_boost_hpp = os.path.join('..', 'a', 'boost.hpp') -b_boost_hpp = os.path.join('..', 'b', 'boost.hpp') - -test.write('SConstruct', """\ -import os -def _check(context): - for dir in ['a', 'b']: - inc = os.path.join('..', dir, 'boost.hpp') - result = context.TryRun(''' - #include "%s" - - int main(void) { return 0; } - ''' % inc, '.cpp')[0] - if result: - import sys - sys.stdout.write('%s: ' % inc) - break - context.Result(result) - return result -env = Environment() -conf = env.Configure(custom_tests={'CheckBoost':_check}) -conf.CheckBoost() -conf.Finish() -""") - -test.write(['b', 'boost.hpp'], """#define FILE "b/boost.hpp"\n""") - -expect = test.wrap_stdout(read_str = "%s: yes\n" % re.escape(b_boost_hpp), - build_str = "scons: `.' is up to date.\n") - -test.run(arguments='--config=force', stdout=expect) - -expect = test.wrap_stdout(read_str = "%s: yes\n" % re.escape(a_boost_hpp), - build_str = "scons: `.' is up to date.\n") - -test.write(['a', 'boost.hpp'], """#define FILE "a/boost.hpp"\n""") - -test.run(arguments='--config=force', stdout=expect) - -test.run() - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Verify that Configure tests work even after an earlier test fails. + +This was broken in 0.98.3 because we'd mark the /usr/bin/g++ compiler +as having failed (because it was on the candidates list as the implicit +command dependency for both the object file and executable generated +for the configuration test) and then avoid trying to rebuild anything +else that used the "failed" Node. + +Thanks to Ben Webb for the test case. +""" + +import os +import re + +import TestSCons + +_obj = TestSCons._obj + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.subdir('a', 'b') + +a_boost_hpp = os.path.join('..', 'a', 'boost.hpp') +b_boost_hpp = os.path.join('..', 'b', 'boost.hpp') + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +import os +def _check(context): + for dir in ['a', 'b']: + inc = os.path.join('..', dir, 'boost.hpp') + result = context.TryRun(''' + #include "%s" + + int main(void) { return 0; } + ''' % inc, '.cpp')[0] + if result: + import sys + sys.stdout.write('%s: ' % inc) + break + context.Result(result) + return result +env = Environment() +conf = env.Configure(custom_tests={'CheckBoost':_check}) +conf.CheckBoost() +conf.Finish() +""") + +test.write(['b', 'boost.hpp'], """#define FILE "b/boost.hpp"\n""") + +expect = test.wrap_stdout(read_str = "%s: yes\n" % re.escape(b_boost_hpp), + build_str = "scons: `.' is up to date.\n") + +test.run(arguments='--config=force', stdout=expect) + +expect = test.wrap_stdout(read_str = "%s: yes\n" % re.escape(a_boost_hpp), + build_str = "scons: `.' is up to date.\n") + +test.write(['a', 'boost.hpp'], """#define FILE "a/boost.hpp"\n""") + +test.run(arguments='--config=force', stdout=expect) + +test.run() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/cache-not-ok.py b/test/Configure/cache-not-ok.py index 7502f7a25..094499644 100644 --- a/test/Configure/cache-not-ok.py +++ b/test/Configure/cache-not-ok.py @@ -1,102 +1,102 @@ -#!/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 cache mechanism works when checks are not ok. -""" - -import TestSCons - -_exe = TestSCons._exe -_obj = TestSCons._obj - -test = TestSCons.TestSCons() - -lib = test.Configure_lib - -NCR = test.NCR # non-cached rebuild -CR = test.CR # cached rebuild (up to date) -NCF = test.NCF # non-cached build failure -CF = test.CF # cached build failure - -test.write('SConstruct', """\ -if not int(ARGUMENTS.get('target_signatures_content', 0)): - Decider('timestamp-newer') -env = Environment() -import os -env.AppendENVPath('PATH', os.environ['PATH']) -conf = env.Configure() -r1 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error -r2 = conf.CheckLib( 'no_c_library_SAFFDG' ) # leads to link error -env = conf.Finish() -if not (not r1 and not r2): - print("FAIL: ", r1, r2) - Exit(1) -""") - -# Verify correct behavior when we call Decider('timestamp-newer'). - -test.run() -test.checkLogAndStdout(["Checking for C header file no_std_c_header.h... ", - "Checking for C library no_c_library_SAFFDG... "], - ["no"]*2, - [[((".c", NCR), (_obj, NCF))], - [((".c", NCR), (_obj, NCR), (_exe, NCF))]], - "config.log", ".sconf_temp", "SConstruct") - -test.run() -test.checkLogAndStdout(["Checking for C header file no_std_c_header.h... ", - "Checking for C library no_c_library_SAFFDG... "], - ["no"]*2, - [[((".c", CR), (_obj, NCF))], - [((".c", CR), (_obj, CR), (_exe, NCF))]], - "config.log", ".sconf_temp", "SConstruct") - -# Same should be true for the default behavior of Decider('content'). - -test.run(arguments='target_signatures_content=1 --config=force') -test.checkLogAndStdout(["Checking for C header file no_std_c_header.h... ", - "Checking for C library no_c_library_SAFFDG... "], - ["no"]*2, - [[((".c", NCR), (_obj, NCF))], - [((".c", NCR), (_obj, NCR), (_exe, NCF))]], - "config.log", ".sconf_temp", "SConstruct") - -test.run(arguments='target_signatures_content=1') -test.checkLogAndStdout(["Checking for C header file no_std_c_header.h... ", - "Checking for C library no_c_library_SAFFDG... "], - ["no"]*2, - [[((".c", CR), (_obj, CF))], - [((".c", CR), (_obj, CR), (_exe, CF))]], - "config.log", ".sconf_temp", "SConstruct") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Verify that the cache mechanism works when checks are not ok. +""" + +import TestSCons + +_exe = TestSCons._exe +_obj = TestSCons._obj + +test = TestSCons.TestSCons() + +lib = test.Configure_lib + +NCR = test.NCR # non-cached rebuild +CR = test.CR # cached rebuild (up to date) +NCF = test.NCF # non-cached build failure +CF = test.CF # cached build failure + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +if not int(ARGUMENTS.get('target_signatures_content', 0)): + Decider('timestamp-newer') +env = Environment() +import os +env.AppendENVPath('PATH', os.environ['PATH']) +conf = env.Configure() +r1 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error +r2 = conf.CheckLib( 'no_c_library_SAFFDG' ) # leads to link error +env = conf.Finish() +if not (not r1 and not r2): + print("FAIL: ", r1, r2) + Exit(1) +""") + +# Verify correct behavior when we call Decider('timestamp-newer'). + +test.run() +test.checkLogAndStdout(["Checking for C header file no_std_c_header.h... ", + "Checking for C library no_c_library_SAFFDG... "], + ["no"]*2, + [[((".c", NCR), (_obj, NCF))], + [((".c", NCR), (_obj, NCR), (_exe, NCF))]], + "config.log", ".sconf_temp", "SConstruct") + +test.run() +test.checkLogAndStdout(["Checking for C header file no_std_c_header.h... ", + "Checking for C library no_c_library_SAFFDG... "], + ["no"]*2, + [[((".c", CR), (_obj, NCF))], + [((".c", CR), (_obj, CR), (_exe, NCF))]], + "config.log", ".sconf_temp", "SConstruct") + +# Same should be true for the default behavior of Decider('content'). + +test.run(arguments='target_signatures_content=1 --config=force') +test.checkLogAndStdout(["Checking for C header file no_std_c_header.h... ", + "Checking for C library no_c_library_SAFFDG... "], + ["no"]*2, + [[((".c", NCR), (_obj, NCF))], + [((".c", NCR), (_obj, NCR), (_exe, NCF))]], + "config.log", ".sconf_temp", "SConstruct") + +test.run(arguments='target_signatures_content=1') +test.checkLogAndStdout(["Checking for C header file no_std_c_header.h... ", + "Checking for C library no_c_library_SAFFDG... "], + ["no"]*2, + [[((".c", CR), (_obj, CF))], + [((".c", CR), (_obj, CR), (_exe, CF))]], + "config.log", ".sconf_temp", "SConstruct") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/cache-ok.py b/test/Configure/cache-ok.py index 93d1308fb..dc2d0c32b 100644 --- a/test/Configure/cache-ok.py +++ b/test/Configure/cache-ok.py @@ -1,126 +1,126 @@ -#!/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 cache mechanism works when checks are ok. -""" - -import TestSCons - -_exe = TestSCons._exe -_obj = TestSCons._obj - -test = TestSCons.TestSCons(match = TestSCons.match_re) - -lib = test.Configure_lib - -NCR = test.NCR # non-cached rebuild -CR = test.CR # cached rebuild (up to date) -NCF = test.NCF # non-cached build failure -CF = test.CF # cached build failure - -test.write('SConstruct', """\ -if not int(ARGUMENTS.get('target_signatures_content', 0)): - Decider('timestamp-newer') -env = Environment() -import os -env.AppendENVPath('PATH', os.environ['PATH']) -conf = Configure(env) -r1 = conf.CheckLibWithHeader( '%(lib)s', 'math.h', 'c' ) -r2 = conf.CheckLibWithHeader( None, 'math.h', 'c' ) -r3 = conf.CheckLib( '%(lib)s', autoadd=0 ) -r4 = conf.CheckLib( None, autoadd=0 ) -r5 = conf.CheckCHeader( 'math.h' ) -r6 = conf.CheckCXXHeader( 'vector' ) -env = conf.Finish() -if not (r1 and r2 and r3 and r4 and r5 and r6): - Exit(1) -""" % locals()) - -# Verify correct behavior when we call Decider('timestamp-newer') - -test.run() -test.checkLogAndStdout(["Checking for C library %s... " % lib, - "Checking for C library None... ", - "Checking for C library %s... " % lib, - "Checking for C library None... ", - "Checking for C header file math.h... ", - "Checking for C++ header file vector... "], - ["yes"]*6, - [[((".c", NCR), (_obj, NCR), (_exe, NCR))]]*4 + - [[((".c", NCR), (_obj, NCR))]] + - [[((".cpp", NCR), (_obj, NCR))]], - "config.log", ".sconf_temp", "SConstruct") - - -test.run() -test.checkLogAndStdout(["Checking for C library %s... " % lib, - "Checking for C library None... ", - "Checking for C library %s... " % lib, - "Checking for C library None... ", - "Checking for C header file math.h... ", - "Checking for C++ header file vector... "], - ["yes"]*6, - [[((".c", CR), (_obj, CR), (_exe, CR))]]*4 + - [[((".c", CR), (_obj, CR))]] + - [[((".cpp", CR), (_obj, CR))]], - "config.log", ".sconf_temp", "SConstruct") - -# same should be true for the default behavior of Decider('content') - -test.run(arguments='target_signatures_content=1 --config=force') -test.checkLogAndStdout(["Checking for C library %s... " % lib, - "Checking for C library None... ", - "Checking for C library %s... " % lib, - "Checking for C library None... ", - "Checking for C header file math.h... ", - "Checking for C++ header file vector... "], - ["yes"]*6, - [[((".c", NCR), (_obj, NCR), (_exe, NCR))]]*4 + - [[((".c", NCR), (_obj, NCR))]] + - [[((".cpp", NCR), (_obj, NCR))]], - "config.log", ".sconf_temp", "SConstruct") - -test.run(arguments='target_signatures_content=1') -test.checkLogAndStdout(["Checking for C library %s... " % lib, - "Checking for C library None... ", - "Checking for C library %s... " % lib, - "Checking for C library None... ", - "Checking for C header file math.h... ", - "Checking for C++ header file vector... "], - ["yes"]*6, - [[((".c", CR), (_obj, CR), (_exe, CR))]]*4 + - [[((".c", CR), (_obj, CR))]] + - [[((".cpp", CR), (_obj, CR))]], - "config.log", ".sconf_temp", "SConstruct") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Verify that the cache mechanism works when checks are ok. +""" + +import TestSCons + +_exe = TestSCons._exe +_obj = TestSCons._obj + +test = TestSCons.TestSCons(match = TestSCons.match_re) + +lib = test.Configure_lib + +NCR = test.NCR # non-cached rebuild +CR = test.CR # cached rebuild (up to date) +NCF = test.NCF # non-cached build failure +CF = test.CF # cached build failure + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +if not int(ARGUMENTS.get('target_signatures_content', 0)): + Decider('timestamp-newer') +env = Environment() +import os +env.AppendENVPath('PATH', os.environ['PATH']) +conf = Configure(env) +r1 = conf.CheckLibWithHeader( '%(lib)s', 'math.h', 'c' ) +r2 = conf.CheckLibWithHeader( None, 'math.h', 'c' ) +r3 = conf.CheckLib( '%(lib)s', autoadd=0 ) +r4 = conf.CheckLib( None, autoadd=0 ) +r5 = conf.CheckCHeader( 'math.h' ) +r6 = conf.CheckCXXHeader( 'vector' ) +env = conf.Finish() +if not (r1 and r2 and r3 and r4 and r5 and r6): + Exit(1) +""" % locals()) + +# Verify correct behavior when we call Decider('timestamp-newer') + +test.run() +test.checkLogAndStdout(["Checking for C library %s... " % lib, + "Checking for C library None... ", + "Checking for C library %s... " % lib, + "Checking for C library None... ", + "Checking for C header file math.h... ", + "Checking for C++ header file vector... "], + ["yes"]*6, + [[((".c", NCR), (_obj, NCR), (_exe, NCR))]]*4 + + [[((".c", NCR), (_obj, NCR))]] + + [[((".cpp", NCR), (_obj, NCR))]], + "config.log", ".sconf_temp", "SConstruct") + + +test.run() +test.checkLogAndStdout(["Checking for C library %s... " % lib, + "Checking for C library None... ", + "Checking for C library %s... " % lib, + "Checking for C library None... ", + "Checking for C header file math.h... ", + "Checking for C++ header file vector... "], + ["yes"]*6, + [[((".c", CR), (_obj, CR), (_exe, CR))]]*4 + + [[((".c", CR), (_obj, CR))]] + + [[((".cpp", CR), (_obj, CR))]], + "config.log", ".sconf_temp", "SConstruct") + +# same should be true for the default behavior of Decider('content') + +test.run(arguments='target_signatures_content=1 --config=force') +test.checkLogAndStdout(["Checking for C library %s... " % lib, + "Checking for C library None... ", + "Checking for C library %s... " % lib, + "Checking for C library None... ", + "Checking for C header file math.h... ", + "Checking for C++ header file vector... "], + ["yes"]*6, + [[((".c", NCR), (_obj, NCR), (_exe, NCR))]]*4 + + [[((".c", NCR), (_obj, NCR))]] + + [[((".cpp", NCR), (_obj, NCR))]], + "config.log", ".sconf_temp", "SConstruct") + +test.run(arguments='target_signatures_content=1') +test.checkLogAndStdout(["Checking for C library %s... " % lib, + "Checking for C library None... ", + "Checking for C library %s... " % lib, + "Checking for C library None... ", + "Checking for C header file math.h... ", + "Checking for C++ header file vector... "], + ["yes"]*6, + [[((".c", CR), (_obj, CR), (_exe, CR))]]*4 + + [[((".c", CR), (_obj, CR))]] + + [[((".cpp", CR), (_obj, CR))]], + "config.log", ".sconf_temp", "SConstruct") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/clean.py b/test/Configure/clean.py index d7a5dc7b5..3370cd251 100644 --- a/test/Configure/clean.py +++ b/test/Configure/clean.py @@ -1,84 +1,84 @@ -#!/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 perform Configure context actions when the --c or --clean options have been specified. -""" - -import TestSCons - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConstruct', """\ -env = Environment() -import os -env.AppendENVPath('PATH', os.environ['PATH']) -conf = Configure(env, clean=int(ARGUMENTS['clean'])) -r1 = conf.CheckCHeader( 'math.h' ) -r2 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error -env = conf.Finish() -Export( 'env' ) -SConscript( 'SConscript' ) -""") - -test.write('SConscript', """\ -Import( 'env' ) -env.Program( 'TestProgram', 'TestProgram.c' ) -""") - -test.write('TestProgram.c', """\ -#include - -int main(void) { - printf( "Hello\\n" ); -} -""") - -lines = [ - "Checking for C header file math.h... ", - "Checking for C header file no_std_c_header.h... " -] - -test.run(arguments = '-c clean=0') -test.must_not_contain_any_line(test.stdout(), lines) - -test.run(arguments = '-c clean=1') -test.must_contain_all_lines(test.stdout(), lines) - -test.run(arguments = '--clean clean=0') -test.must_not_contain_any_line(test.stdout(), lines) - -test.run(arguments = '--clean clean=1') -test.must_contain_all_lines(test.stdout(), lines) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Verify that we don't perform Configure context actions when the +-c or --clean options have been specified. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment() +import os +env.AppendENVPath('PATH', os.environ['PATH']) +conf = Configure(env, clean=int(ARGUMENTS['clean'])) +r1 = conf.CheckCHeader( 'math.h' ) +r2 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error +env = conf.Finish() +Export( 'env' ) +SConscript( 'SConscript' ) +""") + +test.write('SConscript', """\ +Import( 'env' ) +env.Program( 'TestProgram', 'TestProgram.c' ) +""") + +test.write('TestProgram.c', """\ +#include + +int main(void) { + printf( "Hello\\n" ); +} +""") + +lines = [ + "Checking for C header file math.h... ", + "Checking for C header file no_std_c_header.h... " +] + +test.run(arguments = '-c clean=0') +test.must_not_contain_any_line(test.stdout(), lines) + +test.run(arguments = '-c clean=1') +test.must_contain_all_lines(test.stdout(), lines) + +test.run(arguments = '--clean clean=0') +test.must_not_contain_any_line(test.stdout(), lines) + +test.run(arguments = '--clean clean=1') +test.must_contain_all_lines(test.stdout(), lines) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/config-h.py b/test/Configure/config-h.py index aca18e42a..221e3bd20 100644 --- a/test/Configure/config-h.py +++ b/test/Configure/config-h.py @@ -37,6 +37,7 @@ lib = test.Configure_lib LIB = "LIB" + lib.upper() test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) env = Environment() import os env.AppendENVPath('PATH', os.environ['PATH']) diff --git a/test/Configure/custom-tests.py b/test/Configure/custom-tests.py index 47b344aff..a4c29c78e 100644 --- a/test/Configure/custom-tests.py +++ b/test/Configure/custom-tests.py @@ -1,200 +1,202 @@ -#!/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. - -""" -Verify execution of custom test cases. -""" - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import TestSCons - -_exe = TestSCons._exe -_obj = TestSCons._obj -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -NCR = test.NCR # non-cached rebuild -CR = test.CR # cached rebuild (up to date) -NCF = test.NCF # non-cached build failure -CF = test.CF # cached build failure - -compileOK = '#include \\nint main(void) {printf("Hello");return 0;}' -compileFAIL = "syntax error" -linkOK = compileOK -linkFAIL = "void myFunc(); int main(void) { myFunc(); }" -runOK = compileOK -runFAIL = "int main(void) { return 1; }" - -test.write('pyAct.py', """\ -import sys -print(sys.argv[1]) -sys.exit(int(sys.argv[1])) -""") - -test.write('SConstruct', """\ -def CheckCustom(test): - test.Message( 'Executing MyTest ... ' ) - retCompileOK = test.TryCompile( '%(compileOK)s', '.c' ) - retCompileFAIL = test.TryCompile( '%(compileFAIL)s', '.c' ) - retLinkOK = test.TryLink( '%(linkOK)s', '.c' ) - retLinkFAIL = test.TryLink( '%(linkFAIL)s', '.c' ) - (retRunOK, outputRunOK) = test.TryRun( '%(runOK)s', '.c' ) - (retRunFAIL, outputRunFAIL) = test.TryRun( '%(runFAIL)s', '.c' ) - (retActOK, outputActOK) = test.TryAction( r'%(_python_)s pyAct.py 0 > $TARGET' ) - (retActFAIL, outputActFAIL) = test.TryAction( r'%(_python_)s pyAct.py 1 > $TARGET' ) - resOK = retCompileOK and retLinkOK and retRunOK and outputRunOK=="Hello" - resOK = resOK and retActOK and int(outputActOK)==0 - resFAIL = retCompileFAIL or retLinkFAIL or retRunFAIL or outputRunFAIL!="" - resFAIL = resFAIL or retActFAIL or outputActFAIL!="" - test.Result( resOK and not resFAIL ) - return resOK and not resFAIL - -env = Environment() -import os -env.AppendENVPath('PATH', os.environ['PATH']) -conf = Configure( env, custom_tests={'CheckCustom' : CheckCustom} ) -conf.CheckCustom() -env = conf.Finish() -""" % locals()) - -test.run() - -test.checkLogAndStdout(["Executing MyTest ... "], - ["yes"], - [[(('.c', NCR), (_obj, NCR)), - (('.c', NCR), (_obj, NCF)), - (('.c', NCR), (_obj, NCR), (_exe, NCR)), - (('.c', NCR), (_obj, NCR), (_exe, NCF)), - (('.c', NCR), (_obj, NCR), (_exe, NCR), (_exe + '.out', NCR)), - (('.c', NCR), (_obj, NCR), (_exe, NCR), (_exe + '.out', NCF)), - (('', NCR),), - (('', NCF),)]], - "config.log", ".sconf_temp", "SConstruct") - -test.run() - -# Try again to check caching -test.checkLogAndStdout(["Executing MyTest ... "], - ["yes"], - [[(('.c', CR), (_obj, CR)), - (('.c', CR), (_obj, CF)), - (('.c', CR), (_obj, CR), (_exe, CR)), - (('.c', CR), (_obj, CR), (_exe, CF)), - (('.c', CR), (_obj, CR), (_exe, CR), (_exe + '.out', CR)), - (('.c', CR), (_obj, CR), (_exe, CR), (_exe + '.out', CF)), - (('', CR),), - (('', CF),)]], - "config.log", ".sconf_temp", "SConstruct") - -# Test other customs: -test.write('SConstruct', """\ -def CheckList(test): - test.Message( 'Display of list ...' ) - res = [1, 2, 3, 4] - test.Result( res ) - return res - -def CheckEmptyList(test): - test.Message( 'Display of empty list ...' ) - res = list() - test.Result( res ) - return res - -def CheckRandomStr(test): - test.Message( 'Display of random string ...' ) - res = "a random string" - test.Result( res ) - return res - -def CheckEmptyStr(test): - test.Message( 'Display of empty string ...' ) - res = "" - test.Result( res ) - return res - -def CheckDict(test): - test.Message( 'Display of dictionary ...' ) - res = {"key1" : 1, "key2" : "text"} - test.Result( res ) - return res - -def CheckEmptyDict(test): - test.Message( 'Display of empty dictionary ...' ) - res = dict - test.Result( res ) - return res - -env = Environment() -import os -env.AppendENVPath('PATH', os.environ['PATH']) -conf = Configure( env, custom_tests={'CheckList' : CheckList, - 'CheckEmptyList' : CheckEmptyList, - 'CheckRandomStr' : CheckRandomStr, - 'CheckEmptyStr' : CheckEmptyStr, - 'CheckDict' : CheckDict, - 'CheckEmptyDict' : CheckEmptyDict} ) -conf.CheckList() -conf.CheckEmptyList() -conf.CheckRandomStr() -conf.CheckEmptyStr() -conf.CheckDict() -conf.CheckEmptyDict() -env = conf.Finish() -""" % locals()) - -test.run() - -test.must_match('config.log', -r""".* -.* -scons: Configure: Display of list ... -scons: Configure: \(cached\) yes - -scons: Configure: Display of empty list ... -scons: Configure: \(cached\) no - -scons: Configure: Display of random string ... -scons: Configure: \(cached\) a random string - -scons: Configure: Display of empty string ... -scons: Configure: \(cached\) * - -scons: Configure: Display of dictionary ... -scons: Configure: \(cached\) yes - -scons: Configure: Display of empty dictionary ... -scons: Configure: \(cached\) yes - - -""", -match=TestSCons.match_re) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Verify execution of custom test cases. +""" + + +import TestSCons + +_exe = TestSCons._exe +_obj = TestSCons._obj +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +NCR = test.NCR # non-cached rebuild +CR = test.CR # cached rebuild (up to date) +NCF = test.NCF # non-cached build failure +CF = test.CF # cached build failure + +compileOK = '#include \\nint main(void) {printf("Hello");return 0;}' +compileFAIL = "syntax error" +linkOK = compileOK +linkFAIL = "void myFunc(); int main(void) { myFunc(); }" +runOK = compileOK +runFAIL = "int main(void) { return 1; }" + +test.write('pyAct.py', """\ +import sys +print(sys.argv[1]) +sys.exit(int(sys.argv[1])) +""") + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +def CheckCustom(test): + test.Message( 'Executing MyTest ... ' ) + retCompileOK = test.TryCompile( '%(compileOK)s', '.c' ) + retCompileFAIL = test.TryCompile( '%(compileFAIL)s', '.c' ) + retLinkOK = test.TryLink( '%(linkOK)s', '.c' ) + retLinkFAIL = test.TryLink( '%(linkFAIL)s', '.c' ) + (retRunOK, outputRunOK) = test.TryRun( '%(runOK)s', '.c' ) + (retRunFAIL, outputRunFAIL) = test.TryRun( '%(runFAIL)s', '.c' ) + (retActOK, outputActOK) = test.TryAction( r'%(_python_)s pyAct.py 0 > $TARGET' ) + (retActFAIL, outputActFAIL) = test.TryAction( r'%(_python_)s pyAct.py 1 > $TARGET' ) + resOK = retCompileOK and retLinkOK and retRunOK and outputRunOK=="Hello" + resOK = resOK and retActOK and int(outputActOK)==0 + resFAIL = retCompileFAIL or retLinkFAIL or retRunFAIL or outputRunFAIL!="" + resFAIL = resFAIL or retActFAIL or outputActFAIL!="" + test.Result( resOK and not resFAIL ) + return resOK and not resFAIL + +env = Environment() +import os +env.AppendENVPath('PATH', os.environ['PATH']) +conf = Configure( env, custom_tests={'CheckCustom' : CheckCustom} ) +conf.CheckCustom() +env = conf.Finish() +""" % locals()) + +test.run() + +test.checkLogAndStdout(["Executing MyTest ... "], + ["yes"], + [[(('.c', NCR), (_obj, NCR)), + (('.c', NCR), (_obj, NCF)), + (('.c', NCR), (_obj, NCR), (_exe, NCR)), + (('.c', NCR), (_obj, NCR), (_exe, NCF)), + (('.c', NCR), (_obj, NCR), (_exe, NCR), (_exe + '.out', NCR)), + (('.c', NCR), (_obj, NCR), (_exe, NCR), (_exe + '.out', NCF)), + (('', NCR),), + (('', NCF),)]], + "config.log", ".sconf_temp", "SConstruct") + +test.run() + +# Try again to check caching +test.checkLogAndStdout(["Executing MyTest ... "], + ["yes"], + [[(('.c', CR), (_obj, CR)), + (('.c', CR), (_obj, CF)), + (('.c', CR), (_obj, CR), (_exe, CR)), + (('.c', CR), (_obj, CR), (_exe, CF)), + (('.c', CR), (_obj, CR), (_exe, CR), (_exe + '.out', CR)), + (('.c', CR), (_obj, CR), (_exe, CR), (_exe + '.out', CF)), + (('', CR),), + (('', CF),)]], + "config.log", ".sconf_temp", "SConstruct") + +# Test other customs: +test.write('SConstruct', """\ +def CheckList(test): + test.Message( 'Display of list ...' ) + res = [1, 2, 3, 4] + test.Result( res ) + return res + +def CheckEmptyList(test): + test.Message( 'Display of empty list ...' ) + res = list() + test.Result( res ) + return res + +def CheckRandomStr(test): + test.Message( 'Display of random string ...' ) + res = "a random string" + test.Result( res ) + return res + +def CheckEmptyStr(test): + test.Message( 'Display of empty string ...' ) + res = "" + test.Result( res ) + return res + +def CheckDict(test): + test.Message( 'Display of dictionary ...' ) + res = {"key1" : 1, "key2" : "text"} + test.Result( res ) + return res + +def CheckEmptyDict(test): + test.Message( 'Display of empty dictionary ...' ) + res = dict + test.Result( res ) + return res + +env = Environment() +import os +env.AppendENVPath('PATH', os.environ['PATH']) +conf = Configure( env, custom_tests={'CheckList' : CheckList, + 'CheckEmptyList' : CheckEmptyList, + 'CheckRandomStr' : CheckRandomStr, + 'CheckEmptyStr' : CheckEmptyStr, + 'CheckDict' : CheckDict, + 'CheckEmptyDict' : CheckEmptyDict} ) +conf.CheckList() +conf.CheckEmptyList() +conf.CheckRandomStr() +conf.CheckEmptyStr() +conf.CheckDict() +conf.CheckEmptyDict() +env = conf.Finish() +""" % locals()) + +test.run() + +test.must_match('config.log', +r""".* +.* +scons: Configure: Display of list ... +scons: Configure: \(cached\) yes + +scons: Configure: Display of empty list ... +scons: Configure: \(cached\) no + +scons: Configure: Display of random string ... +scons: Configure: \(cached\) a random string + +scons: Configure: Display of empty string ... +scons: Configure: \(cached\) * + +scons: Configure: Display of dictionary ... +scons: Configure: \(cached\) yes + +scons: Configure: Display of empty dictionary ... +scons: Configure: \(cached\) yes + + +""", +match=TestSCons.match_re) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/from-SConscripts.py b/test/Configure/from-SConscripts.py index 59eba535b..5d16592be 100644 --- a/test/Configure/from-SConscripts.py +++ b/test/Configure/from-SConscripts.py @@ -1,63 +1,63 @@ -#!/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 we can call Configure() from subsidiary SConscript calls. - -This was broken at one point when we were using the internal -sconscript_reading flag (which is basically a hint for whether or not -we're in a Builder call) as a semaphore, not a counter. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -env = SConscript('x.scons') -""") - -test.write('x.scons', """\ -env = SConscript('y.scons') -config = env.Configure() -env = config.Finish() -Return('env') -""") - -test.write('y.scons', """\ -env = Environment() -Return('env') -""") - -test.run(arguments = '.') - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Make sure we can call Configure() from subsidiary SConscript calls. + +This was broken at one point when we were using the internal +sconscript_reading flag (which is basically a hint for whether or not +we're in a Builder call) as a semaphore, not a counter. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = SConscript('x.scons') +""") + +test.write('x.scons', """\ +env = SConscript('y.scons') +config = env.Configure() +env = config.Finish() +Return('env') +""") + +test.write('y.scons', """\ +env = Environment(tools=[]) +Return('env') +""") + +test.run(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/Configure/help.py b/test/Configure/help.py index 32f74dac4..abe446d13 100644 --- a/test/Configure/help.py +++ b/test/Configure/help.py @@ -1,94 +1,94 @@ -#!/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 perform Configure context actions when the --H, -h or --help options have been specified. -""" - -import TestSCons - -test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) - -test.write('SConstruct', """\ -env = Environment() -import os -env.AppendENVPath('PATH', os.environ['PATH']) -conf = Configure(env, help=int(ARGUMENTS['help'])) -r1 = conf.CheckCHeader( 'math.h' ) -r2 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error -env = conf.Finish() -Export( 'env' ) -SConscript( 'SConscript' ) -""") - -test.write('SConscript', """\ -Import( 'env' ) -env.Program( 'TestProgram', 'TestProgram.c' ) -""") - -test.write('TestProgram.c', """\ -#include - -int main(void) { - printf( "Hello\\n" ); -} -""") - -lines = [ - "Checking for C header file math.h... ", - "Checking for C header file no_std_c_header.h... " -] - -# The help setting should have no effect on -H, so the -H output -# should never contain the lines. -test.run(arguments = '-H help=0') -test.must_not_contain_any_line(test.stdout(), lines) - -test.run(arguments = '-H help=1') -test.must_not_contain_any_line(test.stdout(), lines) - -# For -h and --help, the lines appear or not depending on how Configure() -# is initialized. -test.run(arguments = '-h help=0') -test.must_not_contain_any_line(test.stdout(), lines) - -test.run(arguments = '-h help=1') -test.must_contain_all_lines(test.stdout(), lines) - -test.run(arguments = '--help help=0') -test.must_not_contain_any_line(test.stdout(), lines) - -test.run(arguments = '--help help=1') -test.must_contain_all_lines(test.stdout(), lines) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Verify that we don't perform Configure context actions when the +-H, -h or --help options have been specified. +""" + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment() +import os +env.AppendENVPath('PATH', os.environ['PATH']) +conf = Configure(env, help=int(ARGUMENTS['help'])) +r1 = conf.CheckCHeader( 'math.h' ) +r2 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error +env = conf.Finish() +Export( 'env' ) +SConscript( 'SConscript' ) +""") + +test.write('SConscript', """\ +Import( 'env' ) +env.Program( 'TestProgram', 'TestProgram.c' ) +""") + +test.write('TestProgram.c', """\ +#include + +int main(void) { + printf( "Hello\\n" ); +} +""") + +lines = [ + "Checking for C header file math.h... ", + "Checking for C header file no_std_c_header.h... " +] + +# The help setting should have no effect on -H, so the -H output +# should never contain the lines. +test.run(arguments = '-H help=0') +test.must_not_contain_any_line(test.stdout(), lines) + +test.run(arguments = '-H help=1') +test.must_not_contain_any_line(test.stdout(), lines) + +# For -h and --help, the lines appear or not depending on how Configure() +# is initialized. +test.run(arguments = '-h help=0') +test.must_not_contain_any_line(test.stdout(), lines) + +test.run(arguments = '-h help=1') +test.must_contain_all_lines(test.stdout(), lines) + +test.run(arguments = '--help help=0') +test.must_not_contain_any_line(test.stdout(), lines) + +test.run(arguments = '--help help=1') +test.must_contain_all_lines(test.stdout(), lines) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/implicit-cache.py b/test/Configure/implicit-cache.py index 2cf74d17e..f5fdd4b42 100644 --- a/test/Configure/implicit-cache.py +++ b/test/Configure/implicit-cache.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -19,7 +21,7 @@ # 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. +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE """ Verify that use of --implicit-cache with the Python Value Nodes @@ -52,7 +54,6 @@ something else changed in the .sconf_temp directory), the string would get longer and longer until it blew out the users's memory. """ -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import TestSConsign from SCons.Util import get_hash_format, get_current_hash_algorithm_used @@ -60,6 +61,7 @@ from SCons.Util import get_hash_format, get_current_hash_algorithm_used test = TestSConsign.TestSConsign() test.write('SConstruct', """ +DefaultEnvironment(tools=[]) env = Environment(CPPPATH=['.']) conf = Configure(env) conf.CheckHeader( 'math.h' ) diff --git a/test/Configure/option--Q.py b/test/Configure/option--Q.py index 198e94fd4..4602a50f6 100644 --- a/test/Configure/option--Q.py +++ b/test/Configure/option--Q.py @@ -1,52 +1,52 @@ -#!/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 -Q option suppresses Configure context output. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -env = Environment() -import os -env.AppendENVPath('PATH', os.environ['PATH']) -conf = Configure(env) -r1 = conf.CheckCHeader('stdio.h') -env = conf.Finish() -""") - -test.run(arguments='-Q', stdout="scons: `.' is up to date.\n", stderr="") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/usr/bin/env python +# +# MIT License +# +# Copyright The SCons Foundation +# +# 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 + +""" +Verify that the -Q option suppresses Configure context output. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment() +import os +env.AppendENVPath('PATH', os.environ['PATH']) +conf = Configure(env) +r1 = conf.CheckCHeader('stdio.h') +env = conf.Finish() +""") + +test.run(arguments='-Q', stdout="scons: `.' is up to date.\n", stderr="") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/option--config.py b/test/Configure/option--config.py index 3fd0691df..4c3d7abc4 100644 --- a/test/Configure/option--config.py +++ b/test/Configure/option--config.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -19,10 +21,7 @@ # 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__" +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE """ Verify use of the --config= option. @@ -51,6 +50,7 @@ if get_current_hash_algorithm_used() != 'md5': SConstruct_path = test.workpath('SConstruct') test.write(SConstruct_path, """ +DefaultEnvironment(tools=[]) env = Environment(CPPPATH='#/include') import os env.AppendENVPath('PATH', os.environ['PATH']) @@ -78,7 +78,7 @@ conftest_0_base = os.path.join(".sconf_temp", "conftest_%s_0%%s"%conftest_0_c_ha conftest_0_c = conftest_0_base%'.c' conftest_1_base = os.path.join(".sconf_temp", "conftest_%s_0%%s"%conftest_1_c_hash) -SConstruct_file_line = test.python_file_line(SConstruct_path, 6)[:-1] +SConstruct_file_line = test.python_file_line(SConstruct_path, 7)[:-1] expect = """ scons: *** "%(conftest_0_c)s" is not yet built and cache is forced. @@ -191,6 +191,7 @@ test.file_fixture('test_main.c') # Check the combination of --config=force and Decider('MD5-timestamp') SConstruct_path = test.workpath('SConstruct') test.write(SConstruct_path, """ +DefaultEnvironment(tools=[]) env = Environment() env.Decider('MD5-timestamp') conf = Configure(env) -- 2.11.4.GIT