From 760baa87801203063ee8244215ce42853602e9d9 Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Thu, 30 May 2024 11:37:47 -0500 Subject: [PATCH 1/3] Update `.gitattributes` to match `.editorconfig` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Expand `.editorconfig` with a few missing extensions & match line-length specified in `.flake8` --- .editorconfig | 8 ++++---- .gitattributes | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.editorconfig b/.editorconfig index 1889885a7d..f6fbafbbe5 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,17 +10,17 @@ trim_trailing_whitespace = true end_of_line = lf charset = utf-8 -[*.py] -max_line_length = 78 +[{*.py,SConstruct,SConscript}] +max_line_length = 88 ensure_newline_before_comments = true include_trailing_comma = true use_parentheses = true -[*.xml] +[*.{xml,yml,yaml}] indent_size = 2 [*.rst] indent_size = 3 -[*.bat] +[*.{bat,cmd,ps1}] end_of_line = crlf diff --git a/.gitattributes b/.gitattributes index 8b807dfb94..dcf034f78c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,10 @@ +* text=auto eol=lf +*.bat eol=crlf +*.cmd eol=crlf +*.ps1 eol=crlf + doc/* linguist-documentation SCons/Tool/docbook/docbook-xsl-1.76.1 linguist-vendored *.xml linguist-documentation *.xsl linguist-documentation *.gen linguist-documentation - -*.in eol=lf From fbb026ef1145fe29e0ec3c1b66a3e99cac51e18d Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Thu, 30 May 2024 16:56:09 -0500 Subject: [PATCH 2/3] Enforce `.editorconfig` eol settings --- test/AR/ARCOM.py | 128 +++---- test/AR/ARCOMSTR.py | 134 +++---- test/AS/ASCOM.py | 180 ++++----- test/AS/ASCOMSTR.py | 166 ++++---- test/AS/ASPPCOM.py | 138 +++---- test/AS/ASPPCOMSTR.py | 132 +++---- test/AS/ml.py | 242 ++++++------ test/Actions/addpost-link.py | 150 ++++---- test/Actions/exitstatfunc.py | 146 +++---- test/AddOption/basic.py | 148 +++---- test/AddOption/help.py | 162 ++++---- test/AddOption/optional-arg.py | 214 +++++------ test/Alias/Dir-order.py | 98 ++--- test/Alias/errors.py | 98 ++--- test/Alias/scanner.py | 128 +++---- test/Batch/Boolean.py | 162 ++++---- test/Batch/CHANGED_SOURCES.py | 250 ++++++------ test/Batch/SOURCES.py | 254 ++++++------ test/Batch/action-changed.py | 208 +++++----- test/Batch/callable.py | 220 +++++------ test/Batch/changed_sources_alwaysbuild.py | 106 ++--- test/Batch/generated.py | 170 ++++---- test/Batch/removed.py | 224 +++++------ test/Batch/up_to_date.py | 188 ++++----- test/Builder/TargetSubst.py | 104 ++--- test/Builder/add_src_builder.py | 142 +++---- test/Builder/different-actions.py | 116 +++--- test/Builder/ensure_suffix.py | 122 +++--- test/Builder/non-multi.py | 134 +++---- test/Builder/not-a-Builder.py | 120 +++--- test/Builder/same-actions-diff-envs.py | 126 +++--- test/Builder/same-actions-diff-overrides.py | 124 +++--- test/Builder/srcdir.py | 166 ++++---- test/Builder/wrapper.py | 154 ++++---- test/CC/CCCOM.py | 144 +++---- test/CC/CCCOMSTR.py | 154 ++++---- test/CC/CCFLAGS.py | 222 +++++------ test/CC/CFLAGS.py | 248 ++++++------ test/CC/SHCCCOM.py | 144 +++---- test/CC/SHCCCOMSTR.py | 158 ++++---- test/CC/SHCFLAGS.py | 276 ++++++------- test/CPPPATH/Dir.py | 170 ++++---- test/CPPPATH/absolute-path.py | 200 +++++----- test/CPPPATH/expand-object.py | 138 +++---- test/CPPPATH/function-expansion.py | 284 +++++++------- test/CPPPATH/list-expansion.py | 276 ++++++------- test/CPPPATH/match-dir.py | 148 +++---- test/CPPPATH/nested-lists.py | 166 ++++---- test/CPPPATH/null.py | 122 +++--- test/CPPPATH/subdir-as-include.py | 196 +++++----- test/CacheDir/CacheDir.py | 328 ++++++++-------- test/CacheDir/SideEffect.py | 228 +++++------ test/CacheDir/VariantDir.py | 312 +++++++-------- test/CacheDir/debug.py | 402 +++++++++---------- test/CacheDir/environment.py | 340 ++++++++-------- test/CacheDir/multi-targets.py | 156 ++++---- test/CacheDir/option--cf.py | 262 ++++++------- test/CacheDir/symlink.py | 152 ++++---- test/CacheDir/up-to-date-q.py | 172 ++++----- test/CacheDir/value_dependencies.py | 102 ++--- test/Clang/clang_default_environment.py | 124 +++--- test/Clang/clang_specific_environment.py | 120 +++--- test/Clang/clang_static_library.py | 136 +++---- test/Clang/clangxx_default_environment.py | 124 +++--- test/Clang/clangxx_shared_library.py | 154 ++++---- test/Clang/clangxx_specific_environment.py | 120 +++--- test/Clang/clangxx_static_library.py | 136 +++---- test/Clean/basic.py | 370 +++++++++--------- test/Clean/function.py | 238 ++++++------ test/Clean/mkfifo.py | 162 ++++---- test/Clean/symlinks.py | 126 +++--- test/Climb/U-Default-dir.py | 96 ++--- test/Climb/U-Default-no-target.py | 100 ++--- test/Climb/U-no-Default.py | 94 ++--- test/Climb/explicit-parent--D.py | 158 ++++---- test/Climb/explicit-parent--U.py | 144 +++---- test/Climb/explicit-parent-u.py | 156 ++++---- test/Climb/filename--D.py | 158 ++++---- test/Climb/filename--U.py | 154 ++++---- test/Climb/filename-u.py | 154 ++++---- test/Climb/option--D.py | 178 ++++----- test/Climb/option--U.py | 288 +++++++------- test/Climb/option-u.py | 296 +++++++------- test/Configure/Action-error.py | 110 +++--- 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.py | 198 +++++----- test/Configure/basic.py | 182 ++++----- 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/custom-tests.py | 404 ++++++++++---------- test/Configure/from-SConscripts.py | 126 +++--- test/Configure/help.py | 188 ++++----- test/Configure/option--Q.py | 104 ++--- 99 files changed, 8739 insertions(+), 8739 deletions(-) diff --git a/test/AR/ARCOM.py b/test/AR/ARCOM.py index 010b6c584a..ddb5ba90c4 100644 --- a/test/AR/ARCOM.py +++ b/test/AR/ARCOM.py @@ -1,64 +1,64 @@ -#!/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 the ability to configure the $ARCOM construction variable. -""" - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.file_fixture('mycompile.py') -test.file_fixture('myrewrite.py') - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=['default', 'ar'], - ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', - RANLIB = True, - RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', - LIBPREFIX = '', - LIBSUFFIX = '.lib') -env.Library(target = 'output', source = ['file.1', 'file.2']) -""" % locals()) - -test.write('file.1', "file.1\n/*ar*/\n/*ranlib*/\n") -test.write('file.2', "file.2\n/*ar*/\n/*ranlib*/\n") - - -test.run(arguments = '.') - -test.must_match('output.lib', "file.1\nfile.2\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. + +""" +Test the ability to configure the $ARCOM construction variable. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.file_fixture('mycompile.py') +test.file_fixture('myrewrite.py') + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=['default', 'ar'], + ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', + RANLIB = True, + RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', + LIBPREFIX = '', + LIBSUFFIX = '.lib') +env.Library(target = 'output', source = ['file.1', 'file.2']) +""" % locals()) + +test.write('file.1', "file.1\n/*ar*/\n/*ranlib*/\n") +test.write('file.2', "file.2\n/*ar*/\n/*ranlib*/\n") + + +test.run(arguments = '.') + +test.must_match('output.lib', "file.1\nfile.2\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/AR/ARCOMSTR.py b/test/AR/ARCOMSTR.py index 95a0cd6ff6..593949ff88 100644 --- a/test/AR/ARCOMSTR.py +++ b/test/AR/ARCOMSTR.py @@ -1,67 +1,67 @@ -#!/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 $ARCOMSTR construction variable allows you to customize -the displayed archiver string. -""" - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.file_fixture('mycompile.py') -test.file_fixture('myrewrite.py') - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=['default', 'ar'], - ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', - ARCOMSTR = 'Archiving $TARGET from $SOURCES', - RANLIB = True, - RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', - LIBPREFIX = '', - LIBSUFFIX = '.lib') -env.Library(target = 'output', source = ['file.1', 'file.2']) -""" % locals()) - -test.write('file.1', "file.1\n/*ar*/\n/*ranlib*/\n") -test.write('file.2', "file.2\n/*ar*/\n/*ranlib*/\n") - -test.run() - -expect = 'Archiving output.lib from file.1 file.2' -test.must_contain_all_lines(test.stdout(), [expect]) -test.must_match('output.lib', "file.1\nfile.2\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. + +""" +Test that the $ARCOMSTR construction variable allows you to customize +the displayed archiver string. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.file_fixture('mycompile.py') +test.file_fixture('myrewrite.py') + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=['default', 'ar'], + ARCOM = r'%(_python_)s mycompile.py ar $TARGET $SOURCES', + ARCOMSTR = 'Archiving $TARGET from $SOURCES', + RANLIB = True, + RANLIBCOM = r'%(_python_)s myrewrite.py ranlib $TARGET', + LIBPREFIX = '', + LIBSUFFIX = '.lib') +env.Library(target = 'output', source = ['file.1', 'file.2']) +""" % locals()) + +test.write('file.1', "file.1\n/*ar*/\n/*ranlib*/\n") +test.write('file.2', "file.2\n/*ar*/\n/*ranlib*/\n") + +test.run() + +expect = 'Archiving output.lib from file.1 file.2' +test.must_contain_all_lines(test.stdout(), [expect]) +test.must_match('output.lib', "file.1\nfile.2\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/AS/ASCOM.py b/test/AS/ASCOM.py index 14291cf82c..01add8cafa 100644 --- a/test/AS/ASCOM.py +++ b/test/AS/ASCOM.py @@ -1,90 +1,90 @@ -#!/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 the ability to configure the $ASCOM construction variable. -""" - -import os - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.file_fixture('mycompile.py') - -if os.path.normcase('.s') == os.path.normcase('.S'): - alt_s_suffix = '.S' - alt_asm_suffix = '.ASM' -else: - alt_s_suffix = '.s' - alt_asm_suffix = '.asm' - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=['as'], - ASCOM = r'%(_python_)s mycompile.py as $TARGET $SOURCE', - OBJSUFFIX = '.obj', - SHOBJPREFIX = '', - SHOBJSUFFIX = '.shobj') -env.Object(target = 'test1', source = 'test1.s') -env.Object(target = 'test2', source = 'test2%(alt_s_suffix)s') -env.Object(target = 'test3', source = 'test3.asm') -env.Object(target = 'test4', source = 'test4%(alt_asm_suffix)s') -env.SharedObject(target = 'test5', source = 'test5.s') -env.SharedObject(target = 'test6', source = 'test6%(alt_s_suffix)s') -env.SharedObject(target = 'test7', source = 'test7.asm') -env.SharedObject(target = 'test8', source = 'test8%(alt_asm_suffix)s') -""" % locals()) - -test.write('test1.s', "test1.s\n/*as*/\n") -test.write('test2'+alt_s_suffix, "test2.S\n/*as*/\n") -test.write('test3.asm', "test3.asm\n/*as*/\n") -test.write('test4'+alt_asm_suffix, "test4.ASM\n/*as*/\n") -test.write('test5.s', "test5.s\n/*as*/\n") -test.write('test6'+alt_s_suffix, "test6.S\n/*as*/\n") -test.write('test7.asm', "test7.asm\n/*as*/\n") -test.write('test8'+alt_asm_suffix, "test8.ASM\n/*as*/\n") - -test.run(arguments = '.') - -test.must_match('test1.obj', "test1.s\n") -test.must_match('test2.obj', "test2.S\n") -test.must_match('test3.obj', "test3.asm\n") -test.must_match('test4.obj', "test4.ASM\n") -test.must_match('test5.shobj', "test5.s\n") -test.must_match('test6.shobj', "test6.S\n") -test.must_match('test7.shobj', "test7.asm\n") -test.must_match('test8.shobj', "test8.ASM\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. + +""" +Test the ability to configure the $ASCOM construction variable. +""" + +import os + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.file_fixture('mycompile.py') + +if os.path.normcase('.s') == os.path.normcase('.S'): + alt_s_suffix = '.S' + alt_asm_suffix = '.ASM' +else: + alt_s_suffix = '.s' + alt_asm_suffix = '.asm' + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=['as'], + ASCOM = r'%(_python_)s mycompile.py as $TARGET $SOURCE', + OBJSUFFIX = '.obj', + SHOBJPREFIX = '', + SHOBJSUFFIX = '.shobj') +env.Object(target = 'test1', source = 'test1.s') +env.Object(target = 'test2', source = 'test2%(alt_s_suffix)s') +env.Object(target = 'test3', source = 'test3.asm') +env.Object(target = 'test4', source = 'test4%(alt_asm_suffix)s') +env.SharedObject(target = 'test5', source = 'test5.s') +env.SharedObject(target = 'test6', source = 'test6%(alt_s_suffix)s') +env.SharedObject(target = 'test7', source = 'test7.asm') +env.SharedObject(target = 'test8', source = 'test8%(alt_asm_suffix)s') +""" % locals()) + +test.write('test1.s', "test1.s\n/*as*/\n") +test.write('test2'+alt_s_suffix, "test2.S\n/*as*/\n") +test.write('test3.asm', "test3.asm\n/*as*/\n") +test.write('test4'+alt_asm_suffix, "test4.ASM\n/*as*/\n") +test.write('test5.s', "test5.s\n/*as*/\n") +test.write('test6'+alt_s_suffix, "test6.S\n/*as*/\n") +test.write('test7.asm', "test7.asm\n/*as*/\n") +test.write('test8'+alt_asm_suffix, "test8.ASM\n/*as*/\n") + +test.run(arguments = '.') + +test.must_match('test1.obj', "test1.s\n") +test.must_match('test2.obj', "test2.S\n") +test.must_match('test3.obj', "test3.asm\n") +test.must_match('test4.obj', "test4.ASM\n") +test.must_match('test5.shobj', "test5.s\n") +test.must_match('test6.shobj', "test6.S\n") +test.must_match('test7.shobj', "test7.asm\n") +test.must_match('test8.shobj', "test8.ASM\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/AS/ASCOMSTR.py b/test/AS/ASCOMSTR.py index a97c285775..956c97cb6d 100644 --- a/test/AS/ASCOMSTR.py +++ b/test/AS/ASCOMSTR.py @@ -1,83 +1,83 @@ -#!/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 $ASCOMSTR construction variable allows you to configure -the assembly output. -""" - -import os - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.file_fixture('mycompile.py') - -if os.path.normcase('.s') == os.path.normcase('.S'): - alt_s_suffix = '.S' - alt_asm_suffix = '.ASM' -else: - alt_s_suffix = '.s' - alt_asm_suffix = '.asm' - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=['as'], - ASCOM = r'%(_python_)s mycompile.py as $TARGET $SOURCE', - ASCOMSTR = 'Assembling $TARGET from $SOURCE', - OBJSUFFIX = '.obj') -env.Object(target = 'test1', source = 'test1.s') -env.Object(target = 'test2', source = 'test2%(alt_s_suffix)s') -env.Object(target = 'test3', source = 'test3.asm') -env.Object(target = 'test4', source = 'test4%(alt_asm_suffix)s') -""" % locals()) - -test.write('test1.s', "test1.s\n/*as*/\n") -test.write('test2'+alt_s_suffix, "test2.S\n/*as*/\n") -test.write('test3.asm', "test3.asm\n/*as*/\n") -test.write('test4'+alt_asm_suffix, "test4.ASM\n/*as*/\n") - -test.run(stdout = test.wrap_stdout("""\ -Assembling test1.obj from test1.s -Assembling test2.obj from test2%(alt_s_suffix)s -Assembling test3.obj from test3.asm -Assembling test4.obj from test4%(alt_asm_suffix)s -""" % locals())) - -test.must_match('test1.obj', "test1.s\n") -test.must_match('test2.obj', "test2.S\n") -test.must_match('test3.obj', "test3.asm\n") -test.must_match('test4.obj', "test4.ASM\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. + +""" +Test that the $ASCOMSTR construction variable allows you to configure +the assembly output. +""" + +import os + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.file_fixture('mycompile.py') + +if os.path.normcase('.s') == os.path.normcase('.S'): + alt_s_suffix = '.S' + alt_asm_suffix = '.ASM' +else: + alt_s_suffix = '.s' + alt_asm_suffix = '.asm' + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=['as'], + ASCOM = r'%(_python_)s mycompile.py as $TARGET $SOURCE', + ASCOMSTR = 'Assembling $TARGET from $SOURCE', + OBJSUFFIX = '.obj') +env.Object(target = 'test1', source = 'test1.s') +env.Object(target = 'test2', source = 'test2%(alt_s_suffix)s') +env.Object(target = 'test3', source = 'test3.asm') +env.Object(target = 'test4', source = 'test4%(alt_asm_suffix)s') +""" % locals()) + +test.write('test1.s', "test1.s\n/*as*/\n") +test.write('test2'+alt_s_suffix, "test2.S\n/*as*/\n") +test.write('test3.asm', "test3.asm\n/*as*/\n") +test.write('test4'+alt_asm_suffix, "test4.ASM\n/*as*/\n") + +test.run(stdout = test.wrap_stdout("""\ +Assembling test1.obj from test1.s +Assembling test2.obj from test2%(alt_s_suffix)s +Assembling test3.obj from test3.asm +Assembling test4.obj from test4%(alt_asm_suffix)s +""" % locals())) + +test.must_match('test1.obj', "test1.s\n") +test.must_match('test2.obj', "test2.S\n") +test.must_match('test3.obj', "test3.asm\n") +test.must_match('test4.obj', "test4.ASM\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/AS/ASPPCOM.py b/test/AS/ASPPCOM.py index 6b704b437f..5c4c7458c3 100644 --- a/test/AS/ASPPCOM.py +++ b/test/AS/ASPPCOM.py @@ -1,69 +1,69 @@ -#!/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 the ability to configure the $ASPPCOM construction variable. -""" - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.file_fixture('mycompile.py') - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=['as'], - ASPPCOM = r'%(_python_)s mycompile.py as $TARGET $SOURCE', - OBJSUFFIX = '.obj', - SHOBJPREFIX = '', - SHOBJSUFFIX = '.shobj') -env.Object(target = 'test1', source = 'test1.spp') -env.Object(target = 'test2', source = 'test2.SPP') -env.SharedObject(target = 'test3', source = 'test3.spp') -env.SharedObject(target = 'test4', source = 'test4.SPP') -""" % locals()) - -test.write('test1.spp', "test1.spp\n/*as*/\n") -test.write('test2.SPP', "test2.SPP\n/*as*/\n") -test.write('test3.spp', "test3.spp\n/*as*/\n") -test.write('test4.SPP', "test4.SPP\n/*as*/\n") - -test.run(arguments = '.') - -test.must_match('test1.obj', "test1.spp\n") -test.must_match('test2.obj', "test2.SPP\n") -test.must_match('test3.shobj', "test3.spp\n") -test.must_match('test4.shobj', "test4.SPP\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. + +""" +Test the ability to configure the $ASPPCOM construction variable. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.file_fixture('mycompile.py') + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=['as'], + ASPPCOM = r'%(_python_)s mycompile.py as $TARGET $SOURCE', + OBJSUFFIX = '.obj', + SHOBJPREFIX = '', + SHOBJSUFFIX = '.shobj') +env.Object(target = 'test1', source = 'test1.spp') +env.Object(target = 'test2', source = 'test2.SPP') +env.SharedObject(target = 'test3', source = 'test3.spp') +env.SharedObject(target = 'test4', source = 'test4.SPP') +""" % locals()) + +test.write('test1.spp', "test1.spp\n/*as*/\n") +test.write('test2.SPP', "test2.SPP\n/*as*/\n") +test.write('test3.spp', "test3.spp\n/*as*/\n") +test.write('test4.SPP', "test4.SPP\n/*as*/\n") + +test.run(arguments = '.') + +test.must_match('test1.obj', "test1.spp\n") +test.must_match('test2.obj', "test2.SPP\n") +test.must_match('test3.shobj', "test3.spp\n") +test.must_match('test4.shobj', "test4.SPP\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/AS/ASPPCOMSTR.py b/test/AS/ASPPCOMSTR.py index 11a9b468ee..030d8a598a 100644 --- a/test/AS/ASPPCOMSTR.py +++ b/test/AS/ASPPCOMSTR.py @@ -1,66 +1,66 @@ -#!/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 $ASPPCOMSTR construction variable allows you to customize -the displayed assembler string. -""" - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.file_fixture('mycompile.py') - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=['as'], - ASPPCOM = r'%(_python_)s mycompile.py as $TARGET $SOURCE', - ASPPCOMSTR = 'Assembling $TARGET from $SOURCE', - OBJSUFFIX = '.obj') -env.Object(target = 'test1', source = 'test1.spp') -env.Object(target = 'test2', source = 'test2.SPP') -""" % locals()) - -test.write('test1.spp', "test1.spp\n/*as*/\n") -test.write('test2.SPP', "test2.SPP\n/*as*/\n") - -test.run(stdout = test.wrap_stdout("""\ -Assembling test1.obj from test1.spp -Assembling test2.obj from test2.SPP -""")) - -test.must_match('test1.obj', "test1.spp\n") -test.must_match('test2.obj', "test2.SPP\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. + +""" +Test that the $ASPPCOMSTR construction variable allows you to customize +the displayed assembler string. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.file_fixture('mycompile.py') + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=['as'], + ASPPCOM = r'%(_python_)s mycompile.py as $TARGET $SOURCE', + ASPPCOMSTR = 'Assembling $TARGET from $SOURCE', + OBJSUFFIX = '.obj') +env.Object(target = 'test1', source = 'test1.spp') +env.Object(target = 'test2', source = 'test2.SPP') +""" % locals()) + +test.write('test1.spp', "test1.spp\n/*as*/\n") +test.write('test2.SPP', "test2.SPP\n/*as*/\n") + +test.run(stdout = test.wrap_stdout("""\ +Assembling test1.obj from test1.spp +Assembling test2.obj from test2.SPP +""")) + +test.must_match('test1.obj', "test1.spp\n") +test.must_match('test2.obj', "test2.SPP\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/AS/ml.py b/test/AS/ml.py index 76b76a9bd1..5684fa87d7 100644 --- a/test/AS/ml.py +++ b/test/AS/ml.py @@ -1,121 +1,121 @@ -#!/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 correct use of the live 'ml' assembler. -""" - -import sys - -import TestSCons - -_python_ = TestSCons._python_ -_exe = TestSCons._exe - -test = TestSCons.TestSCons() - -if sys.platform != 'win32': - test.skip_test("Skipping ml test on non-win32 platform '%s'\n" % sys.platform) - -ml = test.where_is('ml') - -if not ml: - test.skip_test("ml not found; skipping test\n") - -test.file_fixture('wrapper.py') - -test.write('SConstruct', """ -import os -ccc = Environment(tools = ['msvc', 'mslink', 'masm'], - ASFLAGS = '/nologo /coff') -ccc['ENV']['PATH'] = ccc['ENV']['PATH'] + os.pathsep + os.environ['PATH'] -ddd = ccc.Clone(AS = r'%(_python_)s wrapper.py ' + ccc['AS']) -ccc.Program(target = 'ccc', source = ['ccc.asm', 'ccc_main.c']) -ddd.Program(target = 'ddd', source = ['ddd.asm', 'ddd_main.c']) -""" % locals()) - -test.write('ccc.asm', -""" -DSEG segment - PUBLIC _name -_name byte "ccc.asm",0 -DSEG ends - end -""") - -test.write('ddd.asm', -""" -DSEG segment - PUBLIC _name -_name byte "ddd.asm",0 -DSEG ends - end -""") - -test.write('ccc_main.c', r""" -extern char name[]; - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("ccc_main.c %s\n", name); - exit (0); -} -""") - -test.write('ddd_main.c', r""" -extern char name[]; - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("ddd_main.c %s\n", name); - exit (0); -} -""") - -test.run(arguments = 'ccc' + _exe, stderr = None) - -test.run(program = test.workpath('ccc'), stdout = "ccc_main.c ccc.asm\n") - -test.must_not_exist('wrapper.out') - -test.run(arguments = 'ddd' + _exe) - -test.run(program = test.workpath('ddd'), stdout = "ddd_main.c ddd.asm\n") - -test.must_match('wrapper.out', "wrapper.py\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 correct use of the live 'ml' assembler. +""" + +import sys + +import TestSCons + +_python_ = TestSCons._python_ +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +if sys.platform != 'win32': + test.skip_test("Skipping ml test on non-win32 platform '%s'\n" % sys.platform) + +ml = test.where_is('ml') + +if not ml: + test.skip_test("ml not found; skipping test\n") + +test.file_fixture('wrapper.py') + +test.write('SConstruct', """ +import os +ccc = Environment(tools = ['msvc', 'mslink', 'masm'], + ASFLAGS = '/nologo /coff') +ccc['ENV']['PATH'] = ccc['ENV']['PATH'] + os.pathsep + os.environ['PATH'] +ddd = ccc.Clone(AS = r'%(_python_)s wrapper.py ' + ccc['AS']) +ccc.Program(target = 'ccc', source = ['ccc.asm', 'ccc_main.c']) +ddd.Program(target = 'ddd', source = ['ddd.asm', 'ddd_main.c']) +""" % locals()) + +test.write('ccc.asm', +""" +DSEG segment + PUBLIC _name +_name byte "ccc.asm",0 +DSEG ends + end +""") + +test.write('ddd.asm', +""" +DSEG segment + PUBLIC _name +_name byte "ddd.asm",0 +DSEG ends + end +""") + +test.write('ccc_main.c', r""" +extern char name[]; + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("ccc_main.c %s\n", name); + exit (0); +} +""") + +test.write('ddd_main.c', r""" +extern char name[]; + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("ddd_main.c %s\n", name); + exit (0); +} +""") + +test.run(arguments = 'ccc' + _exe, stderr = None) + +test.run(program = test.workpath('ccc'), stdout = "ccc_main.c ccc.asm\n") + +test.must_not_exist('wrapper.out') + +test.run(arguments = 'ddd' + _exe) + +test.run(program = test.workpath('ddd'), stdout = "ddd_main.c ddd.asm\n") + +test.must_match('wrapper.out', "wrapper.py\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/Actions/addpost-link.py b/test/Actions/addpost-link.py index 3aa8352504..65a59b3897 100644 --- a/test/Actions/addpost-link.py +++ b/test/Actions/addpost-link.py @@ -1,75 +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 AddPostAction() on a program target doesn't interfere with -linking. - -This is a test for fix of Issue 1004, reported by Matt Doar and -packaged by Gary Oberbrunner. -""" - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.dir_fixture('addpost-link-fixture') - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -env = Environment() - -mylib = env.StaticLibrary('mytest', 'test_lib.c') - -myprog = env.Program('test1.c', - LIBPATH = ['.'], - LIBS = ['mytest'], - OBJSUFFIX = '.obj', - PROGSUFFIX = '.exe') -if ARGUMENTS['case']=='2': - AddPostAction(myprog, Action(r'%(_python_)s strip.py ' + myprog[0].get_abspath())) -""" % locals()) - -test.run(arguments="-Q case=1", stderr=None) - -test.run(arguments="-Q -c case=1") - -test.must_not_exist('test1.obj') - -test.run(arguments="-Q case=2", stderr=None) - -expect = 'strip.py: %s' % test.workpath('test1.exe') -test.must_contain_all_lines(test.stdout(), [expect]) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/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 AddPostAction() on a program target doesn't interfere with +linking. + +This is a test for fix of Issue 1004, reported by Matt Doar and +packaged by Gary Oberbrunner. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.dir_fixture('addpost-link-fixture') + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment() + +mylib = env.StaticLibrary('mytest', 'test_lib.c') + +myprog = env.Program('test1.c', + LIBPATH = ['.'], + LIBS = ['mytest'], + OBJSUFFIX = '.obj', + PROGSUFFIX = '.exe') +if ARGUMENTS['case']=='2': + AddPostAction(myprog, Action(r'%(_python_)s strip.py ' + myprog[0].get_abspath())) +""" % locals()) + +test.run(arguments="-Q case=1", stderr=None) + +test.run(arguments="-Q -c case=1") + +test.must_not_exist('test1.obj') + +test.run(arguments="-Q case=2", stderr=None) + +expect = 'strip.py: %s' % test.workpath('test1.exe') +test.must_contain_all_lines(test.stdout(), [expect]) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Actions/exitstatfunc.py b/test/Actions/exitstatfunc.py index e14b86b32f..7d5b2b976d 100644 --- a/test/Actions/exitstatfunc.py +++ b/test/Actions/exitstatfunc.py @@ -1,73 +1,73 @@ -#!/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 setting exitstatfunc on an Action works as advertised. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -def always_succeed(s): - # Always return 0, which indicates success. - return 0 - -def copy_fail(target, source, env): - with open(str(source[0]), 'rb') as infp, open(str(target[0]), 'wb') as f: - f.write(infp.read()) - return 2 - -a = Action(copy_fail, exitstatfunc=always_succeed) -Alias('test1', Command('test1.out', 'test1.in', a)) - -def fail(target, source, env): - return 2 - -t2 = Command('test2.out', 'test2.in', Copy('$TARGET', '$SOURCE')) -AddPostAction(t2, Action(fail, exitstatfunc=always_succeed)) -Alias('test2', t2) -""") - -test.write('test1.in', "test1.in\n") -test.write('test2.in', "test2.in\n") - -test.run(arguments = 'test1') - -test.must_match('test1.out', "test1.in\n") - -test.run(arguments = 'test2') - -test.must_match('test2.out', "test2.in\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 setting exitstatfunc on an Action works as advertised. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +def always_succeed(s): + # Always return 0, which indicates success. + return 0 + +def copy_fail(target, source, env): + with open(str(source[0]), 'rb') as infp, open(str(target[0]), 'wb') as f: + f.write(infp.read()) + return 2 + +a = Action(copy_fail, exitstatfunc=always_succeed) +Alias('test1', Command('test1.out', 'test1.in', a)) + +def fail(target, source, env): + return 2 + +t2 = Command('test2.out', 'test2.in', Copy('$TARGET', '$SOURCE')) +AddPostAction(t2, Action(fail, exitstatfunc=always_succeed)) +Alias('test2', t2) +""") + +test.write('test1.in', "test1.in\n") +test.write('test2.in', "test2.in\n") + +test.run(arguments = 'test1') + +test.must_match('test1.out', "test1.in\n") + +test.run(arguments = 'test2') + +test.must_match('test2.out', "test2.in\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/AddOption/basic.py b/test/AddOption/basic.py index b087ac0aba..64fb7ba1c1 100644 --- a/test/AddOption/basic.py +++ b/test/AddOption/basic.py @@ -1,74 +1,74 @@ -#!/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 the help text when the AddOption() function is used (and when -it's not). -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -env = Environment(tools=[]) -AddOption('--force', - action="store_true", - help='force installation (overwrite any existing files)') -AddOption('--prefix', - nargs=1, - dest='prefix', - action='store', - type='string', - metavar='DIR', - help='installation prefix') -f = GetOption('force') -if f: - f = "True" -print(f) -print(GetOption('prefix')) -""") - -test.run('-Q -q .', - stdout="None\nNone\n") - -test.run('-Q -q . --force', - stdout="True\nNone\n") - -test.run('-Q -q . --prefix=/home/foo', - stdout="None\n/home/foo\n") - -test.run('-Q -q . -- --prefix=/home/foo --force', - status=1, - stdout="None\nNone\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 the help text when the AddOption() function is used (and when +it's not). +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) +AddOption('--force', + action="store_true", + help='force installation (overwrite any existing files)') +AddOption('--prefix', + nargs=1, + dest='prefix', + action='store', + type='string', + metavar='DIR', + help='installation prefix') +f = GetOption('force') +if f: + f = "True" +print(f) +print(GetOption('prefix')) +""") + +test.run('-Q -q .', + stdout="None\nNone\n") + +test.run('-Q -q . --force', + stdout="True\nNone\n") + +test.run('-Q -q . --prefix=/home/foo', + stdout="None\n/home/foo\n") + +test.run('-Q -q . -- --prefix=/home/foo --force', + status=1, + stdout="None\nNone\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/AddOption/help.py b/test/AddOption/help.py index 81bb8983fb..6d855bd2d2 100644 --- a/test/AddOption/help.py +++ b/test/AddOption/help.py @@ -1,81 +1,81 @@ -#!/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. - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -env = Environment(tools=[]) -AddOption('--force', - action="store_true", - help='force installation (overwrite existing files)') -AddOption('--prefix', - nargs=1, - dest='prefix', - action='store', - type='string', - metavar='DIR', - help='installation prefix') -""") - -expected_lines = [ - 'Local Options:', - ' --force force installation (overwrite existing files)', - ' --prefix=DIR installation prefix', -] - -test.run(arguments = '-h') -lines = test.stdout().split('\n') -missing = [e for e in expected_lines if e not in lines] - -if missing: - print("====== STDOUT:") - print(test.stdout()) - print("====== Missing the following lines in the above AddOption() help output:") - print("\n".join(missing)) - test.fail_test() - -test.unlink('SConstruct') - -test.run(arguments = '-h') -lines = test.stdout().split('\n') -unexpected = [e for e in expected_lines if e in lines] - -if unexpected: - print("====== STDOUT:") - print(test.stdout()) - print("====== Unexpected lines in the above non-AddOption() help output:") - print("\n".join(unexpected)) - test.fail_test() - -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. + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) +AddOption('--force', + action="store_true", + help='force installation (overwrite existing files)') +AddOption('--prefix', + nargs=1, + dest='prefix', + action='store', + type='string', + metavar='DIR', + help='installation prefix') +""") + +expected_lines = [ + 'Local Options:', + ' --force force installation (overwrite existing files)', + ' --prefix=DIR installation prefix', +] + +test.run(arguments = '-h') +lines = test.stdout().split('\n') +missing = [e for e in expected_lines if e not in lines] + +if missing: + print("====== STDOUT:") + print(test.stdout()) + print("====== Missing the following lines in the above AddOption() help output:") + print("\n".join(missing)) + test.fail_test() + +test.unlink('SConstruct') + +test.run(arguments = '-h') +lines = test.stdout().split('\n') +unexpected = [e for e in expected_lines if e in lines] + +if unexpected: + print("====== STDOUT:") + print(test.stdout()) + print("====== Unexpected lines in the above non-AddOption() help output:") + print("\n".join(unexpected)) + test.fail_test() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/AddOption/optional-arg.py b/test/AddOption/optional-arg.py index 1f597bf43e..362da00ec4 100644 --- a/test/AddOption/optional-arg.py +++ b/test/AddOption/optional-arg.py @@ -1,107 +1,107 @@ -#!/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 use of the nargs='?' keyword argument to specify a long -command-line option with an optional argument value. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -AddOption('--install', - nargs='?', - dest='install', - default='/default/directory', - const='/called/default/directory', - action='store', - type='string', - metavar='DIR', - help='installation directory') -print(GetOption('install')) -""") - -test.run('-Q -q', - stdout="/default/directory\n") - -test.run('-Q -q next-arg', - stdout="/default/directory\n", - status=1) - -test.run('-Q -q . --install', - stdout="/called/default/directory\n") - -test.run('-Q -q . --install next-arg', - stdout="/called/default/directory\n", - status=1) - -test.run('-Q -q . first-arg --install', - stdout="/called/default/directory\n", - status=1) - -test.run('-Q -q . first-arg --install next-arg', - stdout="/called/default/directory\n", - status=1) - -test.run('-Q -q . --install=/command/line/directory', - stdout="/command/line/directory\n") - -test.run('-Q -q . --install=/command/line/directory next-arg', - stdout="/command/line/directory\n", - status=1) - -test.run('-Q -q . first-arg --install=/command/line/directory', - stdout="/command/line/directory\n", - status=1) - -test.run('-Q -q . first-arg --install=/command/line/directory next-arg', - stdout="/command/line/directory\n", - status=1) - - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -AddOption('-X', nargs='?') -""") - -expect = r""" -scons: \*\*\* option -X: nargs='\?' is incompatible with short options -File "[^"]+", line \d+, in \S+ -""" - -test.run(status=2, stderr=expect, 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 use of the nargs='?' keyword argument to specify a long +command-line option with an optional argument value. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +AddOption('--install', + nargs='?', + dest='install', + default='/default/directory', + const='/called/default/directory', + action='store', + type='string', + metavar='DIR', + help='installation directory') +print(GetOption('install')) +""") + +test.run('-Q -q', + stdout="/default/directory\n") + +test.run('-Q -q next-arg', + stdout="/default/directory\n", + status=1) + +test.run('-Q -q . --install', + stdout="/called/default/directory\n") + +test.run('-Q -q . --install next-arg', + stdout="/called/default/directory\n", + status=1) + +test.run('-Q -q . first-arg --install', + stdout="/called/default/directory\n", + status=1) + +test.run('-Q -q . first-arg --install next-arg', + stdout="/called/default/directory\n", + status=1) + +test.run('-Q -q . --install=/command/line/directory', + stdout="/command/line/directory\n") + +test.run('-Q -q . --install=/command/line/directory next-arg', + stdout="/command/line/directory\n", + status=1) + +test.run('-Q -q . first-arg --install=/command/line/directory', + stdout="/command/line/directory\n", + status=1) + +test.run('-Q -q . first-arg --install=/command/line/directory next-arg', + stdout="/command/line/directory\n", + status=1) + + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +AddOption('-X', nargs='?') +""") + +expect = r""" +scons: \*\*\* option -X: nargs='\?' is incompatible with short options +File "[^"]+", line \d+, in \S+ +""" + +test.run(status=2, stderr=expect, 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/Alias/Dir-order.py b/test/Alias/Dir-order.py index 6b62cb2020..86d0495c57 100644 --- a/test/Alias/Dir-order.py +++ b/test/Alias/Dir-order.py @@ -1,49 +1,49 @@ -#!/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. - -""" -Validate that calling Dir() for a string after we've used it as an -Alias() expansion works. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -Alias('afoo', 'foo') -f = Dir('foo') -""") - -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. + +""" +Validate that calling Dir() for a string after we've used it as an +Alias() expansion works. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +Alias('afoo', 'foo') +f = Dir('foo') +""") + +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/Alias/errors.py b/test/Alias/errors.py index 0bd24909d0..abac5d569d 100644 --- a/test/Alias/errors.py +++ b/test/Alias/errors.py @@ -1,49 +1,49 @@ -#!/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. - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env=Environment(tools=[]) -Decider('content') -env.Alias('C', 'D') -env.Alias('B', 'C') -env.Alias('A', 'B') -""") - -test.run(arguments='A', - stderr="scons: *** [C] Source `D' not found, needed by target `C'.\n", - status=2) - -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. + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env=Environment(tools=[]) +Decider('content') +env.Alias('C', 'D') +env.Alias('B', 'C') +env.Alias('A', 'B') +""") + +test.run(arguments='A', + stderr="scons: *** [C] Source `D' not found, needed by target `C'.\n", + status=2) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Alias/scanner.py b/test/Alias/scanner.py index 618c052ec1..4f7473b672 100644 --- a/test/Alias/scanner.py +++ b/test/Alias/scanner.py @@ -1,64 +1,64 @@ -#!/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 an Alias of a node with a Scanner works. -""" - - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -def cat(env, source, target): - target = str(target[0]) - with open(target, "wb") as f: - for src in source: - with open(str(src), "rb") as ifp: - f.write(ifp.read()) - -XBuilder = Builder(action = cat, src_suffix = '.x', suffix = '.c') -env = Environment(tools=[]) -env.Append(BUILDERS = { 'XBuilder': XBuilder }) -f = env.XBuilder(source = ['file.x'], target = ['file.c']) -env.Alias(target = ['cfiles'], source = f) -Default(['cfiles']) -""") - -test.write('file.x', "file.x\n") - -test.run() - -test.fail_test(test.read('file.c') != b"file.x\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. + +""" +Test that an Alias of a node with a Scanner works. +""" + + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +def cat(env, source, target): + target = str(target[0]) + with open(target, "wb") as f: + for src in source: + with open(str(src), "rb") as ifp: + f.write(ifp.read()) + +XBuilder = Builder(action = cat, src_suffix = '.x', suffix = '.c') +env = Environment(tools=[]) +env.Append(BUILDERS = { 'XBuilder': XBuilder }) +f = env.XBuilder(source = ['file.x'], target = ['file.c']) +env.Alias(target = ['cfiles'], source = f) +Default(['cfiles']) +""") + +test.write('file.x', "file.x\n") + +test.run() + +test.fail_test(test.read('file.c') != b"file.x\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/Batch/Boolean.py b/test/Batch/Boolean.py index 249599da73..702d24befb 100644 --- a/test/Batch/Boolean.py +++ b/test/Batch/Boolean.py @@ -1,81 +1,81 @@ -#!/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 basic use of batch_key to write a batch builder that handles -arbitrary pairs of target + source files. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) - -def batch_build(target, source, env): - for t, s in zip(target, source): - with open(str(t), 'wb') as f, open(str(s), 'rb') as infp: - f.write(infp.read()) -env = Environment(tools=[]) -bb = Action(batch_build, batch_key=True) -env['BUILDERS']['Batch'] = Builder(action=bb) -env1 = env.Clone() -env1.Batch('f1a.out', 'f1a.in') -env1.Batch('f1b.out', 'f1b.in') -env2 = env.Clone() -env2.Batch('f2a.out', 'f2a.in') -env3 = env.Clone() -env3.Batch('f3a.out', 'f3a.in') -env3.Batch('f3b.out', 'f3b.in') -""") - -test.write('f1a.in', "f1a.in\n") -test.write('f1b.in', "f1b.in\n") -test.write('f2a.in', "f2a.in\n") -test.write('f3a.in', "f3a.in\n") -test.write('f3b.in', "f3b.in\n") - -expect = test.wrap_stdout("""\ -batch_build(["f1a.out", "f1b.out"], ["f1a.in", "f1b.in"]) -batch_build(["f2a.out"], ["f2a.in"]) -batch_build(["f3a.out", "f3b.out"], ["f3a.in", "f3b.in"]) -""") - -test.run(stdout = expect) - -test.must_match('f1a.out', "f1a.in\n") -test.must_match('f1b.out', "f1b.in\n") -test.must_match('f2a.out', "f2a.in\n") -test.must_match('f3a.out', "f3a.in\n") -test.must_match('f3b.out', "f3b.in\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 basic use of batch_key to write a batch builder that handles +arbitrary pairs of target + source files. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + +def batch_build(target, source, env): + for t, s in zip(target, source): + with open(str(t), 'wb') as f, open(str(s), 'rb') as infp: + f.write(infp.read()) +env = Environment(tools=[]) +bb = Action(batch_build, batch_key=True) +env['BUILDERS']['Batch'] = Builder(action=bb) +env1 = env.Clone() +env1.Batch('f1a.out', 'f1a.in') +env1.Batch('f1b.out', 'f1b.in') +env2 = env.Clone() +env2.Batch('f2a.out', 'f2a.in') +env3 = env.Clone() +env3.Batch('f3a.out', 'f3a.in') +env3.Batch('f3b.out', 'f3b.in') +""") + +test.write('f1a.in', "f1a.in\n") +test.write('f1b.in', "f1b.in\n") +test.write('f2a.in', "f2a.in\n") +test.write('f3a.in', "f3a.in\n") +test.write('f3b.in', "f3b.in\n") + +expect = test.wrap_stdout("""\ +batch_build(["f1a.out", "f1b.out"], ["f1a.in", "f1b.in"]) +batch_build(["f2a.out"], ["f2a.in"]) +batch_build(["f3a.out", "f3b.out"], ["f3a.in", "f3b.in"]) +""") + +test.run(stdout = expect) + +test.must_match('f1a.out', "f1a.in\n") +test.must_match('f1b.out', "f1b.in\n") +test.must_match('f2a.out', "f2a.in\n") +test.must_match('f3a.out', "f3a.in\n") +test.must_match('f3b.out', "f3b.in\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/Batch/CHANGED_SOURCES.py b/test/Batch/CHANGED_SOURCES.py index 125a5562e0..5899269194 100644 --- a/test/Batch/CHANGED_SOURCES.py +++ b/test/Batch/CHANGED_SOURCES.py @@ -1,125 +1,125 @@ -#!/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 use of $CHANGED_SOURCES with batch builders correctly decides -to rebuild if any sources of changed, and specifies only the sources -on the rebuild. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -_python_ = TestSCons._python_ - -test.write('batch_build.py', """\ -import os -import sys -dir = sys.argv[1] -for infile in sys.argv[2:]: - inbase = os.path.splitext(os.path.split(infile)[1])[0] - outfile = os.path.join(dir, inbase+'.out') - with open(outfile, 'wb') as f, open(infile, 'rb') as infp: - f.write(infp.read()) -sys.exit(0) -""") - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=[]) -env['BATCH_BUILD'] = 'batch_build.py' -env['BATCHCOM'] = r'%(_python_)s $BATCH_BUILD ${TARGET.dir} $CHANGED_SOURCES' -bb = Action('$BATCHCOM', batch_key=True, targets='CHANGED_TARGETS') -env['BUILDERS']['Batch'] = Builder(action=bb) -env1 = env.Clone() -env1.Batch('out1/f1a.out', 'f1a.in') -env1.Batch('out1/f1b.out', 'f1b.in') -env2 = env.Clone() -env2.Batch('out2/f2a.out', 'f2a.in') -env3 = env.Clone() -env3.Batch('out3/f3a.out', 'f3a.in') -env3.Batch('out3/f3b.out', 'f3b.in') -""" % locals()) - -test.write('f1a.in', "f1a.in\n") -test.write('f1b.in', "f1b.in\n") -test.write('f2a.in', "f2a.in\n") -test.write('f3a.in', "f3a.in\n") -test.write('f3b.in', "f3b.in\n") - -expect = test.wrap_stdout("""\ -%(_python_)s batch_build.py out1 f1a.in f1b.in -%(_python_)s batch_build.py out2 f2a.in -%(_python_)s batch_build.py out3 f3a.in f3b.in -""" % locals()) - -test.run(stdout = expect) - -test.must_match(['out1', 'f1a.out'], "f1a.in\n") -test.must_match(['out1', 'f1b.out'], "f1b.in\n") -test.must_match(['out2', 'f2a.out'], "f2a.in\n") -test.must_match(['out3', 'f3a.out'], "f3a.in\n") -test.must_match(['out3', 'f3b.out'], "f3b.in\n") - - - -test.write('f1b.in', "f1b.in 2\n") - -expect = test.wrap_stdout("""\ -%(_python_)s batch_build.py out1 f1b.in -""" % locals()) - -test.run(stdout = expect) - -test.must_match(['out1', 'f1a.out'], "f1a.in\n") -test.must_match(['out1', 'f1b.out'], "f1b.in 2\n") -test.must_match(['out2', 'f2a.out'], "f2a.in\n") -test.must_match(['out3', 'f3a.out'], "f3a.in\n") -test.must_match(['out3', 'f3b.out'], "f3b.in\n") - - - -test.write('f3a.in', "f3a.in 2\n") - -expect = test.wrap_stdout("""\ -%(_python_)s batch_build.py out3 f3a.in -""" % locals()) - -test.run(stdout = expect) - -test.must_match(['out1', 'f1a.out'], "f1a.in\n") -test.must_match(['out1', 'f1b.out'], "f1b.in 2\n") -test.must_match(['out2', 'f2a.out'], "f2a.in\n") -test.must_match(['out3', 'f3a.out'], "f3a.in 2\n") -test.must_match(['out3', 'f3b.out'], "f3b.in\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 use of $CHANGED_SOURCES with batch builders correctly decides +to rebuild if any sources of changed, and specifies only the sources +on the rebuild. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +_python_ = TestSCons._python_ + +test.write('batch_build.py', """\ +import os +import sys +dir = sys.argv[1] +for infile in sys.argv[2:]: + inbase = os.path.splitext(os.path.split(infile)[1])[0] + outfile = os.path.join(dir, inbase+'.out') + with open(outfile, 'wb') as f, open(infile, 'rb') as infp: + f.write(infp.read()) +sys.exit(0) +""") + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) +env['BATCH_BUILD'] = 'batch_build.py' +env['BATCHCOM'] = r'%(_python_)s $BATCH_BUILD ${TARGET.dir} $CHANGED_SOURCES' +bb = Action('$BATCHCOM', batch_key=True, targets='CHANGED_TARGETS') +env['BUILDERS']['Batch'] = Builder(action=bb) +env1 = env.Clone() +env1.Batch('out1/f1a.out', 'f1a.in') +env1.Batch('out1/f1b.out', 'f1b.in') +env2 = env.Clone() +env2.Batch('out2/f2a.out', 'f2a.in') +env3 = env.Clone() +env3.Batch('out3/f3a.out', 'f3a.in') +env3.Batch('out3/f3b.out', 'f3b.in') +""" % locals()) + +test.write('f1a.in', "f1a.in\n") +test.write('f1b.in', "f1b.in\n") +test.write('f2a.in', "f2a.in\n") +test.write('f3a.in', "f3a.in\n") +test.write('f3b.in', "f3b.in\n") + +expect = test.wrap_stdout("""\ +%(_python_)s batch_build.py out1 f1a.in f1b.in +%(_python_)s batch_build.py out2 f2a.in +%(_python_)s batch_build.py out3 f3a.in f3b.in +""" % locals()) + +test.run(stdout = expect) + +test.must_match(['out1', 'f1a.out'], "f1a.in\n") +test.must_match(['out1', 'f1b.out'], "f1b.in\n") +test.must_match(['out2', 'f2a.out'], "f2a.in\n") +test.must_match(['out3', 'f3a.out'], "f3a.in\n") +test.must_match(['out3', 'f3b.out'], "f3b.in\n") + + + +test.write('f1b.in', "f1b.in 2\n") + +expect = test.wrap_stdout("""\ +%(_python_)s batch_build.py out1 f1b.in +""" % locals()) + +test.run(stdout = expect) + +test.must_match(['out1', 'f1a.out'], "f1a.in\n") +test.must_match(['out1', 'f1b.out'], "f1b.in 2\n") +test.must_match(['out2', 'f2a.out'], "f2a.in\n") +test.must_match(['out3', 'f3a.out'], "f3a.in\n") +test.must_match(['out3', 'f3b.out'], "f3b.in\n") + + + +test.write('f3a.in', "f3a.in 2\n") + +expect = test.wrap_stdout("""\ +%(_python_)s batch_build.py out3 f3a.in +""" % locals()) + +test.run(stdout = expect) + +test.must_match(['out1', 'f1a.out'], "f1a.in\n") +test.must_match(['out1', 'f1b.out'], "f1b.in 2\n") +test.must_match(['out2', 'f2a.out'], "f2a.in\n") +test.must_match(['out3', 'f3a.out'], "f3a.in 2\n") +test.must_match(['out3', 'f3b.out'], "f3b.in\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/Batch/SOURCES.py b/test/Batch/SOURCES.py index 2cbb205cfc..ea17224e4e 100644 --- a/test/Batch/SOURCES.py +++ b/test/Batch/SOURCES.py @@ -1,127 +1,127 @@ -#!/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 use of $SOURCES with batch builders correctly decides to -rebuild if any sources of changed, and specifies all the sources -on the rebuild. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -_python_ = TestSCons._python_ - -test.write('batch_build.py', """\ -import os -import sys -dir = sys.argv[1] -for infile in sys.argv[2:]: - inbase = os.path.splitext(os.path.split(infile)[1])[0] - outfile = os.path.join(dir, inbase+'.out') - with open(outfile, 'wb') as f, open(infile, 'rb') as infp: - f.write(infp.read()) -sys.exit(0) -""") - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=[]) -env['BATCH_BUILD'] = 'batch_build.py' -env['BATCHCOM'] = r'%(_python_)s $BATCH_BUILD ${TARGET.dir} $SOURCES' -bb = Action('$BATCHCOM', batch_key=True) -env['BUILDERS']['Batch'] = Builder(action=bb) -env1 = env.Clone() -env1.Batch('out1/f1a.out', 'f1a.in') -env1.Batch('out1/f1b.out', 'f1b.in') -env2 = env.Clone() -env2.Batch('out2/f2a.out', 'f2a.in') -env3 = env.Clone() -env3.Batch('out3/f3a.out', 'f3a.in') -env3.Batch('out3/f3b.out', 'f3b.in') -""" % locals()) - -test.write('f1a.in', "f1a.in\n") -test.write('f1b.in', "f1b.in\n") -test.write('f2a.in', "f2a.in\n") -test.write('f3a.in', "f3a.in\n") -test.write('f3b.in', "f3b.in\n") - -expect = test.wrap_stdout("""\ -%(_python_)s batch_build.py out1 f1a.in f1b.in -%(_python_)s batch_build.py out2 f2a.in -%(_python_)s batch_build.py out3 f3a.in f3b.in -""" % locals()) - -test.run(stdout = expect) - -test.must_match(['out1', 'f1a.out'], "f1a.in\n") -test.must_match(['out1', 'f1b.out'], "f1b.in\n") -test.must_match(['out2', 'f2a.out'], "f2a.in\n") -test.must_match(['out3', 'f3a.out'], "f3a.in\n") -test.must_match(['out3', 'f3b.out'], "f3b.in\n") - -test.up_to_date(options = '--debug=explain', arguments = '.') - - - - -test.write('f1b.in', "f1b.in 2\n") - -expect = test.wrap_stdout("""\ -%(_python_)s batch_build.py out1 f1a.in f1b.in -""" % locals()) - -test.run(stdout = expect) - -test.must_match(['out1', 'f1a.out'], "f1a.in\n") -test.must_match(['out1', 'f1b.out'], "f1b.in 2\n") -test.must_match(['out2', 'f2a.out'], "f2a.in\n") -test.must_match(['out3', 'f3a.out'], "f3a.in\n") -test.must_match(['out3', 'f3b.out'], "f3b.in\n") - - -test.write('f3a.in', "f3a.in 2\n") - -expect = test.wrap_stdout("""\ -%(_python_)s batch_build.py out3 f3a.in f3b.in -""" % locals()) - -test.run(stdout = expect) - -test.must_match(['out1', 'f1a.out'], "f1a.in\n") -test.must_match(['out1', 'f1b.out'], "f1b.in 2\n") -test.must_match(['out2', 'f2a.out'], "f2a.in\n") -test.must_match(['out3', 'f3a.out'], "f3a.in 2\n") -test.must_match(['out3', 'f3b.out'], "f3b.in\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 use of $SOURCES with batch builders correctly decides to +rebuild if any sources of changed, and specifies all the sources +on the rebuild. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +_python_ = TestSCons._python_ + +test.write('batch_build.py', """\ +import os +import sys +dir = sys.argv[1] +for infile in sys.argv[2:]: + inbase = os.path.splitext(os.path.split(infile)[1])[0] + outfile = os.path.join(dir, inbase+'.out') + with open(outfile, 'wb') as f, open(infile, 'rb') as infp: + f.write(infp.read()) +sys.exit(0) +""") + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) +env['BATCH_BUILD'] = 'batch_build.py' +env['BATCHCOM'] = r'%(_python_)s $BATCH_BUILD ${TARGET.dir} $SOURCES' +bb = Action('$BATCHCOM', batch_key=True) +env['BUILDERS']['Batch'] = Builder(action=bb) +env1 = env.Clone() +env1.Batch('out1/f1a.out', 'f1a.in') +env1.Batch('out1/f1b.out', 'f1b.in') +env2 = env.Clone() +env2.Batch('out2/f2a.out', 'f2a.in') +env3 = env.Clone() +env3.Batch('out3/f3a.out', 'f3a.in') +env3.Batch('out3/f3b.out', 'f3b.in') +""" % locals()) + +test.write('f1a.in', "f1a.in\n") +test.write('f1b.in', "f1b.in\n") +test.write('f2a.in', "f2a.in\n") +test.write('f3a.in', "f3a.in\n") +test.write('f3b.in', "f3b.in\n") + +expect = test.wrap_stdout("""\ +%(_python_)s batch_build.py out1 f1a.in f1b.in +%(_python_)s batch_build.py out2 f2a.in +%(_python_)s batch_build.py out3 f3a.in f3b.in +""" % locals()) + +test.run(stdout = expect) + +test.must_match(['out1', 'f1a.out'], "f1a.in\n") +test.must_match(['out1', 'f1b.out'], "f1b.in\n") +test.must_match(['out2', 'f2a.out'], "f2a.in\n") +test.must_match(['out3', 'f3a.out'], "f3a.in\n") +test.must_match(['out3', 'f3b.out'], "f3b.in\n") + +test.up_to_date(options = '--debug=explain', arguments = '.') + + + + +test.write('f1b.in', "f1b.in 2\n") + +expect = test.wrap_stdout("""\ +%(_python_)s batch_build.py out1 f1a.in f1b.in +""" % locals()) + +test.run(stdout = expect) + +test.must_match(['out1', 'f1a.out'], "f1a.in\n") +test.must_match(['out1', 'f1b.out'], "f1b.in 2\n") +test.must_match(['out2', 'f2a.out'], "f2a.in\n") +test.must_match(['out3', 'f3a.out'], "f3a.in\n") +test.must_match(['out3', 'f3b.out'], "f3b.in\n") + + +test.write('f3a.in', "f3a.in 2\n") + +expect = test.wrap_stdout("""\ +%(_python_)s batch_build.py out3 f3a.in f3b.in +""" % locals()) + +test.run(stdout = expect) + +test.must_match(['out1', 'f1a.out'], "f1a.in\n") +test.must_match(['out1', 'f1b.out'], "f1b.in 2\n") +test.must_match(['out2', 'f2a.out'], "f2a.in\n") +test.must_match(['out3', 'f3a.out'], "f3a.in 2\n") +test.must_match(['out3', 'f3b.out'], "f3b.in\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/Batch/action-changed.py b/test/Batch/action-changed.py index bbe7da3b3c..771b876250 100644 --- a/test/Batch/action-changed.py +++ b/test/Batch/action-changed.py @@ -1,104 +1,104 @@ -#!/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 targets in a batch builder are rebuilt when the -build action changes. -""" - -import os - -import TestSCons - -# swap slashes because on py3 on win32 inside the generated build.py -# the backslashes are getting interpretted as unicode which is -# invalid. -python = TestSCons.python.replace('\\','//') -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -build_py_contents = """\ -#!/usr/bin/env %s -import sys -sep = sys.argv.index('--') -targets = sys.argv[1:sep] -sources = sys.argv[sep+1:] -for t, s in zip(targets, sources): - with open(t, 'wb') as ofp, open(s, 'rb') as ifp: - ofp.write(bytearray('%s\\n', 'utf-8')) - ofp.write(ifp.read()) -sys.exit(0) -""" - -test.write('build.py', build_py_contents % (python, 'one')) -os.chmod(test.workpath('build.py'), 0o755) - -build_py_workpath = test.workpath('build.py') - -# Provide IMPLICIT_COMMAND_DEPENDENCIES=2 so we take a dependency on build.py. -# Without that, we only scan the first entry in the action string. -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=[], - IMPLICIT_COMMAND_DEPENDENCIES=2) -env.PrependENVPath('PATHEXT', '.PY') -bb = Action(r'%(_python_)s "%(build_py_workpath)s" $CHANGED_TARGETS -- $CHANGED_SOURCES', - batch_key=True, - targets='CHANGED_TARGETS') -env['BUILDERS']['Batch'] = Builder(action=bb) -env.Batch('f1.out', 'f1.in') -env.Batch('f2.out', 'f2.in') -env.Batch('f3.out', 'f3.in') -""" % locals()) - -test.write('f1.in', "f1.in\n") -test.write('f2.in', "f2.in\n") -test.write('f3.in', "f3.in\n") - -test.run(arguments = '.') - -test.must_match('f1.out', "one\nf1.in\n") -test.must_match('f2.out', "one\nf2.in\n") -test.must_match('f3.out', "one\nf3.in\n") - -test.up_to_date(arguments = '.') - -test.write('build.py', build_py_contents % (python, 'two')) -os.chmod(test.workpath('build.py'), 0o755) - -test.not_up_to_date(arguments = '.') - -test.must_match('f1.out', "two\nf1.in\n") -test.must_match('f2.out', "two\nf2.in\n") -test.must_match('f3.out', "two\nf3.in\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 targets in a batch builder are rebuilt when the +build action changes. +""" + +import os + +import TestSCons + +# swap slashes because on py3 on win32 inside the generated build.py +# the backslashes are getting interpretted as unicode which is +# invalid. +python = TestSCons.python.replace('\\','//') +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +build_py_contents = """\ +#!/usr/bin/env %s +import sys +sep = sys.argv.index('--') +targets = sys.argv[1:sep] +sources = sys.argv[sep+1:] +for t, s in zip(targets, sources): + with open(t, 'wb') as ofp, open(s, 'rb') as ifp: + ofp.write(bytearray('%s\\n', 'utf-8')) + ofp.write(ifp.read()) +sys.exit(0) +""" + +test.write('build.py', build_py_contents % (python, 'one')) +os.chmod(test.workpath('build.py'), 0o755) + +build_py_workpath = test.workpath('build.py') + +# Provide IMPLICIT_COMMAND_DEPENDENCIES=2 so we take a dependency on build.py. +# Without that, we only scan the first entry in the action string. +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=[], + IMPLICIT_COMMAND_DEPENDENCIES=2) +env.PrependENVPath('PATHEXT', '.PY') +bb = Action(r'%(_python_)s "%(build_py_workpath)s" $CHANGED_TARGETS -- $CHANGED_SOURCES', + batch_key=True, + targets='CHANGED_TARGETS') +env['BUILDERS']['Batch'] = Builder(action=bb) +env.Batch('f1.out', 'f1.in') +env.Batch('f2.out', 'f2.in') +env.Batch('f3.out', 'f3.in') +""" % locals()) + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") +test.write('f3.in', "f3.in\n") + +test.run(arguments = '.') + +test.must_match('f1.out', "one\nf1.in\n") +test.must_match('f2.out', "one\nf2.in\n") +test.must_match('f3.out', "one\nf3.in\n") + +test.up_to_date(arguments = '.') + +test.write('build.py', build_py_contents % (python, 'two')) +os.chmod(test.workpath('build.py'), 0o755) + +test.not_up_to_date(arguments = '.') + +test.must_match('f1.out', "two\nf1.in\n") +test.must_match('f2.out', "two\nf2.in\n") +test.must_match('f3.out', "two\nf3.in\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/Batch/callable.py b/test/Batch/callable.py index 9f9a119a2a..5c4d816d3c 100644 --- a/test/Batch/callable.py +++ b/test/Batch/callable.py @@ -1,110 +1,110 @@ -#!/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 passing in a batch_key callable for more control over how -batch builders behave. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('sub1', 'sub2') - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -def batch_build(target, source, env): - for t, s in zip(target, source): - with open(str(t), 'wb') as f, open(str(s), 'rb') as infp: - f.write(infp.read()) -if ARGUMENTS.get('BATCH_CALLABLE'): - def batch_key(action, env, target, source): - return (id(action), id(env), target[0].dir) -else: - batch_key=True -env = Environment(tools=[]) -bb = Action(batch_build, batch_key=batch_key) -env['BUILDERS']['Batch'] = Builder(action=bb) -env1 = env.Clone() -env1.Batch('sub1/f1a.out', 'f1a.in') -env1.Batch('sub2/f1b.out', 'f1b.in') -env2 = env.Clone() -env2.Batch('sub1/f2a.out', 'f2a.in') -env2.Batch('sub2/f2b.out', 'f2b.in') -""") - -test.write('f1a.in', "f1a.in\n") -test.write('f1b.in', "f1b.in\n") -test.write('f2a.in', "f2a.in\n") -test.write('f2b.in', "f2b.in\n") - -sub1_f1a_out = os.path.join('sub1', 'f1a.out') -sub2_f1b_out = os.path.join('sub2', 'f1b.out') -sub1_f2a_out = os.path.join('sub1', 'f2a.out') -sub2_f2b_out = os.path.join('sub2', 'f2b.out') - -expect = test.wrap_stdout("""\ -batch_build(["%(sub1_f1a_out)s", "%(sub2_f1b_out)s"], ["f1a.in", "f1b.in"]) -batch_build(["%(sub1_f2a_out)s", "%(sub2_f2b_out)s"], ["f2a.in", "f2b.in"]) -""" % locals()) - -test.run(stdout = expect) - -test.must_match(['sub1', 'f1a.out'], "f1a.in\n") -test.must_match(['sub2', 'f1b.out'], "f1b.in\n") -test.must_match(['sub1', 'f2a.out'], "f2a.in\n") -test.must_match(['sub2', 'f2b.out'], "f2b.in\n") - -test.run(arguments = '-c') - -test.must_not_exist(['sub1', 'f1a.out']) -test.must_not_exist(['sub2', 'f1b.out']) -test.must_not_exist(['sub1', 'f2a.out']) -test.must_not_exist(['sub2', 'f2b.out']) - -expect = test.wrap_stdout("""\ -batch_build(["%(sub1_f1a_out)s"], ["f1a.in"]) -batch_build(["%(sub1_f2a_out)s"], ["f2a.in"]) -batch_build(["%(sub2_f1b_out)s"], ["f1b.in"]) -batch_build(["%(sub2_f2b_out)s"], ["f2b.in"]) -""" % locals()) - -test.run(arguments = 'BATCH_CALLABLE=1', stdout = expect) - -test.must_match(['sub1', 'f1a.out'], "f1a.in\n") -test.must_match(['sub2', 'f1b.out'], "f1b.in\n") -test.must_match(['sub1', 'f2a.out'], "f2a.in\n") -test.must_match(['sub2', 'f2b.out'], "f2b.in\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 passing in a batch_key callable for more control over how +batch builders behave. +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('sub1', 'sub2') + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +def batch_build(target, source, env): + for t, s in zip(target, source): + with open(str(t), 'wb') as f, open(str(s), 'rb') as infp: + f.write(infp.read()) +if ARGUMENTS.get('BATCH_CALLABLE'): + def batch_key(action, env, target, source): + return (id(action), id(env), target[0].dir) +else: + batch_key=True +env = Environment(tools=[]) +bb = Action(batch_build, batch_key=batch_key) +env['BUILDERS']['Batch'] = Builder(action=bb) +env1 = env.Clone() +env1.Batch('sub1/f1a.out', 'f1a.in') +env1.Batch('sub2/f1b.out', 'f1b.in') +env2 = env.Clone() +env2.Batch('sub1/f2a.out', 'f2a.in') +env2.Batch('sub2/f2b.out', 'f2b.in') +""") + +test.write('f1a.in', "f1a.in\n") +test.write('f1b.in', "f1b.in\n") +test.write('f2a.in', "f2a.in\n") +test.write('f2b.in', "f2b.in\n") + +sub1_f1a_out = os.path.join('sub1', 'f1a.out') +sub2_f1b_out = os.path.join('sub2', 'f1b.out') +sub1_f2a_out = os.path.join('sub1', 'f2a.out') +sub2_f2b_out = os.path.join('sub2', 'f2b.out') + +expect = test.wrap_stdout("""\ +batch_build(["%(sub1_f1a_out)s", "%(sub2_f1b_out)s"], ["f1a.in", "f1b.in"]) +batch_build(["%(sub1_f2a_out)s", "%(sub2_f2b_out)s"], ["f2a.in", "f2b.in"]) +""" % locals()) + +test.run(stdout = expect) + +test.must_match(['sub1', 'f1a.out'], "f1a.in\n") +test.must_match(['sub2', 'f1b.out'], "f1b.in\n") +test.must_match(['sub1', 'f2a.out'], "f2a.in\n") +test.must_match(['sub2', 'f2b.out'], "f2b.in\n") + +test.run(arguments = '-c') + +test.must_not_exist(['sub1', 'f1a.out']) +test.must_not_exist(['sub2', 'f1b.out']) +test.must_not_exist(['sub1', 'f2a.out']) +test.must_not_exist(['sub2', 'f2b.out']) + +expect = test.wrap_stdout("""\ +batch_build(["%(sub1_f1a_out)s"], ["f1a.in"]) +batch_build(["%(sub1_f2a_out)s"], ["f2a.in"]) +batch_build(["%(sub2_f1b_out)s"], ["f1b.in"]) +batch_build(["%(sub2_f2b_out)s"], ["f2b.in"]) +""" % locals()) + +test.run(arguments = 'BATCH_CALLABLE=1', stdout = expect) + +test.must_match(['sub1', 'f1a.out'], "f1a.in\n") +test.must_match(['sub2', 'f1b.out'], "f1b.in\n") +test.must_match(['sub1', 'f2a.out'], "f2a.in\n") +test.must_match(['sub2', 'f2b.out'], "f2b.in\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/Batch/changed_sources_alwaysbuild.py b/test/Batch/changed_sources_alwaysbuild.py index 06a2e02c2b..5e278a5236 100644 --- a/test/Batch/changed_sources_alwaysbuild.py +++ b/test/Batch/changed_sources_alwaysbuild.py @@ -1,53 +1,53 @@ -#!/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 files marked AlwaysBuild also get put into CHANGED_SOURCES. -Tigris bug 2622 -""" - -import TestSCons - -test = TestSCons.TestSCons() -test.file_fixture('SConstruct_changed_sources_alwaysBuild','SConstruct') -test.file_fixture('changed_sources_main.cpp') -# always works on first run -test.run() - -# On second run prior to fix the file hasn't changed and so never -# makes it into CHANGED_SOURCES. -# Compile is triggered because SCons knows it needs to build it. -# This tests that on second run the source file is in the scons -# output. Also prior to fix the compile would fail because -# it would produce a compile command line lacking a source file. -test.run() -test.must_contain_all_lines(test.stdout(),['changed_sources_main.cpp']) -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 files marked AlwaysBuild also get put into CHANGED_SOURCES. +Tigris bug 2622 +""" + +import TestSCons + +test = TestSCons.TestSCons() +test.file_fixture('SConstruct_changed_sources_alwaysBuild','SConstruct') +test.file_fixture('changed_sources_main.cpp') +# always works on first run +test.run() + +# On second run prior to fix the file hasn't changed and so never +# makes it into CHANGED_SOURCES. +# Compile is triggered because SCons knows it needs to build it. +# This tests that on second run the source file is in the scons +# output. Also prior to fix the compile would fail because +# it would produce a compile command line lacking a source file. +test.run() +test.must_contain_all_lines(test.stdout(),['changed_sources_main.cpp']) +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Batch/generated.py b/test/Batch/generated.py index 91b4609f2d..cb76ff2b7c 100644 --- a/test/Batch/generated.py +++ b/test/Batch/generated.py @@ -1,85 +1,85 @@ -#!/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 use of a batch builder when one of the later targets in the -list the list depends on a generated file. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) - -def batch_build(target, source, env): - for t, s in zip(target, source): - with open(str(t), 'wb') as fp: - if str(t) == 'f3.out': - with open('f3.include', 'rb') as f: - fp.write(f.read()) - with open(str(s), 'rb') as f: - fp.write(f.read()) -env = Environment(tools=[]) -bb = Action(batch_build, batch_key=True) -env['BUILDERS']['Batch'] = Builder(action=bb) -env1 = env.Clone() -env1.Batch('f1.out', 'f1.in') -env1.Batch('f2.out', 'f2.mid') -f3_out = env1.Batch('f3.out', 'f3.in') - -env2 = env.Clone() -env2.Batch('f2.mid', 'f2.in') - -f3_include = env.Batch('f3.include', 'f3.include.in') -env.Depends(f3_out, f3_include) -""") - -test.write('f1.in', "f1.in\n") -test.write('f2.in', "f2.in\n") -test.write('f3.in', "f3.in\n") -test.write('f3.include.in', "f3.include.in\n") - -expect = test.wrap_stdout("""\ -batch_build(["f2.mid"], ["f2.in"]) -batch_build(["f3.include"], ["f3.include.in"]) -batch_build(["f1.out", "f2.out", "f3.out"], ["f1.in", "f2.mid", "f3.in"]) -""") - -test.run(stdout = expect) - -test.must_match('f1.out', "f1.in\n") -test.must_match('f2.out', "f2.in\n") - -test.up_to_date(arguments = '.') - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/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 use of a batch builder when one of the later targets in the +list the list depends on a generated file. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + +def batch_build(target, source, env): + for t, s in zip(target, source): + with open(str(t), 'wb') as fp: + if str(t) == 'f3.out': + with open('f3.include', 'rb') as f: + fp.write(f.read()) + with open(str(s), 'rb') as f: + fp.write(f.read()) +env = Environment(tools=[]) +bb = Action(batch_build, batch_key=True) +env['BUILDERS']['Batch'] = Builder(action=bb) +env1 = env.Clone() +env1.Batch('f1.out', 'f1.in') +env1.Batch('f2.out', 'f2.mid') +f3_out = env1.Batch('f3.out', 'f3.in') + +env2 = env.Clone() +env2.Batch('f2.mid', 'f2.in') + +f3_include = env.Batch('f3.include', 'f3.include.in') +env.Depends(f3_out, f3_include) +""") + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") +test.write('f3.in', "f3.in\n") +test.write('f3.include.in', "f3.include.in\n") + +expect = test.wrap_stdout("""\ +batch_build(["f2.mid"], ["f2.in"]) +batch_build(["f3.include"], ["f3.include.in"]) +batch_build(["f1.out", "f2.out", "f3.out"], ["f1.in", "f2.mid", "f3.in"]) +""") + +test.run(stdout = expect) + +test.must_match('f1.out', "f1.in\n") +test.must_match('f2.out', "f2.in\n") + +test.up_to_date(arguments = '.') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Batch/removed.py b/test/Batch/removed.py index b64958dda3..60c2fbf852 100644 --- a/test/Batch/removed.py +++ b/test/Batch/removed.py @@ -1,112 +1,112 @@ -#!/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 correct batch builder $CHANGED_SOURCES behavior when some of -the targets have been removed. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -_python_ = TestSCons._python_ - -test.write('batch_build.py', """\ -import os -import sys -dir = sys.argv[1] -for infile in sys.argv[2:]: - inbase = os.path.splitext(os.path.split(infile)[1])[0] - outfile = os.path.join(dir, inbase+'.out') - with open(outfile, 'wb') as f, open(infile, 'rb') as infp: - f.write(infp.read()) -sys.exit(0) -""") - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=[]) -env['BATCH_BUILD'] = 'batch_build.py' -env['BATCHCOM'] = r'%(_python_)s $BATCH_BUILD ${TARGET.dir} $CHANGED_SOURCES' -bb = Action('$BATCHCOM', batch_key=True, targets='CHANGED_TARGETS') -env['BUILDERS']['Batch'] = Builder(action=bb) -env1 = env.Clone() -env1.Batch('out1/f1a.out', 'f1a.in') -env1.Batch('out1/f1b.out', 'f1b.in') -env2 = env.Clone() -env2.Batch('out2/f2a.out', 'f2a.in') -env3 = env.Clone() -env3.Batch('out3/f3a.out', 'f3a.in') -env3.Batch('out3/f3b.out', 'f3b.in') -""" % locals()) - -test.write('f1a.in', "f1a.in\n") -test.write('f1b.in', "f1b.in\n") -test.write('f2a.in', "f2a.in\n") -test.write('f3a.in', "f3a.in\n") -test.write('f3b.in', "f3b.in\n") - -expect = test.wrap_stdout("""\ -%(_python_)s batch_build.py out1 f1a.in f1b.in -%(_python_)s batch_build.py out2 f2a.in -%(_python_)s batch_build.py out3 f3a.in f3b.in -""" % locals()) - -test.run(stdout = expect) - -test.must_match(['out1', 'f1a.out'], "f1a.in\n") -test.must_match(['out1', 'f1b.out'], "f1b.in\n") -test.must_match(['out2', 'f2a.out'], "f2a.in\n") -test.must_match(['out3', 'f3a.out'], "f3a.in\n") -test.must_match(['out3', 'f3b.out'], "f3b.in\n") - -test.up_to_date(options = '--debug=explain', arguments = '.') - -test.unlink(['out1', 'f1b.out']) -test.unlink(['out2', 'f2a.out']) -test.unlink(['out3', 'f3a.out']) - -expect = test.wrap_stdout("""\ -%(_python_)s batch_build.py out1 f1b.in -%(_python_)s batch_build.py out2 f2a.in -%(_python_)s batch_build.py out3 f3a.in -""" % locals()) - -test.run(arguments = '.', stdout = expect) - -test.must_match(['out1', 'f1a.out'], "f1a.in\n") -test.must_match(['out1', 'f1b.out'], "f1b.in\n") -test.must_match(['out2', 'f2a.out'], "f2a.in\n") -test.must_match(['out3', 'f3a.out'], "f3a.in\n") -test.must_match(['out3', 'f3b.out'], "f3b.in\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 correct batch builder $CHANGED_SOURCES behavior when some of +the targets have been removed. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +_python_ = TestSCons._python_ + +test.write('batch_build.py', """\ +import os +import sys +dir = sys.argv[1] +for infile in sys.argv[2:]: + inbase = os.path.splitext(os.path.split(infile)[1])[0] + outfile = os.path.join(dir, inbase+'.out') + with open(outfile, 'wb') as f, open(infile, 'rb') as infp: + f.write(infp.read()) +sys.exit(0) +""") + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) +env['BATCH_BUILD'] = 'batch_build.py' +env['BATCHCOM'] = r'%(_python_)s $BATCH_BUILD ${TARGET.dir} $CHANGED_SOURCES' +bb = Action('$BATCHCOM', batch_key=True, targets='CHANGED_TARGETS') +env['BUILDERS']['Batch'] = Builder(action=bb) +env1 = env.Clone() +env1.Batch('out1/f1a.out', 'f1a.in') +env1.Batch('out1/f1b.out', 'f1b.in') +env2 = env.Clone() +env2.Batch('out2/f2a.out', 'f2a.in') +env3 = env.Clone() +env3.Batch('out3/f3a.out', 'f3a.in') +env3.Batch('out3/f3b.out', 'f3b.in') +""" % locals()) + +test.write('f1a.in', "f1a.in\n") +test.write('f1b.in', "f1b.in\n") +test.write('f2a.in', "f2a.in\n") +test.write('f3a.in', "f3a.in\n") +test.write('f3b.in', "f3b.in\n") + +expect = test.wrap_stdout("""\ +%(_python_)s batch_build.py out1 f1a.in f1b.in +%(_python_)s batch_build.py out2 f2a.in +%(_python_)s batch_build.py out3 f3a.in f3b.in +""" % locals()) + +test.run(stdout = expect) + +test.must_match(['out1', 'f1a.out'], "f1a.in\n") +test.must_match(['out1', 'f1b.out'], "f1b.in\n") +test.must_match(['out2', 'f2a.out'], "f2a.in\n") +test.must_match(['out3', 'f3a.out'], "f3a.in\n") +test.must_match(['out3', 'f3b.out'], "f3b.in\n") + +test.up_to_date(options = '--debug=explain', arguments = '.') + +test.unlink(['out1', 'f1b.out']) +test.unlink(['out2', 'f2a.out']) +test.unlink(['out3', 'f3a.out']) + +expect = test.wrap_stdout("""\ +%(_python_)s batch_build.py out1 f1b.in +%(_python_)s batch_build.py out2 f2a.in +%(_python_)s batch_build.py out3 f3a.in +""" % locals()) + +test.run(arguments = '.', stdout = expect) + +test.must_match(['out1', 'f1a.out'], "f1a.in\n") +test.must_match(['out1', 'f1b.out'], "f1b.in\n") +test.must_match(['out2', 'f2a.out'], "f2a.in\n") +test.must_match(['out3', 'f3a.out'], "f3a.in\n") +test.must_match(['out3', 'f3b.out'], "f3b.in\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/Batch/up_to_date.py b/test/Batch/up_to_date.py index 4ba304b6c0..ae73afbced 100644 --- a/test/Batch/up_to_date.py +++ b/test/Batch/up_to_date.py @@ -1,94 +1,94 @@ -#!/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 simple use of $SOURCES with batch builders correctly decide -that files are up to date on a rebuild. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -_python_ = TestSCons._python_ - -test.write('batch_build.py', """\ -import os -import sys -dir = sys.argv[1] -for infile in sys.argv[2:]: - inbase = os.path.splitext(os.path.split(infile)[1])[0] - outfile = os.path.join(dir, inbase+'.out') - with open(outfile, 'wb') as f, open(infile, 'rb') as infp: - f.write(infp.read()) -sys.exit(0) -""") - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=[]) -env['BATCH_BUILD'] = 'batch_build.py' -env['BATCHCOM'] = r'%(_python_)s $BATCH_BUILD ${TARGET.dir} $SOURCES' -bb = Action('$BATCHCOM', batch_key=True) -env['BUILDERS']['Batch'] = Builder(action=bb) -env1 = env.Clone() -env1.Batch('out1/f1a.out', 'f1a.in') -env1.Batch('out1/f1b.out', 'f1b.in') -env2 = env.Clone() -env2.Batch('out2/f2a.out', 'f2a.in') -env3 = env.Clone() -env3.Batch('out3/f3a.out', 'f3a.in') -env3.Batch('out3/f3b.out', 'f3b.in') -""" % locals()) - -test.write('f1a.in', "f1a.in\n") -test.write('f1b.in', "f1b.in\n") -test.write('f2a.in', "f2a.in\n") -test.write('f3a.in', "f3a.in\n") -test.write('f3b.in', "f3b.in\n") - -expect = test.wrap_stdout("""\ -%(_python_)s batch_build.py out1 f1a.in f1b.in -%(_python_)s batch_build.py out2 f2a.in -%(_python_)s batch_build.py out3 f3a.in f3b.in -""" % locals()) - -test.run(stdout = expect) - -test.must_match(['out1', 'f1a.out'], "f1a.in\n") -test.must_match(['out1', 'f1b.out'], "f1b.in\n") -test.must_match(['out2', 'f2a.out'], "f2a.in\n") -test.must_match(['out3', 'f3a.out'], "f3a.in\n") -test.must_match(['out3', 'f3b.out'], "f3b.in\n") - -test.up_to_date(options = '--debug=explain', 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. + +""" +Verify simple use of $SOURCES with batch builders correctly decide +that files are up to date on a rebuild. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +_python_ = TestSCons._python_ + +test.write('batch_build.py', """\ +import os +import sys +dir = sys.argv[1] +for infile in sys.argv[2:]: + inbase = os.path.splitext(os.path.split(infile)[1])[0] + outfile = os.path.join(dir, inbase+'.out') + with open(outfile, 'wb') as f, open(infile, 'rb') as infp: + f.write(infp.read()) +sys.exit(0) +""") + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) +env['BATCH_BUILD'] = 'batch_build.py' +env['BATCHCOM'] = r'%(_python_)s $BATCH_BUILD ${TARGET.dir} $SOURCES' +bb = Action('$BATCHCOM', batch_key=True) +env['BUILDERS']['Batch'] = Builder(action=bb) +env1 = env.Clone() +env1.Batch('out1/f1a.out', 'f1a.in') +env1.Batch('out1/f1b.out', 'f1b.in') +env2 = env.Clone() +env2.Batch('out2/f2a.out', 'f2a.in') +env3 = env.Clone() +env3.Batch('out3/f3a.out', 'f3a.in') +env3.Batch('out3/f3b.out', 'f3b.in') +""" % locals()) + +test.write('f1a.in', "f1a.in\n") +test.write('f1b.in', "f1b.in\n") +test.write('f2a.in', "f2a.in\n") +test.write('f3a.in', "f3a.in\n") +test.write('f3b.in', "f3b.in\n") + +expect = test.wrap_stdout("""\ +%(_python_)s batch_build.py out1 f1a.in f1b.in +%(_python_)s batch_build.py out2 f2a.in +%(_python_)s batch_build.py out3 f3a.in f3b.in +""" % locals()) + +test.run(stdout = expect) + +test.must_match(['out1', 'f1a.out'], "f1a.in\n") +test.must_match(['out1', 'f1b.out'], "f1b.in\n") +test.must_match(['out2', 'f2a.out'], "f2a.in\n") +test.must_match(['out3', 'f3a.out'], "f3a.in\n") +test.must_match(['out3', 'f3b.out'], "f3b.in\n") + +test.up_to_date(options = '--debug=explain', 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/Builder/TargetSubst.py b/test/Builder/TargetSubst.py index 3983eee174..de4d724f7d 100644 --- a/test/Builder/TargetSubst.py +++ b/test/Builder/TargetSubst.py @@ -1,52 +1,52 @@ -#!/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 ensure_suffix argument to causes us to add the suffix -configured for the Builder even if it looks like the target already has -a different suffix. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -env = Environment(tools=[]) -builder = Builder(action=Copy('$TARGET', '$SOURCE')) -tgt = builder(env, target="${SOURCE}.out", source="infile") -""") - -test.write('infile', "infile\n") -test.run(arguments = '.') -test.must_match('infile.out', "infile\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 the ensure_suffix argument to causes us to add the suffix +configured for the Builder even if it looks like the target already has +a different suffix. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) +builder = Builder(action=Copy('$TARGET', '$SOURCE')) +tgt = builder(env, target="${SOURCE}.out", source="infile") +""") + +test.write('infile', "infile\n") +test.run(arguments = '.') +test.must_match('infile.out', "infile\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/Builder/add_src_builder.py b/test/Builder/add_src_builder.py index 78e30069c4..733d1b92a2 100644 --- a/test/Builder/add_src_builder.py +++ b/test/Builder/add_src_builder.py @@ -1,71 +1,71 @@ -#!/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 can call add_src_builder() to add a builder to -another on the fly. - -This used to trigger infinite recursion (issue 1681) because the -same src_builder list object was being re-used between all Builder -objects that weren't initialized with a separate src_builder. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -copy_out = Builder(action = Copy('$TARGET', '$SOURCE'), - suffix = '.out', - src_suffix = '.mid') - -copy_mid = Builder(action = Copy('$TARGET', '$SOURCE'), - suffix = '.mid', \ - src_suffix = '.in') - -env = Environment(tools=[]) -env['BUILDERS']['CopyOut'] = copy_out -env['BUILDERS']['CopyMid'] = copy_mid - -copy_out.add_src_builder(copy_mid) - -env.CopyOut('file1.out', 'file1.in') -""") - -test.write('file1.in', "file1.in\n") - -test.run() - -test.must_match('file1.mid', "file1.in\n") -test.must_match('file1.out', "file1.in\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 we can call add_src_builder() to add a builder to +another on the fly. + +This used to trigger infinite recursion (issue 1681) because the +same src_builder list object was being re-used between all Builder +objects that weren't initialized with a separate src_builder. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +copy_out = Builder(action = Copy('$TARGET', '$SOURCE'), + suffix = '.out', + src_suffix = '.mid') + +copy_mid = Builder(action = Copy('$TARGET', '$SOURCE'), + suffix = '.mid', \ + src_suffix = '.in') + +env = Environment(tools=[]) +env['BUILDERS']['CopyOut'] = copy_out +env['BUILDERS']['CopyMid'] = copy_mid + +copy_out.add_src_builder(copy_mid) + +env.CopyOut('file1.out', 'file1.in') +""") + +test.write('file1.in', "file1.in\n") + +test.run() + +test.must_match('file1.mid', "file1.in\n") +test.must_match('file1.out', "file1.in\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/Builder/different-actions.py b/test/Builder/different-actions.py index c7191bf097..457639121a 100644 --- a/test/Builder/different-actions.py +++ b/test/Builder/different-actions.py @@ -1,58 +1,58 @@ -#!/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 two builders in two environments with different -actions generate an error. -""" - -import TestSCons - -test = TestSCons.TestSCons(match=TestSCons.match_re) - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -e1 = Environment(tools=[]) -e2 = Environment(tools=[]) - -e1.Command('out.txt', [], 'echo 1 > $TARGET') -e2.Command('out.txt', [], 'echo 2 > $TARGET') -""",'w') - -expect = TestSCons.re_escape(""" -scons: *** Two environments with different actions were specified for the same target: out.txt -(action 1: echo 1 > out.txt) -(action 2: echo 2 > out.txt) -""") + TestSCons.file_expr - -test.run(arguments='out.txt', status=2, stderr=expect) - -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 two builders in two environments with different +actions generate an error. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +e1 = Environment(tools=[]) +e2 = Environment(tools=[]) + +e1.Command('out.txt', [], 'echo 1 > $TARGET') +e2.Command('out.txt', [], 'echo 2 > $TARGET') +""",'w') + +expect = TestSCons.re_escape(""" +scons: *** Two environments with different actions were specified for the same target: out.txt +(action 1: echo 1 > out.txt) +(action 2: echo 2 > out.txt) +""") + TestSCons.file_expr + +test.run(arguments='out.txt', status=2, stderr=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Builder/ensure_suffix.py b/test/Builder/ensure_suffix.py index 94a7e1f5ed..08cf16e354 100644 --- a/test/Builder/ensure_suffix.py +++ b/test/Builder/ensure_suffix.py @@ -1,61 +1,61 @@ -#!/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 ensure_suffix argument to causes us to add the suffix -configured for the Builder even if it looks like the target already has -a different suffix. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -env = Environment(tools=[]) - -tbuilder = Builder(action=Copy('$TARGET', '$SOURCE'), - suffix='.dll', - ensure_suffix=True) - -env['BUILDERS']['TBuilder'] = tbuilder - -env.TBuilder("aa.bb.cc.dd","aa.aa.txt") -""") - -test.write('aa.aa.txt', "clean test\n") - -test.run(arguments = '.') - -test.must_match('aa.bb.cc.dd.dll', "clean test\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 the ensure_suffix argument to causes us to add the suffix +configured for the Builder even if it looks like the target already has +a different suffix. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) + +tbuilder = Builder(action=Copy('$TARGET', '$SOURCE'), + suffix='.dll', + ensure_suffix=True) + +env['BUILDERS']['TBuilder'] = tbuilder + +env.TBuilder("aa.bb.cc.dd","aa.aa.txt") +""") + +test.write('aa.aa.txt', "clean test\n") + +test.run(arguments = '.') + +test.must_match('aa.bb.cc.dd.dll', "clean test\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/Builder/non-multi.py b/test/Builder/non-multi.py index cdbd5b044f..d540f6bf8b 100644 --- a/test/Builder/non-multi.py +++ b/test/Builder/non-multi.py @@ -1,67 +1,67 @@ -#!/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 a builder without "multi" set can still be called multiple -times if the calls are the same. -""" - -import TestSCons - -test = TestSCons.TestSCons(match=TestSCons.match_re) - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) - -def build(env, target, source): - with open(str(target[0]), 'wb') as f: - for s in source: - with open(str(s), 'rb') as infp: - f.write(infp.read()) - -B = Builder(action=build, multi=0) -env = Environment(tools=[], BUILDERS = { 'B' : B }) -env.B(target = 'file7.out', source = 'file7.in') -env.B(target = 'file7.out', source = 'file7.in') -env.B(target = 'file8.out', source = 'file8.in', arg=1) -env.B(target = 'file8.out', source = 'file8.in', arg=1) -""") - -test.write('file7.in', 'file7.in\n') -test.write('file8.in', 'file8.in\n') - -test.run(arguments='file7.out') -test.run(arguments='file8.out') - -test.must_match('file7.out', "file7.in\n") -test.must_match('file8.out', "file8.in\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 a builder without "multi" set can still be called multiple +times if the calls are the same. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + +def build(env, target, source): + with open(str(target[0]), 'wb') as f: + for s in source: + with open(str(s), 'rb') as infp: + f.write(infp.read()) + +B = Builder(action=build, multi=0) +env = Environment(tools=[], BUILDERS = { 'B' : B }) +env.B(target = 'file7.out', source = 'file7.in') +env.B(target = 'file7.out', source = 'file7.in') +env.B(target = 'file8.out', source = 'file8.in', arg=1) +env.B(target = 'file8.out', source = 'file8.in', arg=1) +""") + +test.write('file7.in', 'file7.in\n') +test.write('file8.in', 'file8.in\n') + +test.run(arguments='file7.out') +test.run(arguments='file8.out') + +test.must_match('file7.out', "file7.in\n") +test.must_match('file8.out', "file8.in\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/Builder/not-a-Builder.py b/test/Builder/not-a-Builder.py index 2cee0aaef7..f0a16b3654 100644 --- a/test/Builder/not-a-Builder.py +++ b/test/Builder/not-a-Builder.py @@ -1,60 +1,60 @@ -#!/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 the error when trying to configure a Builder with a non-Builder object. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -SConstruct_path = test.workpath('SConstruct') - -test.write(SConstruct_path, """\ -def mkdir(env, target, source): - return None -mkdir = 1 -env = Environment(BUILDERS={'mkdir': 1}) -env.mkdir(env.Dir('src'), None) -""") - -expect_stderr = """\ - -scons: *** 1 is not a Builder. -""" + test.python_file_line(SConstruct_path, 4) - -test.run(arguments='.', - stderr=expect_stderr, - status=2) - - -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 the error when trying to configure a Builder with a non-Builder object. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +SConstruct_path = test.workpath('SConstruct') + +test.write(SConstruct_path, """\ +def mkdir(env, target, source): + return None +mkdir = 1 +env = Environment(BUILDERS={'mkdir': 1}) +env.mkdir(env.Dir('src'), None) +""") + +expect_stderr = """\ + +scons: *** 1 is not a Builder. +""" + test.python_file_line(SConstruct_path, 4) + +test.run(arguments='.', + stderr=expect_stderr, + status=2) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Builder/same-actions-diff-envs.py b/test/Builder/same-actions-diff-envs.py index f3bff437c3..709b10850f 100644 --- a/test/Builder/same-actions-diff-envs.py +++ b/test/Builder/same-actions-diff-envs.py @@ -1,63 +1,63 @@ -#!/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 two builders in two environments with the same actions generate -a warning -""" - -import TestSCons - -test = TestSCons.TestSCons(match=TestSCons.match_re) - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) - -def build(env, target, source): - with open(str(target[0]), 'w') as f: - f.write('1') - -B = Builder(action=build) -env = Environment(tools=[], BUILDERS = { 'B' : B }) -env2 = Environment(tools=[], BUILDERS = { 'B' : B }) -env.B('out.txt', []) -env2.B('out.txt', []) -""") - -expect = TestSCons.re_escape(""" -scons: warning: Two different environments were specified for target out.txt, -\tbut they appear to have the same action: build(target, source, env) -""") + TestSCons.file_expr - -test.run(arguments='out.txt', status=0, stderr=expect) -test.must_match('out.txt', '1') - -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 two builders in two environments with the same actions generate +a warning +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) + +def build(env, target, source): + with open(str(target[0]), 'w') as f: + f.write('1') + +B = Builder(action=build) +env = Environment(tools=[], BUILDERS = { 'B' : B }) +env2 = Environment(tools=[], BUILDERS = { 'B' : B }) +env.B('out.txt', []) +env2.B('out.txt', []) +""") + +expect = TestSCons.re_escape(""" +scons: warning: Two different environments were specified for target out.txt, +\tbut they appear to have the same action: build(target, source, env) +""") + TestSCons.file_expr + +test.run(arguments='out.txt', status=0, stderr=expect) +test.must_match('out.txt', '1') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Builder/same-actions-diff-overrides.py b/test/Builder/same-actions-diff-overrides.py index 596c8687f2..ba3ee9078d 100644 --- a/test/Builder/same-actions-diff-overrides.py +++ b/test/Builder/same-actions-diff-overrides.py @@ -1,62 +1,62 @@ -#!/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 two calls to a builder with different overrides, but the same -action, generate a warning -""" - -import TestSCons - -test = TestSCons.TestSCons(match=TestSCons.match_re) - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) - -def build(env, target, source): - with open(str(target[0]), 'w') as f: - f.write('1') - -B = Builder(action=build) -env = Environment(tools=[], BUILDERS = { 'B' : B }) -env.B('out.txt', [], arg=1) -env.B('out.txt', [], arg=2) -""") - -expect = TestSCons.re_escape(""" -scons: warning: Two different environments were specified for target out.txt, -\tbut they appear to have the same action: build(target, source, env) -""") + TestSCons.file_expr - -test.run(arguments='out.txt', status=0, stderr=expect) -test.must_match('out.txt', '1') - -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 two calls to a builder with different overrides, but the same +action, generate a warning +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) + +def build(env, target, source): + with open(str(target[0]), 'w') as f: + f.write('1') + +B = Builder(action=build) +env = Environment(tools=[], BUILDERS = { 'B' : B }) +env.B('out.txt', [], arg=1) +env.B('out.txt', [], arg=2) +""") + +expect = TestSCons.re_escape(""" +scons: warning: Two different environments were specified for target out.txt, +\tbut they appear to have the same action: build(target, source, env) +""") + TestSCons.file_expr + +test.run(arguments='out.txt', status=0, stderr=expect) +test.must_match('out.txt', '1') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Builder/srcdir.py b/test/Builder/srcdir.py index 0ce6b5e0a0..d084f9380c 100644 --- a/test/Builder/srcdir.py +++ b/test/Builder/srcdir.py @@ -1,83 +1,83 @@ -#!/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 specifying a srcdir when calling a Builder correctly -prefixes each relative-path string with the specified srcdir. -""" - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.subdir('src', ['src', 'foo']) - -file3 = test.workpath('file3') - -test.write(['src', 'cat.py'], """\ -import sys -with open(sys.argv[1], 'wb') as o: - for f in sys.argv[2:]: - with open(f, 'rb') as i: - o.write(i.read()) -""") - -test.write(['src', 'SConstruct'], """\ -DefaultEnvironment(tools=[]) - -Command('output', - ['file1', File('file2'), r'%(file3)s', 'file4'], - r'%(_python_)s cat.py $TARGET $SOURCES', - srcdir='foo') -""" % locals()) - -test.write(['src', 'foo', 'file1'], "file1\n") - -test.write(['src', 'file2'], "file2\n") - -test.write(file3, "file3\n") - -test.write(['src', 'foo', 'file4'], "file4\n") - -test.run(chdir = 'src', arguments = '.') - -expected = """\ -file1 -file2 -file3 -file4 -""" - -test.must_match(['src', 'output'], expected) - -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 specifying a srcdir when calling a Builder correctly +prefixes each relative-path string with the specified srcdir. +""" + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.subdir('src', ['src', 'foo']) + +file3 = test.workpath('file3') + +test.write(['src', 'cat.py'], """\ +import sys +with open(sys.argv[1], 'wb') as o: + for f in sys.argv[2:]: + with open(f, 'rb') as i: + o.write(i.read()) +""") + +test.write(['src', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) + +Command('output', + ['file1', File('file2'), r'%(file3)s', 'file4'], + r'%(_python_)s cat.py $TARGET $SOURCES', + srcdir='foo') +""" % locals()) + +test.write(['src', 'foo', 'file1'], "file1\n") + +test.write(['src', 'file2'], "file2\n") + +test.write(file3, "file3\n") + +test.write(['src', 'foo', 'file4'], "file4\n") + +test.run(chdir = 'src', arguments = '.') + +expected = """\ +file1 +file2 +file3 +file4 +""" + +test.must_match(['src', 'output'], expected) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Builder/wrapper.py b/test/Builder/wrapper.py index d68a6cab61..60f8b21baa 100644 --- a/test/Builder/wrapper.py +++ b/test/Builder/wrapper.py @@ -1,77 +1,77 @@ -#!/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 the ability to use a direct Python function to wrap -calls to other Builder(s). -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) - -import os.path -import string -def cat(target, source, env): - with open(str(target[0]), 'wb') as fp: - for s in map(str, source): - with open(s, 'rb') as infp: - fp.write(infp.read()) -Cat = Builder(action=cat) -def Wrapper(env, target, source): - if not target: - target = [str(source[0]).replace('.in', '.wout')] - t1 = 't1-'+str(target[0]) - source = 's-'+str(source[0]) - env.Cat(t1, source) - t2 = 't2-'+str(target[0]) - env.Cat(t2, source) -env = Environment(tools=[], - BUILDERS = {'Cat' : Cat, - 'Wrapper' : Wrapper}) -env.Wrapper('f1.out', 'f1.in') -env.Wrapper('f2.in') -""") - -test.write('s-f1.in', "s-f1.in\n") -test.write('s-f2.in', "s-f2.in\n") - -test.run() - -test.must_match('t1-f1.out', "s-f1.in\n") -test.must_match('t1-f2.wout', "s-f2.in\n") -test.must_match('t2-f1.out', "s-f1.in\n") -test.must_match('t2-f2.wout', "s-f2.in\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. + +""" +Test the ability to use a direct Python function to wrap +calls to other Builder(s). +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) + +import os.path +import string +def cat(target, source, env): + with open(str(target[0]), 'wb') as fp: + for s in map(str, source): + with open(s, 'rb') as infp: + fp.write(infp.read()) +Cat = Builder(action=cat) +def Wrapper(env, target, source): + if not target: + target = [str(source[0]).replace('.in', '.wout')] + t1 = 't1-'+str(target[0]) + source = 's-'+str(source[0]) + env.Cat(t1, source) + t2 = 't2-'+str(target[0]) + env.Cat(t2, source) +env = Environment(tools=[], + BUILDERS = {'Cat' : Cat, + 'Wrapper' : Wrapper}) +env.Wrapper('f1.out', 'f1.in') +env.Wrapper('f2.in') +""") + +test.write('s-f1.in', "s-f1.in\n") +test.write('s-f2.in', "s-f2.in\n") + +test.run() + +test.must_match('t1-f1.out', "s-f1.in\n") +test.must_match('t1-f2.wout', "s-f2.in\n") +test.must_match('t2-f1.out', "s-f1.in\n") +test.must_match('t2-f2.wout', "s-f2.in\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/CC/CCCOM.py b/test/CC/CCCOM.py index 717b36f984..9ee49b446b 100644 --- a/test/CC/CCCOM.py +++ b/test/CC/CCCOM.py @@ -1,72 +1,72 @@ -#!/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 the ability to configure the $CCCOM construction variable. -""" - -import os - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.file_fixture('mycompile.py') - -if os.path.normcase('.c') == os.path.normcase('.C'): - alt_c_suffix = '.C' -else: - alt_c_suffix = '.c' - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=['cc'], - CCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', - OBJSUFFIX='.obj') -env.Object(target = 'test1', source = 'test1.c') -env.Object(target = 'test2', source = 'test2%(alt_c_suffix)s') -""" % locals()) - -test.write('test1.c', 'test1.c\n/*cc*/\n') - -test.write('test2'+alt_c_suffix, """\ -test2.C -/*cc*/ -""") - -test.run() - -test.must_match('test1.obj', "test1.c\n") -test.must_match('test2.obj', "test2.C\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. + +""" +Test the ability to configure the $CCCOM construction variable. +""" + +import os + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.file_fixture('mycompile.py') + +if os.path.normcase('.c') == os.path.normcase('.C'): + alt_c_suffix = '.C' +else: + alt_c_suffix = '.c' + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=['cc'], + CCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', + OBJSUFFIX='.obj') +env.Object(target = 'test1', source = 'test1.c') +env.Object(target = 'test2', source = 'test2%(alt_c_suffix)s') +""" % locals()) + +test.write('test1.c', 'test1.c\n/*cc*/\n') + +test.write('test2'+alt_c_suffix, """\ +test2.C +/*cc*/ +""") + +test.run() + +test.must_match('test1.obj', "test1.c\n") +test.must_match('test2.obj', "test2.C\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/CC/CCCOMSTR.py b/test/CC/CCCOMSTR.py index 55d1db26d7..da07dd3d44 100644 --- a/test/CC/CCCOMSTR.py +++ b/test/CC/CCCOMSTR.py @@ -1,77 +1,77 @@ -#!/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 $CCCOMSTR construction variable allows you to configure -the C compilation output. -""" - -import os - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.file_fixture('mycompile.py') - -if os.path.normcase('.c') == os.path.normcase('.C'): - alt_c_suffix = '.C' -else: - alt_c_suffix = '.c' - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=['cc'], - CCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', - CCCOMSTR = 'Building $TARGET from $SOURCE', - OBJSUFFIX='.obj') -env.Object(target = 'test1', source = 'test1.c') -env.Object(target = 'test2', source = 'test2%(alt_c_suffix)s') -""" % locals()) - -test.write('test1.c', 'test1.c\n/*cc*/\n') - -test.write('test2'+alt_c_suffix, """\ -test2.C -/*cc*/ -""") - -test.run(stdout = test.wrap_stdout("""\ -Building test1.obj from test1.c -Building test2.obj from test2%(alt_c_suffix)s -""" % locals())) - -test.must_match('test1.obj', "test1.c\n") -test.must_match('test2.obj', "test2.C\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. + +""" +Test that the $CCCOMSTR construction variable allows you to configure +the C compilation output. +""" + +import os + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.file_fixture('mycompile.py') + +if os.path.normcase('.c') == os.path.normcase('.C'): + alt_c_suffix = '.C' +else: + alt_c_suffix = '.c' + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=['cc'], + CCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', + CCCOMSTR = 'Building $TARGET from $SOURCE', + OBJSUFFIX='.obj') +env.Object(target = 'test1', source = 'test1.c') +env.Object(target = 'test2', source = 'test2%(alt_c_suffix)s') +""" % locals()) + +test.write('test1.c', 'test1.c\n/*cc*/\n') + +test.write('test2'+alt_c_suffix, """\ +test2.C +/*cc*/ +""") + +test.run(stdout = test.wrap_stdout("""\ +Building test1.obj from test1.c +Building test2.obj from test2%(alt_c_suffix)s +""" % locals())) + +test.must_match('test1.obj', "test1.c\n") +test.must_match('test2.obj', "test2.C\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/CC/CCFLAGS.py b/test/CC/CCFLAGS.py index 8afa3b342f..7269b9cf24 100644 --- a/test/CC/CCFLAGS.py +++ b/test/CC/CCFLAGS.py @@ -1,111 +1,111 @@ -#!/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. - -import sys -import TestSCons - -_obj = TestSCons._obj - -if sys.platform == 'win32': - import SCons.Tool.MSCommon as msc - - if not msc.msvc_exists(): - fooflags = '-DFOO' - barflags = '-DBAR' - else: - fooflags = '/nologo -DFOO' - barflags = '/nologo -DBAR' -else: - fooflags = '-DFOO' - barflags = '-DBAR' - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -DefaultEnvironment(tool=[]) -foo = Environment(CCFLAGS = '%s') -bar = Environment(CCFLAGS = '%s') -foo.Object(target = 'foo%s', source = 'prog.c') -bar.Object(target = 'bar%s', source = 'prog.c') -foo.Program(target = 'foo', source = 'foo%s') -bar.Program(target = 'bar', source = 'bar%s') -foo.Program(target = 'prog', source = 'prog.c', - CCFLAGS = '$CCFLAGS -DBAR $BAZ', BAZ = '-DBAZ') -""" % (fooflags, barflags, _obj, _obj, _obj, _obj)) - -test.write('prog.c', r""" -#include -#include - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; -#ifdef FOO - printf("prog.c: FOO\n"); -#endif -#ifdef BAR - printf("prog.c: BAR\n"); -#endif -#ifdef BAZ - printf("prog.c: BAZ\n"); -#endif - exit (0); -} -""") - - -test.run(arguments = '.') - -test.run(program = test.workpath('foo'), stdout = "prog.c: FOO\n") -test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n") -test.run(program = test.workpath('prog'), stdout = """\ -prog.c: FOO -prog.c: BAR -prog.c: BAZ -""") - -test.write('SConstruct', """ -DefaultEnvironment(tool=[]) - -bar = Environment(CCFLAGS = '%s') -bar.Object(target = 'foo%s', source = 'prog.c') -bar.Object(target = 'bar%s', source = 'prog.c') -bar.Program(target = 'foo', source = 'foo%s') -bar.Program(target = 'bar', source = 'bar%s') -""" % (barflags, _obj, _obj, _obj, _obj)) - -test.run(arguments = '.') - -test.run(program = test.workpath('foo'), stdout = "prog.c: BAR\n") -test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\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. + +import sys +import TestSCons + +_obj = TestSCons._obj + +if sys.platform == 'win32': + import SCons.Tool.MSCommon as msc + + if not msc.msvc_exists(): + fooflags = '-DFOO' + barflags = '-DBAR' + else: + fooflags = '/nologo -DFOO' + barflags = '/nologo -DBAR' +else: + fooflags = '-DFOO' + barflags = '-DBAR' + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +DefaultEnvironment(tool=[]) +foo = Environment(CCFLAGS = '%s') +bar = Environment(CCFLAGS = '%s') +foo.Object(target = 'foo%s', source = 'prog.c') +bar.Object(target = 'bar%s', source = 'prog.c') +foo.Program(target = 'foo', source = 'foo%s') +bar.Program(target = 'bar', source = 'bar%s') +foo.Program(target = 'prog', source = 'prog.c', + CCFLAGS = '$CCFLAGS -DBAR $BAZ', BAZ = '-DBAZ') +""" % (fooflags, barflags, _obj, _obj, _obj, _obj)) + +test.write('prog.c', r""" +#include +#include + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; +#ifdef FOO + printf("prog.c: FOO\n"); +#endif +#ifdef BAR + printf("prog.c: BAR\n"); +#endif +#ifdef BAZ + printf("prog.c: BAZ\n"); +#endif + exit (0); +} +""") + + +test.run(arguments = '.') + +test.run(program = test.workpath('foo'), stdout = "prog.c: FOO\n") +test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n") +test.run(program = test.workpath('prog'), stdout = """\ +prog.c: FOO +prog.c: BAR +prog.c: BAZ +""") + +test.write('SConstruct', """ +DefaultEnvironment(tool=[]) + +bar = Environment(CCFLAGS = '%s') +bar.Object(target = 'foo%s', source = 'prog.c') +bar.Object(target = 'bar%s', source = 'prog.c') +bar.Program(target = 'foo', source = 'foo%s') +bar.Program(target = 'bar', source = 'bar%s') +""" % (barflags, _obj, _obj, _obj, _obj)) + +test.run(arguments = '.') + +test.run(program = test.workpath('foo'), stdout = "prog.c: BAR\n") +test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\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/CC/CFLAGS.py b/test/CC/CFLAGS.py index 59ac137b6c..19ae2641df 100644 --- a/test/CC/CFLAGS.py +++ b/test/CC/CFLAGS.py @@ -1,124 +1,124 @@ -#!/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. - -import sys -import TestSCons - -test = TestSCons.TestSCons() - -# Make sure CFLAGS is not passed to CXX by just expanding CXXCOM -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(CFLAGS='-xyz', CCFLAGS='-abc') -print(env.subst('$CXXCOM')) -print(env.subst('$CXXCOMSTR')) -print(env.subst('$SHCXXCOM')) -print(env.subst('$SHCXXCOMSTR')) -""") -test.run(arguments = '.') -test.must_not_contain_any_line(test.stdout(), ["-xyz"]) -test.must_contain_all_lines(test.stdout(), ["-abc"]) - -_obj = TestSCons._obj - -# Test passing CFLAGS to C compiler by actually compiling programs -if sys.platform == 'win32': - import SCons.Tool.MSCommon as msc - - if not msc.msvc_exists(): - fooflags = '-DFOO' - barflags = '-DBAR' - else: - fooflags = '/nologo -DFOO' - barflags = '/nologo -DBAR' -else: - fooflags = '-DFOO' - barflags = '-DBAR' - - -test.write('SConstruct', """ -foo = Environment(CFLAGS = '%s') -bar = Environment(CFLAGS = '%s') -foo.Object(target = 'foo%s', source = 'prog.c') -bar.Object(target = 'bar%s', source = 'prog.c') -foo.Program(target = 'foo', source = 'foo%s') -bar.Program(target = 'bar', source = 'bar%s') -foo.Program(target = 'prog', source = 'prog.c', - CFLAGS = '$CFLAGS -DBAR $BAZ', BAZ = '-DBAZ') -""" % (fooflags, barflags, _obj, _obj, _obj, _obj)) - -test.write('prog.c', r""" -#include -#include - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; -#ifdef FOO - printf("prog.c: FOO\n"); -#endif -#ifdef BAR - printf("prog.c: BAR\n"); -#endif -#ifdef BAZ - printf("prog.c: BAZ\n"); -#endif - exit (0); -} -""") - - - -test.run(arguments = '.') - -test.run(program = test.workpath('foo'), stdout = "prog.c: FOO\n") -test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n") -test.run(program = test.workpath('prog'), stdout = """\ -prog.c: FOO -prog.c: BAR -prog.c: BAZ -""") - -test.write('SConstruct', """ -bar = Environment(CFLAGS = '%s') -bar.Object(target = 'foo%s', source = 'prog.c') -bar.Object(target = 'bar%s', source = 'prog.c') -bar.Program(target = 'foo', source = 'foo%s') -bar.Program(target = 'bar', source = 'bar%s') -""" % (barflags, _obj, _obj, _obj, _obj)) - -test.run(arguments = '.') - -test.run(program = test.workpath('foo'), stdout = "prog.c: BAR\n") -test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\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. + +import sys +import TestSCons + +test = TestSCons.TestSCons() + +# Make sure CFLAGS is not passed to CXX by just expanding CXXCOM +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(CFLAGS='-xyz', CCFLAGS='-abc') +print(env.subst('$CXXCOM')) +print(env.subst('$CXXCOMSTR')) +print(env.subst('$SHCXXCOM')) +print(env.subst('$SHCXXCOMSTR')) +""") +test.run(arguments = '.') +test.must_not_contain_any_line(test.stdout(), ["-xyz"]) +test.must_contain_all_lines(test.stdout(), ["-abc"]) + +_obj = TestSCons._obj + +# Test passing CFLAGS to C compiler by actually compiling programs +if sys.platform == 'win32': + import SCons.Tool.MSCommon as msc + + if not msc.msvc_exists(): + fooflags = '-DFOO' + barflags = '-DBAR' + else: + fooflags = '/nologo -DFOO' + barflags = '/nologo -DBAR' +else: + fooflags = '-DFOO' + barflags = '-DBAR' + + +test.write('SConstruct', """ +foo = Environment(CFLAGS = '%s') +bar = Environment(CFLAGS = '%s') +foo.Object(target = 'foo%s', source = 'prog.c') +bar.Object(target = 'bar%s', source = 'prog.c') +foo.Program(target = 'foo', source = 'foo%s') +bar.Program(target = 'bar', source = 'bar%s') +foo.Program(target = 'prog', source = 'prog.c', + CFLAGS = '$CFLAGS -DBAR $BAZ', BAZ = '-DBAZ') +""" % (fooflags, barflags, _obj, _obj, _obj, _obj)) + +test.write('prog.c', r""" +#include +#include + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; +#ifdef FOO + printf("prog.c: FOO\n"); +#endif +#ifdef BAR + printf("prog.c: BAR\n"); +#endif +#ifdef BAZ + printf("prog.c: BAZ\n"); +#endif + exit (0); +} +""") + + + +test.run(arguments = '.') + +test.run(program = test.workpath('foo'), stdout = "prog.c: FOO\n") +test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n") +test.run(program = test.workpath('prog'), stdout = """\ +prog.c: FOO +prog.c: BAR +prog.c: BAZ +""") + +test.write('SConstruct', """ +bar = Environment(CFLAGS = '%s') +bar.Object(target = 'foo%s', source = 'prog.c') +bar.Object(target = 'bar%s', source = 'prog.c') +bar.Program(target = 'foo', source = 'foo%s') +bar.Program(target = 'bar', source = 'bar%s') +""" % (barflags, _obj, _obj, _obj, _obj)) + +test.run(arguments = '.') + +test.run(program = test.workpath('foo'), stdout = "prog.c: BAR\n") +test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\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/CC/SHCCCOM.py b/test/CC/SHCCCOM.py index 55ff1e1ff4..eb05e9cd02 100644 --- a/test/CC/SHCCCOM.py +++ b/test/CC/SHCCCOM.py @@ -1,72 +1,72 @@ -#!/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. - -import os - -import TestSCons - -""" -Test the ability to configure the $SHCCCOM construction variable. -""" - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.file_fixture('mycompile.py') - -if os.path.normcase('.c') == os.path.normcase('.C'): - alt_c_suffix = '.C' -else: - alt_c_suffix = '.c' - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(SHCCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', - SHOBJPREFIX='', - SHOBJSUFFIX='.obj') -env.SharedObject(target = 'test1', source = 'test1.c') -env.SharedObject(target = 'test2', source = 'test2%(alt_c_suffix)s') -""" % locals()) - -test.write('test1.c', 'test1.c\n/*cc*/\n') - -test.write('test2'+alt_c_suffix, """\ -test2.C -/*cc*/ -""") - -test.run() - -test.must_match('test1.obj', "test1.c\n") -test.must_match('test2.obj', "test2.C\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. + +import os + +import TestSCons + +""" +Test the ability to configure the $SHCCCOM construction variable. +""" + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.file_fixture('mycompile.py') + +if os.path.normcase('.c') == os.path.normcase('.C'): + alt_c_suffix = '.C' +else: + alt_c_suffix = '.c' + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(SHCCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', + SHOBJPREFIX='', + SHOBJSUFFIX='.obj') +env.SharedObject(target = 'test1', source = 'test1.c') +env.SharedObject(target = 'test2', source = 'test2%(alt_c_suffix)s') +""" % locals()) + +test.write('test1.c', 'test1.c\n/*cc*/\n') + +test.write('test2'+alt_c_suffix, """\ +test2.C +/*cc*/ +""") + +test.run() + +test.must_match('test1.obj', "test1.c\n") +test.must_match('test2.obj', "test2.C\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/CC/SHCCCOMSTR.py b/test/CC/SHCCCOMSTR.py index e41de80849..c24f9a93eb 100644 --- a/test/CC/SHCCCOMSTR.py +++ b/test/CC/SHCCCOMSTR.py @@ -1,79 +1,79 @@ -#!/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 $SHCCCOMSTR construction variable allows you to customize -the shared object C compilation output. -""" - -import os - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.file_fixture('mycompile.py') - -if os.path.normcase('.c') == os.path.normcase('.C'): - alt_c_suffix = '.C' -else: - alt_c_suffix = '.c' - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(SHCCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', - SHCCCOMSTR = 'Building $TARGET from $SOURCE', - SHOBJPREFIX='', - SHOBJSUFFIX='.obj') -env.SharedObject(target = 'test1', source = 'test1.c') -env.SharedObject(target = 'test2', source = 'test2%(alt_c_suffix)s') -""" % locals()) - -test.write('test1.c', 'test1.c\n/*cc*/\n') - -test.write('test2'+alt_c_suffix, """\ -test2.C -/*cc*/ -""") - -test.run(stdout = test.wrap_stdout("""\ -Building test1.obj from test1.c -Building test2.obj from test2%(alt_c_suffix)s -""" % locals())) - -test.must_match('test1.obj', "test1.c\n") -test.must_match('test2.obj', "test2.C\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. + +""" +Test that the $SHCCCOMSTR construction variable allows you to customize +the shared object C compilation output. +""" + +import os + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.file_fixture('mycompile.py') + +if os.path.normcase('.c') == os.path.normcase('.C'): + alt_c_suffix = '.C' +else: + alt_c_suffix = '.c' + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(SHCCCOM = r'%(_python_)s mycompile.py cc $TARGET $SOURCE', + SHCCCOMSTR = 'Building $TARGET from $SOURCE', + SHOBJPREFIX='', + SHOBJSUFFIX='.obj') +env.SharedObject(target = 'test1', source = 'test1.c') +env.SharedObject(target = 'test2', source = 'test2%(alt_c_suffix)s') +""" % locals()) + +test.write('test1.c', 'test1.c\n/*cc*/\n') + +test.write('test2'+alt_c_suffix, """\ +test2.C +/*cc*/ +""") + +test.run(stdout = test.wrap_stdout("""\ +Building test1.obj from test1.c +Building test2.obj from test2%(alt_c_suffix)s +""" % locals())) + +test.must_match('test1.obj', "test1.c\n") +test.must_match('test2.obj', "test2.C\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/CC/SHCFLAGS.py b/test/CC/SHCFLAGS.py index b110f59de9..e143713c56 100644 --- a/test/CC/SHCFLAGS.py +++ b/test/CC/SHCFLAGS.py @@ -1,138 +1,138 @@ -#!/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. -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - -import sys -import TestSCons -import os - -test = TestSCons.TestSCons() - -e = test.Environment() -fooflags = e['SHCFLAGS'] + ' -DFOO' -barflags = e['SHCFLAGS'] + ' -DBAR' - -if os.name == 'posix': - os.environ['LD_LIBRARY_PATH'] = '.' -if sys.platform.find('irix') > -1: - os.environ['LD_LIBRARYN32_PATH'] = '.' - -test.write('SConstruct', f""" -DefaultEnvironment(tools=[]) -foo = Environment(SHCFLAGS = '{fooflags}', WINDOWS_INSERT_DEF=1) -bar = Environment(SHCFLAGS = '{barflags}', WINDOWS_INSERT_DEF=1) - -foo_obj = foo.SharedObject(target = 'foo', source = 'prog.c') -foo.SharedLibrary(target = 'foo', source = foo_obj) - -bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c') -bar.SharedLibrary(target = 'bar', source = bar_obj) - -fooMain = foo.Clone(LIBS='foo', LIBPATH='.') -foomain_obj = fooMain.Object(target='foomain', source='main.c') -fooMain.Program(target='fooprog', source=foomain_obj) - -barMain = bar.Clone(LIBS='bar', LIBPATH='.') -barmain_obj = barMain.Object(target='barmain', source='main.c') -barMain.Program(target='barprog', source=barmain_obj) -""") - -test.write('foo.def', r""" -LIBRARY "foo" -DESCRIPTION "Foo Shared Library" - -EXPORTS - doIt -""") - -test.write('bar.def', r""" -LIBRARY "bar" -DESCRIPTION "Bar Shared Library" - -EXPORTS - doIt -""") - -test.write('prog.c', r""" -#include - -void -doIt() -{ -#ifdef FOO - printf("prog.c: FOO\n"); -#endif -#ifdef BAR - printf("prog.c: BAR\n"); -#endif -} -""") - -test.write('main.c', r""" - -void doIt(); - -int -main(int argc, char* argv[]) -{ - doIt(); - return 0; -} -""") - -test.run(arguments = '.') - -test.run(program = test.workpath('fooprog'), stdout = "prog.c: FOO\n") -test.run(program = test.workpath('barprog'), stdout = "prog.c: BAR\n") - -test.write('SConstruct', f""" -DefaultEnvironment(tools=[]) -bar = Environment(SHCFLAGS = '{barflags}', WINDOWS_INSERT_DEF=1) - -foo_obj = bar.SharedObject(target = 'foo', source = 'prog.c') -bar.SharedLibrary(target = 'foo', source = foo_obj) - -bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c') -bar.SharedLibrary(target = 'bar', source = bar_obj) - -barMain = bar.Clone(LIBS='bar', LIBPATH='.') -foomain_obj = barMain.Object(target='foomain', source='main.c') -barmain_obj = barMain.Object(target='barmain', source='main.c') -barMain.Program(target='barprog', source=foomain_obj) -barMain.Program(target='fooprog', source=barmain_obj) -""") - -test.run(arguments = '.') - -test.run(program = test.workpath('fooprog'), stdout = "prog.c: BAR\n") -test.run(program = test.workpath('barprog'), stdout = "prog.c: BAR\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. +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import sys +import TestSCons +import os + +test = TestSCons.TestSCons() + +e = test.Environment() +fooflags = e['SHCFLAGS'] + ' -DFOO' +barflags = e['SHCFLAGS'] + ' -DBAR' + +if os.name == 'posix': + os.environ['LD_LIBRARY_PATH'] = '.' +if sys.platform.find('irix') > -1: + os.environ['LD_LIBRARYN32_PATH'] = '.' + +test.write('SConstruct', f""" +DefaultEnvironment(tools=[]) +foo = Environment(SHCFLAGS = '{fooflags}', WINDOWS_INSERT_DEF=1) +bar = Environment(SHCFLAGS = '{barflags}', WINDOWS_INSERT_DEF=1) + +foo_obj = foo.SharedObject(target = 'foo', source = 'prog.c') +foo.SharedLibrary(target = 'foo', source = foo_obj) + +bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c') +bar.SharedLibrary(target = 'bar', source = bar_obj) + +fooMain = foo.Clone(LIBS='foo', LIBPATH='.') +foomain_obj = fooMain.Object(target='foomain', source='main.c') +fooMain.Program(target='fooprog', source=foomain_obj) + +barMain = bar.Clone(LIBS='bar', LIBPATH='.') +barmain_obj = barMain.Object(target='barmain', source='main.c') +barMain.Program(target='barprog', source=barmain_obj) +""") + +test.write('foo.def', r""" +LIBRARY "foo" +DESCRIPTION "Foo Shared Library" + +EXPORTS + doIt +""") + +test.write('bar.def', r""" +LIBRARY "bar" +DESCRIPTION "Bar Shared Library" + +EXPORTS + doIt +""") + +test.write('prog.c', r""" +#include + +void +doIt() +{ +#ifdef FOO + printf("prog.c: FOO\n"); +#endif +#ifdef BAR + printf("prog.c: BAR\n"); +#endif +} +""") + +test.write('main.c', r""" + +void doIt(); + +int +main(int argc, char* argv[]) +{ + doIt(); + return 0; +} +""") + +test.run(arguments = '.') + +test.run(program = test.workpath('fooprog'), stdout = "prog.c: FOO\n") +test.run(program = test.workpath('barprog'), stdout = "prog.c: BAR\n") + +test.write('SConstruct', f""" +DefaultEnvironment(tools=[]) +bar = Environment(SHCFLAGS = '{barflags}', WINDOWS_INSERT_DEF=1) + +foo_obj = bar.SharedObject(target = 'foo', source = 'prog.c') +bar.SharedLibrary(target = 'foo', source = foo_obj) + +bar_obj = bar.SharedObject(target = 'bar', source = 'prog.c') +bar.SharedLibrary(target = 'bar', source = bar_obj) + +barMain = bar.Clone(LIBS='bar', LIBPATH='.') +foomain_obj = barMain.Object(target='foomain', source='main.c') +barmain_obj = barMain.Object(target='barmain', source='main.c') +barMain.Program(target='barprog', source=foomain_obj) +barMain.Program(target='fooprog', source=barmain_obj) +""") + +test.run(arguments = '.') + +test.run(program = test.workpath('fooprog'), stdout = "prog.c: BAR\n") +test.run(program = test.workpath('barprog'), stdout = "prog.c: BAR\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/Dir.py b/test/CPPPATH/Dir.py index 8275c0e243..a0b1b32ac4 100644 --- a/test/CPPPATH/Dir.py +++ b/test/CPPPATH/Dir.py @@ -1,85 +1,85 @@ -#!/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 CPPPATH values with Dir nodes work correctly. -""" - -import TestSCons - -_exe = TestSCons._exe - -test = TestSCons.TestSCons() - -test.subdir('inc1', 'inc2', 'inc3', ['inc3', 'subdir']) - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(CPPPATH = [Dir('inc1'), '$INC2', '$INC3/subdir'], - INC2 = Dir('inc2'), - INC3 = Dir('inc3')) -env.Program('prog.c') -""") - -test.write('prog.c', """\ -#include -#include - -#include "one.h" -#include "two.h" -#include "three.h" -int -main(int argc, char *argv[]) -{ - printf("%s\\n", ONE); - printf("%s\\n", TWO); - printf("%s\\n", THREE); - return (0); -} -""") - -test.write(['inc1', 'one.h'], """\ -#define ONE "1" -""") - -test.write(['inc2', 'two.h'], """\ -#define TWO "2" -""") - -test.write(['inc3', 'subdir', 'three.h'], """\ -#define THREE "3" -""") - -test.run(arguments = '.') - -test.run(program = test.workpath('prog' + _exe), stdout = "1\n2\n3\n") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/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 CPPPATH values with Dir nodes work correctly. +""" + +import TestSCons + +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +test.subdir('inc1', 'inc2', 'inc3', ['inc3', 'subdir']) + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(CPPPATH = [Dir('inc1'), '$INC2', '$INC3/subdir'], + INC2 = Dir('inc2'), + INC3 = Dir('inc3')) +env.Program('prog.c') +""") + +test.write('prog.c', """\ +#include +#include + +#include "one.h" +#include "two.h" +#include "three.h" +int +main(int argc, char *argv[]) +{ + printf("%s\\n", ONE); + printf("%s\\n", TWO); + printf("%s\\n", THREE); + return (0); +} +""") + +test.write(['inc1', 'one.h'], """\ +#define ONE "1" +""") + +test.write(['inc2', 'two.h'], """\ +#define TWO "2" +""") + +test.write(['inc3', 'subdir', 'three.h'], """\ +#define THREE "3" +""") + +test.run(arguments = '.') + +test.run(program = test.workpath('prog' + _exe), stdout = "1\n2\n3\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/absolute-path.py b/test/CPPPATH/absolute-path.py index a73f4fcec8..dca01f0336 100644 --- a/test/CPPPATH/absolute-path.py +++ b/test/CPPPATH/absolute-path.py @@ -1,100 +1,100 @@ -#!/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 the ability to #include a file with an absolute path name. (Which -is not strictly a test of using $CPPPATH, but it's in the ball park...) -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('include', 'work') - -inc1_h = test.workpath('include', 'inc1.h') -inc2_h = test.workpath('include', 'inc2.h') -does_not_exist_h = test.workpath('include', 'does_not_exist.h') - -# Verify that including an absolute path still works even if they -# double the separators in the input file. This can happen especially -# on Windows if they use \\ to represent an escaped backslash. -inc2_h = inc2_h.replace(os.sep, os.sep+os.sep) - -test.write(['work', 'SConstruct'], """\ -Program('prog.c') -""") - -test.write(['work', 'prog.c'], """\ -#include -#include "%(inc1_h)s" -#include "%(inc2_h)s" -#if 0 -#include "%(does_not_exist_h)s" -#endif - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("%%s\\n", STRING1); - printf("%%s\\n", STRING2); - return 0; -} -""" % locals()) - -test.write(['include', 'inc1.h'], """\ -#define STRING1 "include/inc1.h A\\n" -""") - -test.write(['include', 'inc2.h'], """\ -#define STRING2 "include/inc2.h A\\n" -""") - -test.run(chdir = 'work', arguments = '.') - -test.up_to_date(chdir = 'work', arguments = '.') - -test.write(['include', 'inc1.h'], """\ -#define STRING1 "include/inc1.h B\\n" -""") - -test.not_up_to_date(chdir = 'work', arguments = '.') - -test.write(['include', 'inc2.h'], """\ -#define STRING2 "include/inc2.h B\\n" -""") - -test.not_up_to_date(chdir = 'work', arguments = '.') - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/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 the ability to #include a file with an absolute path name. (Which +is not strictly a test of using $CPPPATH, but it's in the ball park...) +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('include', 'work') + +inc1_h = test.workpath('include', 'inc1.h') +inc2_h = test.workpath('include', 'inc2.h') +does_not_exist_h = test.workpath('include', 'does_not_exist.h') + +# Verify that including an absolute path still works even if they +# double the separators in the input file. This can happen especially +# on Windows if they use \\ to represent an escaped backslash. +inc2_h = inc2_h.replace(os.sep, os.sep+os.sep) + +test.write(['work', 'SConstruct'], """\ +Program('prog.c') +""") + +test.write(['work', 'prog.c'], """\ +#include +#include "%(inc1_h)s" +#include "%(inc2_h)s" +#if 0 +#include "%(does_not_exist_h)s" +#endif + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("%%s\\n", STRING1); + printf("%%s\\n", STRING2); + return 0; +} +""" % locals()) + +test.write(['include', 'inc1.h'], """\ +#define STRING1 "include/inc1.h A\\n" +""") + +test.write(['include', 'inc2.h'], """\ +#define STRING2 "include/inc2.h A\\n" +""") + +test.run(chdir = 'work', arguments = '.') + +test.up_to_date(chdir = 'work', arguments = '.') + +test.write(['include', 'inc1.h'], """\ +#define STRING1 "include/inc1.h B\\n" +""") + +test.not_up_to_date(chdir = 'work', arguments = '.') + +test.write(['include', 'inc2.h'], """\ +#define STRING2 "include/inc2.h B\\n" +""") + +test.not_up_to_date(chdir = 'work', arguments = '.') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/expand-object.py b/test/CPPPATH/expand-object.py index 5b751bb823..eec4ac815b 100644 --- a/test/CPPPATH/expand-object.py +++ b/test/CPPPATH/expand-object.py @@ -1,69 +1,69 @@ -#!/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 that $CPPPATH expands correctly if one of the subsidiary -expansions contains a stringable non-Node object. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -class XXX: - def __init__(self, value): - self.value = value - def __str__(self): - return 'XXX-' + self.value + '-XXX' -env = Environment(CPPPATH = ['#', - '$BUILDDIR', - '/tmp/xyzzy'], - BUILDDIR = '#scons_build/$EXPANSION', - EXPANSION = XXX('win32')) -env.Object('foo.c') -""") - -test.write('foo.c', """\ -#include -void -foo(void) -{ - printf("foo.c\\n"); -} -""") - -test.run(arguments = '.') - -test.must_exist(test.workpath('foo' + TestSCons._obj)) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/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 that $CPPPATH expands correctly if one of the subsidiary +expansions contains a stringable non-Node object. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +class XXX: + def __init__(self, value): + self.value = value + def __str__(self): + return 'XXX-' + self.value + '-XXX' +env = Environment(CPPPATH = ['#', + '$BUILDDIR', + '/tmp/xyzzy'], + BUILDDIR = '#scons_build/$EXPANSION', + EXPANSION = XXX('win32')) +env.Object('foo.c') +""") + +test.write('foo.c', """\ +#include +void +foo(void) +{ + printf("foo.c\\n"); +} +""") + +test.run(arguments = '.') + +test.must_exist(test.workpath('foo' + TestSCons._obj)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/function-expansion.py b/test/CPPPATH/function-expansion.py index b9bc5be8db..3fb999fa4c 100644 --- a/test/CPPPATH/function-expansion.py +++ b/test/CPPPATH/function-expansion.py @@ -1,142 +1,142 @@ -#!/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 expansion of construction variables whose values are functions -(that return lists that contain Nodes, even) works as expected within -a $CPPPATH list definition. - -This used to cause TypeErrors when the _concat expansion tried to -join the Nodes with the strings. - -Test courtesy Konstantin Bozhikov. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('list_inc1', - 'list_inc2', - 'inc1', - 'inc2', - 'inc3', - ['inc3', 'subdir']) - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -def my_cpppaths( target, source, env, for_signature ): - return [ Dir('list_inc1'), Dir('list_inc2') ] - -env = Environment( CPPPATH = [Dir('inc1'), '$INC2', '$INC3/subdir', '$MY_CPPPATHS' ], - INC2 = Dir('inc2'), - INC3 = Dir('inc3'), - MY_CPPPATHS = my_cpppaths ) - -env.Program('prog.c') -""") - -test.write('prog.c', """\ -#include -#include -#include "string_list_1.h" -#include "string_list_2.h" -#include "string_1.h" -#include "string_2.h" -#include "string_3.h" - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("prog.c\\n"); - printf("%s\\n", STRING_LIST_1); - printf("%s\\n", STRING_LIST_2); - printf("%s\\n", STRING_1); - printf("%s\\n", STRING_2); - printf("%s\\n", STRING_3); - exit (0); -} -""") - -test.write(['list_inc1', 'string_list_1.h'], """\ -#define STRING_LIST_1 "list_inc1/string_list_1.h" -""") - -test.write(['list_inc2', 'string_list_2.h'], """\ -#define STRING_LIST_2 "list_inc2/string_list_2.h" -""") - -test.write(['inc1', 'string_1.h'], """\ -#define STRING_1 "inc1/string_1.h" -""") - -test.write(['inc2', 'string_2.h'], """\ -#define STRING_2 "inc2/string_2.h" -""") - -test.write(['inc3', 'subdir', 'string_3.h'], """\ -#define STRING_3 "inc3/subdir/string_3.h" -""") - -test.run() - -test.up_to_date(arguments = '.') - -expect = """\ -prog.c -list_inc1/string_list_1.h -list_inc2/string_list_2.h -inc1/string_1.h -inc2/string_2.h -inc3/subdir/string_3.h -""" - -test.run(program = test.workpath('prog' + TestSCons._exe), stdout=expect) - -test.write(['inc3', 'subdir', 'string_3.h'], """\ -#define STRING_3 "inc3/subdir/string_3.h 2" -""") - -test.not_up_to_date(arguments = '.') - -expect = """\ -prog.c -list_inc1/string_list_1.h -list_inc2/string_list_2.h -inc1/string_1.h -inc2/string_2.h -inc3/subdir/string_3.h 2 -""" - -test.run(program = test.workpath('prog' + TestSCons._exe), stdout=expect) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/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 expansion of construction variables whose values are functions +(that return lists that contain Nodes, even) works as expected within +a $CPPPATH list definition. + +This used to cause TypeErrors when the _concat expansion tried to +join the Nodes with the strings. + +Test courtesy Konstantin Bozhikov. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('list_inc1', + 'list_inc2', + 'inc1', + 'inc2', + 'inc3', + ['inc3', 'subdir']) + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +def my_cpppaths( target, source, env, for_signature ): + return [ Dir('list_inc1'), Dir('list_inc2') ] + +env = Environment( CPPPATH = [Dir('inc1'), '$INC2', '$INC3/subdir', '$MY_CPPPATHS' ], + INC2 = Dir('inc2'), + INC3 = Dir('inc3'), + MY_CPPPATHS = my_cpppaths ) + +env.Program('prog.c') +""") + +test.write('prog.c', """\ +#include +#include +#include "string_list_1.h" +#include "string_list_2.h" +#include "string_1.h" +#include "string_2.h" +#include "string_3.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("prog.c\\n"); + printf("%s\\n", STRING_LIST_1); + printf("%s\\n", STRING_LIST_2); + printf("%s\\n", STRING_1); + printf("%s\\n", STRING_2); + printf("%s\\n", STRING_3); + exit (0); +} +""") + +test.write(['list_inc1', 'string_list_1.h'], """\ +#define STRING_LIST_1 "list_inc1/string_list_1.h" +""") + +test.write(['list_inc2', 'string_list_2.h'], """\ +#define STRING_LIST_2 "list_inc2/string_list_2.h" +""") + +test.write(['inc1', 'string_1.h'], """\ +#define STRING_1 "inc1/string_1.h" +""") + +test.write(['inc2', 'string_2.h'], """\ +#define STRING_2 "inc2/string_2.h" +""") + +test.write(['inc3', 'subdir', 'string_3.h'], """\ +#define STRING_3 "inc3/subdir/string_3.h" +""") + +test.run() + +test.up_to_date(arguments = '.') + +expect = """\ +prog.c +list_inc1/string_list_1.h +list_inc2/string_list_2.h +inc1/string_1.h +inc2/string_2.h +inc3/subdir/string_3.h +""" + +test.run(program = test.workpath('prog' + TestSCons._exe), stdout=expect) + +test.write(['inc3', 'subdir', 'string_3.h'], """\ +#define STRING_3 "inc3/subdir/string_3.h 2" +""") + +test.not_up_to_date(arguments = '.') + +expect = """\ +prog.c +list_inc1/string_list_1.h +list_inc2/string_list_2.h +inc1/string_1.h +inc2/string_2.h +inc3/subdir/string_3.h 2 +""" + +test.run(program = test.workpath('prog' + TestSCons._exe), stdout=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/list-expansion.py b/test/CPPPATH/list-expansion.py index ad41ba24eb..5e88320042 100644 --- a/test/CPPPATH/list-expansion.py +++ b/test/CPPPATH/list-expansion.py @@ -1,138 +1,138 @@ -#!/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 expansion of construction variables whose values are -lists works as expected within a $CPPPATH list definition. - -Previously, the stringification of the expansion of the individual -variables would turn a list like ['sub1', 'sub2'] below into "-Isub1 sub2" -on the command line. - -Test case courtesy Daniel Svensson. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('sub1', 'sub2', 'sub3', 'sub4') - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -class _inc_test: - def __init__(self, name): - self.name = name - - def __call__(self, target, source, env, for_signature): - return env.something[self.name] - -env = Environment() - -env.something = {} -env.something['test'] = ['sub1', 'sub2'] - -env['INC_PATHS1'] = _inc_test - -env['INC_PATHS2'] = ['sub3', 'sub4'] - -env.Append(CPPPATH = ['${INC_PATHS1("test")}', '$INC_PATHS2']) -env.Program('test', 'test.c') -""") - -test.write('test.c', """\ -#include -#include -#include "string1.h" -#include "string2.h" -#include "string3.h" -#include "string4.h" - -int -main(int argc, char *argv[]) -{ - argv[argc++] = "--"; - printf("test.c\\n"); - printf("%s\\n", STRING1); - printf("%s\\n", STRING2); - printf("%s\\n", STRING3); - printf("%s\\n", STRING4); - exit (0); -} -""") - -test.write(['sub1', 'string1.h'], """\ -#define STRING1 "sub1/string1.h" -""") - -test.write(['sub2', 'string2.h'], """\ -#define STRING2 "sub2/string2.h" -""") - -test.write(['sub3', 'string3.h'], """\ -#define STRING3 "sub3/string3.h" -""") - -test.write(['sub4', 'string4.h'], """\ -#define STRING4 "sub4/string4.h" -""") - -test.run() - -test.up_to_date(arguments = '.') - -expect = """\ -test.c -sub1/string1.h -sub2/string2.h -sub3/string3.h -sub4/string4.h -""" - -test.run(program = test.workpath('test' + TestSCons._exe), stdout=expect) - -test.write(['sub2', 'string2.h'], """\ -#define STRING2 "sub2/string2.h 2" -""") - -test.not_up_to_date(arguments = '.') - -expect = """\ -test.c -sub1/string1.h -sub2/string2.h 2 -sub3/string3.h -sub4/string4.h -""" - -test.run(program = test.workpath('test' + TestSCons._exe), stdout=expect) - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/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 expansion of construction variables whose values are +lists works as expected within a $CPPPATH list definition. + +Previously, the stringification of the expansion of the individual +variables would turn a list like ['sub1', 'sub2'] below into "-Isub1 sub2" +on the command line. + +Test case courtesy Daniel Svensson. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('sub1', 'sub2', 'sub3', 'sub4') + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +class _inc_test: + def __init__(self, name): + self.name = name + + def __call__(self, target, source, env, for_signature): + return env.something[self.name] + +env = Environment() + +env.something = {} +env.something['test'] = ['sub1', 'sub2'] + +env['INC_PATHS1'] = _inc_test + +env['INC_PATHS2'] = ['sub3', 'sub4'] + +env.Append(CPPPATH = ['${INC_PATHS1("test")}', '$INC_PATHS2']) +env.Program('test', 'test.c') +""") + +test.write('test.c', """\ +#include +#include +#include "string1.h" +#include "string2.h" +#include "string3.h" +#include "string4.h" + +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("test.c\\n"); + printf("%s\\n", STRING1); + printf("%s\\n", STRING2); + printf("%s\\n", STRING3); + printf("%s\\n", STRING4); + exit (0); +} +""") + +test.write(['sub1', 'string1.h'], """\ +#define STRING1 "sub1/string1.h" +""") + +test.write(['sub2', 'string2.h'], """\ +#define STRING2 "sub2/string2.h" +""") + +test.write(['sub3', 'string3.h'], """\ +#define STRING3 "sub3/string3.h" +""") + +test.write(['sub4', 'string4.h'], """\ +#define STRING4 "sub4/string4.h" +""") + +test.run() + +test.up_to_date(arguments = '.') + +expect = """\ +test.c +sub1/string1.h +sub2/string2.h +sub3/string3.h +sub4/string4.h +""" + +test.run(program = test.workpath('test' + TestSCons._exe), stdout=expect) + +test.write(['sub2', 'string2.h'], """\ +#define STRING2 "sub2/string2.h 2" +""") + +test.not_up_to_date(arguments = '.') + +expect = """\ +test.c +sub1/string1.h +sub2/string2.h 2 +sub3/string3.h +sub4/string4.h +""" + +test.run(program = test.workpath('test' + TestSCons._exe), stdout=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/match-dir.py b/test/CPPPATH/match-dir.py index fdbdfee901..41f071d7cc 100644 --- a/test/CPPPATH/match-dir.py +++ b/test/CPPPATH/match-dir.py @@ -1,74 +1,74 @@ -#!/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 blow up if there's a directory name within -$CPPPATH that matches a #include file name. -""" - -import sys - -import TestSCons - -test = TestSCons.TestSCons() - -# TODO(sgk): get this to work everywhere by using fake compilers -if sys.platform.find('sunos') != -1: - msg = 'SunOS C compiler does not handle this case; skipping test.\n' - test.skip_test(msg) - -test.subdir(['src'], - ['src', 'inc'], - ['src', 'inc', 'inc2']) - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -SConscript('src/SConscript', variant_dir = 'build', duplicate = 0) -""") - -test.write(['src', 'SConscript'], """\ -env = Environment(CPPPATH = ['#build/inc', '#build/inc/inc2']) -env.Object('foo.c') -""") - -test.write(['src', 'foo.c'], """\ -#include "inc1" -""") - -test.subdir(['src', 'inc', 'inc1']) - -test.write(['src', 'inc', 'inc2', 'inc1'], "\n") - -test.run(arguments = '.') - -test.up_to_date(arguments = '.') - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/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 blow up if there's a directory name within +$CPPPATH that matches a #include file name. +""" + +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +# TODO(sgk): get this to work everywhere by using fake compilers +if sys.platform.find('sunos') != -1: + msg = 'SunOS C compiler does not handle this case; skipping test.\n' + test.skip_test(msg) + +test.subdir(['src'], + ['src', 'inc'], + ['src', 'inc', 'inc2']) + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +SConscript('src/SConscript', variant_dir = 'build', duplicate = 0) +""") + +test.write(['src', 'SConscript'], """\ +env = Environment(CPPPATH = ['#build/inc', '#build/inc/inc2']) +env.Object('foo.c') +""") + +test.write(['src', 'foo.c'], """\ +#include "inc1" +""") + +test.subdir(['src', 'inc', 'inc1']) + +test.write(['src', 'inc', 'inc2', 'inc1'], "\n") + +test.run(arguments = '.') + +test.up_to_date(arguments = '.') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/nested-lists.py b/test/CPPPATH/nested-lists.py index f47829d64c..86fb69b107 100644 --- a/test/CPPPATH/nested-lists.py +++ b/test/CPPPATH/nested-lists.py @@ -1,83 +1,83 @@ -#!/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 CPPPATH values consisting of nested lists work correctly. -""" - -import TestSCons - -_exe = TestSCons._exe - -test = TestSCons.TestSCons() - -test.subdir('inc1', 'inc2', 'inc3') - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(CPPPATH = ['inc1', ['inc2', ['inc3']]]) -env.Program('prog.c') -""") - -test.write('prog.c', """\ -#include -#include - -#include "one.h" -#include "two.h" -#include "three.h" -int -main(int argc, char *argv[]) -{ - printf("%s\\n", ONE); - printf("%s\\n", TWO); - printf("%s\\n", THREE); - return (0); -} -""") - -test.write(['inc1', 'one.h'], """\ -#define ONE "1" -""") - -test.write(['inc2', 'two.h'], """\ -#define TWO "2" -""") - -test.write(['inc3', 'three.h'], """\ -#define THREE "3" -""") - -test.run(arguments = '.') - -test.run(program = test.workpath('prog' + _exe), stdout = "1\n2\n3\n") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/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 CPPPATH values consisting of nested lists work correctly. +""" + +import TestSCons + +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +test.subdir('inc1', 'inc2', 'inc3') + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(CPPPATH = ['inc1', ['inc2', ['inc3']]]) +env.Program('prog.c') +""") + +test.write('prog.c', """\ +#include +#include + +#include "one.h" +#include "two.h" +#include "three.h" +int +main(int argc, char *argv[]) +{ + printf("%s\\n", ONE); + printf("%s\\n", TWO); + printf("%s\\n", THREE); + return (0); +} +""") + +test.write(['inc1', 'one.h'], """\ +#define ONE "1" +""") + +test.write(['inc2', 'two.h'], """\ +#define TWO "2" +""") + +test.write(['inc3', 'three.h'], """\ +#define THREE "3" +""") + +test.run(arguments = '.') + +test.run(program = test.workpath('prog' + _exe), stdout = "1\n2\n3\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/null.py b/test/CPPPATH/null.py index 17f0a8c9cc..b8c6841bbe 100644 --- a/test/CPPPATH/null.py +++ b/test/CPPPATH/null.py @@ -1,61 +1,61 @@ -#!/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 SOFTWAR - -""" -Verify that neither a null-string CPPPATH nor a -a CPPPATH containing null values blows up. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(CPPPATH = '') -env.Library('one', source = 'empty1.c') -env = Environment(CPPPATH = [None]) -env.Library('two', source = 'empty2.c') -env = Environment(CPPPATH = ['']) -env.Library('three', source = 'empty3.c') -""") - -test.write('empty1.c', "int a=0;\n") -test.write('empty2.c', "int b=0;\n") -test.write('empty3.c', "int c=0;\n") - -test.run(arguments = '.', - stderr=TestSCons.noisy_ar, - match=TestSCons.match_re_dotall) - - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/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 SOFTWAR + +""" +Verify that neither a null-string CPPPATH nor a +a CPPPATH containing null values blows up. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(CPPPATH = '') +env.Library('one', source = 'empty1.c') +env = Environment(CPPPATH = [None]) +env.Library('two', source = 'empty2.c') +env = Environment(CPPPATH = ['']) +env.Library('three', source = 'empty3.c') +""") + +test.write('empty1.c', "int a=0;\n") +test.write('empty2.c', "int b=0;\n") +test.write('empty3.c', "int c=0;\n") + +test.run(arguments = '.', + stderr=TestSCons.noisy_ar, + match=TestSCons.match_re_dotall) + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CPPPATH/subdir-as-include.py b/test/CPPPATH/subdir-as-include.py index 27e687fd83..25ecd23521 100644 --- a/test/CPPPATH/subdir-as-include.py +++ b/test/CPPPATH/subdir-as-include.py @@ -1,98 +1,98 @@ -#!/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 SOFTWAR - -""" -This is an obscure test case. When a file without a suffix is included in -a c++ build and there is a directory with the same name as that file in a -sub-build directory, verify that an Errno 21 is not thrown upon trying to -recursively scan the contents of includes. The Errno 21 indicates that -the directory with the same name was trying to be scanned as the include -file, which it clearly is not. -""" - -import TestSCons - -_exe = TestSCons._exe - -test = TestSCons.TestSCons() - -test.subdir('inc1', ['inc1', 'iterator']) - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(CPPPATH = [Dir('inc1')]) -env.Program('prog.cpp') - -Export('env') -SConscript('inc1/SConscript', variant_dir='inc1/build', duplicate=0) -""") - -test.write('prog.cpp', """\ -#include -#include - -#include "one.h" -#include -int main(int argc, char* argv[]) -{ - printf("%s\\n", ONE); - return 0; -} -""") - -test.write(['inc1', 'SConscript'], """\ -Import('env') -oneenv = env.Clone() -oneenv.Program('one.cpp') -""") - -test.write(['inc1', 'one.h'], """\ -#define ONE "1" -""") - -test.write(['inc1', 'one.cpp'], """\ -#include -#include -#include "one.h" - -int main(int argc, char* argv[]) -{ - printf("%s\\n", ONE); - return 0; -} -""") - -test.run(arguments = '.') - -test.run(program = test.workpath('prog' + _exe), stdout = "1\n") -test.run(program = test.workpath('inc1/build/one' + _exe), stdout = "1\n") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/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 SOFTWAR + +""" +This is an obscure test case. When a file without a suffix is included in +a c++ build and there is a directory with the same name as that file in a +sub-build directory, verify that an Errno 21 is not thrown upon trying to +recursively scan the contents of includes. The Errno 21 indicates that +the directory with the same name was trying to be scanned as the include +file, which it clearly is not. +""" + +import TestSCons + +_exe = TestSCons._exe + +test = TestSCons.TestSCons() + +test.subdir('inc1', ['inc1', 'iterator']) + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(CPPPATH = [Dir('inc1')]) +env.Program('prog.cpp') + +Export('env') +SConscript('inc1/SConscript', variant_dir='inc1/build', duplicate=0) +""") + +test.write('prog.cpp', """\ +#include +#include + +#include "one.h" +#include +int main(int argc, char* argv[]) +{ + printf("%s\\n", ONE); + return 0; +} +""") + +test.write(['inc1', 'SConscript'], """\ +Import('env') +oneenv = env.Clone() +oneenv.Program('one.cpp') +""") + +test.write(['inc1', 'one.h'], """\ +#define ONE "1" +""") + +test.write(['inc1', 'one.cpp'], """\ +#include +#include +#include "one.h" + +int main(int argc, char* argv[]) +{ + printf("%s\\n", ONE); + return 0; +} +""") + +test.run(arguments = '.') + +test.run(program = test.workpath('prog' + _exe), stdout = "1\n") +test.run(program = test.workpath('inc1/build/one' + _exe), stdout = "1\n") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CacheDir/CacheDir.py b/test/CacheDir/CacheDir.py index f59da13ea9..bd8d674af3 100644 --- a/test/CacheDir/CacheDir.py +++ b/test/CacheDir/CacheDir.py @@ -1,164 +1,164 @@ -#!/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 retrieving derived files from a CacheDir. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -cache = test.workpath('cache') - -src_aaa_out = test.workpath('src', 'aaa.out') -src_bbb_out = test.workpath('src', 'bbb.out') -src_ccc_out = test.workpath('src', 'ccc.out') -src_cat_out = test.workpath('src', 'cat.out') -src_all = test.workpath('src', 'all') - -test.subdir('cache', 'src') - -test.write(['src', 'SConstruct'], """\ -DefaultEnvironment(tools=[]) -CacheDir(r'%(cache)s') -SConscript('SConscript') -""" % locals()) - -test.write(['src', 'SConscript'], """\ -def cat(env, source, target): - target = str(target[0]) - with open('cat.out', 'a') as f: - f.write(target + "\\n") - with open(target, "w") as f: - for src in source: - with open(str(src), "r") as f2: - f.write(f2.read()) -env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -""") - -test.write(['src', 'aaa.in'], "aaa.in\n") -test.write(['src', 'bbb.in'], "bbb.in\n") -test.write(['src', 'ccc.in'], "ccc.in\n") - -# Verify that building with -n and an empty cache reports that proper -# build operations would be taken, but that nothing is actually built -# and that the cache is still empty. -test.run(chdir = 'src', arguments = '-n .', stdout = test.wrap_stdout("""\ -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -""")) - -test.must_not_exist(src_aaa_out) -test.must_not_exist(src_bbb_out) -test.must_not_exist(src_ccc_out) -test.must_not_exist(src_all) -# Even if you do -n, the cache will be configured. -test.fail_test(os.listdir(cache) != ['config']) - -# Verify that a normal build works correctly, and clean up. -# This should populate the cache with our derived files. -test.run(chdir = 'src', arguments = '.') - -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') -test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') - -test.up_to_date(chdir = 'src', arguments = '.') - -test.run(chdir = 'src', arguments = '-c .') -test.unlink(['src', 'cat.out']) - -# Verify that we now retrieve the derived files from cache, -# not rebuild them. Then clean up. -test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ -Retrieved `aaa.out' from cache -Retrieved `bbb.out' from cache -Retrieved `ccc.out' from cache -Retrieved `all' from cache -""")) - -test.must_not_exist(src_cat_out) - -test.up_to_date(chdir = 'src', arguments = '.') - -test.run(chdir = 'src', arguments = '-c .') - -# Verify that rebuilding with -n reports that everything was retrieved -# from the cache, but that nothing really was. -test.run(chdir = 'src', arguments = '-n .', stdout = test.wrap_stdout("""\ -Retrieved `aaa.out' from cache -Retrieved `bbb.out' from cache -Retrieved `ccc.out' from cache -Retrieved `all' from cache -""")) - -test.must_not_exist(src_aaa_out) -test.must_not_exist(src_bbb_out) -test.must_not_exist(src_ccc_out) -test.must_not_exist(src_all) - -# Verify that rebuilding with -s retrieves everything from the cache -# even though it doesn't report anything. -test.run(chdir = 'src', arguments = '-s .', stdout = "") - -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') -test.must_not_exist(src_cat_out) - -test.up_to_date(chdir = 'src', arguments = '.') - -test.run(chdir = 'src', arguments = '-c .') - -# Verify that updating one input file builds its derived file and -# dependency but that the other files are retrieved from cache. -test.write(['src', 'bbb.in'], "bbb.in 2\n") - -test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ -Retrieved `aaa.out' from cache -cat(["bbb.out"], ["bbb.in"]) -Retrieved `ccc.out' from cache -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -""")) - -test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') -test.must_match(['src', 'cat.out'], "bbb.out\nall\n", mode='r') - -test.up_to_date(chdir = 'src', 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. + +""" +Test retrieving derived files from a CacheDir. +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +cache = test.workpath('cache') + +src_aaa_out = test.workpath('src', 'aaa.out') +src_bbb_out = test.workpath('src', 'bbb.out') +src_ccc_out = test.workpath('src', 'ccc.out') +src_cat_out = test.workpath('src', 'cat.out') +src_all = test.workpath('src', 'all') + +test.subdir('cache', 'src') + +test.write(['src', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) +CacheDir(r'%(cache)s') +SConscript('SConscript') +""" % locals()) + +test.write(['src', 'SConscript'], """\ +def cat(env, source, target): + target = str(target[0]) + with open('cat.out', 'a') as f: + f.write(target + "\\n") + with open(target, "w") as f: + for src in source: + with open(str(src), "r") as f2: + f.write(f2.read()) +env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) +env.Cat('aaa.out', 'aaa.in') +env.Cat('bbb.out', 'bbb.in') +env.Cat('ccc.out', 'ccc.in') +env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) +""") + +test.write(['src', 'aaa.in'], "aaa.in\n") +test.write(['src', 'bbb.in'], "bbb.in\n") +test.write(['src', 'ccc.in'], "ccc.in\n") + +# Verify that building with -n and an empty cache reports that proper +# build operations would be taken, but that nothing is actually built +# and that the cache is still empty. +test.run(chdir = 'src', arguments = '-n .', stdout = test.wrap_stdout("""\ +cat(["aaa.out"], ["aaa.in"]) +cat(["bbb.out"], ["bbb.in"]) +cat(["ccc.out"], ["ccc.in"]) +cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) +""")) + +test.must_not_exist(src_aaa_out) +test.must_not_exist(src_bbb_out) +test.must_not_exist(src_ccc_out) +test.must_not_exist(src_all) +# Even if you do -n, the cache will be configured. +test.fail_test(os.listdir(cache) != ['config']) + +# Verify that a normal build works correctly, and clean up. +# This should populate the cache with our derived files. +test.run(chdir = 'src', arguments = '.') + +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') + +test.up_to_date(chdir = 'src', arguments = '.') + +test.run(chdir = 'src', arguments = '-c .') +test.unlink(['src', 'cat.out']) + +# Verify that we now retrieve the derived files from cache, +# not rebuild them. Then clean up. +test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ +Retrieved `aaa.out' from cache +Retrieved `bbb.out' from cache +Retrieved `ccc.out' from cache +Retrieved `all' from cache +""")) + +test.must_not_exist(src_cat_out) + +test.up_to_date(chdir = 'src', arguments = '.') + +test.run(chdir = 'src', arguments = '-c .') + +# Verify that rebuilding with -n reports that everything was retrieved +# from the cache, but that nothing really was. +test.run(chdir = 'src', arguments = '-n .', stdout = test.wrap_stdout("""\ +Retrieved `aaa.out' from cache +Retrieved `bbb.out' from cache +Retrieved `ccc.out' from cache +Retrieved `all' from cache +""")) + +test.must_not_exist(src_aaa_out) +test.must_not_exist(src_bbb_out) +test.must_not_exist(src_ccc_out) +test.must_not_exist(src_all) + +# Verify that rebuilding with -s retrieves everything from the cache +# even though it doesn't report anything. +test.run(chdir = 'src', arguments = '-s .', stdout = "") + +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_not_exist(src_cat_out) + +test.up_to_date(chdir = 'src', arguments = '.') + +test.run(chdir = 'src', arguments = '-c .') + +# Verify that updating one input file builds its derived file and +# dependency but that the other files are retrieved from cache. +test.write(['src', 'bbb.in'], "bbb.in 2\n") + +test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ +Retrieved `aaa.out' from cache +cat(["bbb.out"], ["bbb.in"]) +Retrieved `ccc.out' from cache +cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) +""")) + +test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') +test.must_match(['src', 'cat.out'], "bbb.out\nall\n", mode='r') + +test.up_to_date(chdir = 'src', 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/CacheDir/SideEffect.py b/test/CacheDir/SideEffect.py index c93485f817..61c9bbcf6e 100644 --- a/test/CacheDir/SideEffect.py +++ b/test/CacheDir/SideEffect.py @@ -1,114 +1,114 @@ -#!/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 use of SideEffect() doesn't interfere with CacheDir. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('cache', 'work') - -cache = test.workpath('cache') - -test.write(['work', 'SConstruct'], """\ -DefaultEnvironment(tools=[]) -def copy(source, target): - with open(target, "w") as f, open(source, "r") as f2: - f.write(f2.read()) - -def build(env, source, target): - s = str(source[0]) - t = str(target[0]) - copy(s, t) - if target[0].side_effects: - with open(str(target[0].side_effects[0]), "a") as side_effect: - side_effect.write(s + ' -> ' + t + '\\n') - -CacheDir(r'%(cache)s') - -Build = Builder(action=build) -env = Environment(tools=[], BUILDERS={'Build':Build}, SUBDIR='subdir') -env.Build('f1.out', 'f1.in') -env.Build('f2.out', 'f2.in') -env.Build('f3.out', 'f3.in') -SideEffect('log.txt', ['f1.out', 'f2.out', 'f3.out']) -""" % locals()) - -test.write(['work', 'f1.in'], 'f1.in\n') -test.write(['work', 'f2.in'], 'f2.in\n') -test.write(['work', 'f3.in'], 'f3.in\n') - -test.run(chdir='work', arguments='f1.out f2.out') - -expect = """\ -f1.in -> f1.out -f2.in -> f2.out -""" - -test.must_match(['work', 'log.txt'], expect, mode='r') - - - -test.write(['work', 'f2.in'], 'f2.in 2 \n') - -test.run(chdir='work', arguments='log.txt') - -expect = """\ -f1.in -> f1.out -f2.in -> f2.out -f2.in -> f2.out -f3.in -> f3.out -""" - -test.must_match(['work', 'log.txt'], expect, mode='r') - - - -test.write(['work', 'f1.in'], 'f1.in 2 \n') - -test.run(chdir='work', arguments=".") - -expect = """\ -f1.in -> f1.out -f2.in -> f2.out -f2.in -> f2.out -f3.in -> f3.out -f1.in -> f1.out -""" - -test.must_match(['work', 'log.txt'], 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 use of SideEffect() doesn't interfere with CacheDir. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('cache', 'work') + +cache = test.workpath('cache') + +test.write(['work', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) +def copy(source, target): + with open(target, "w") as f, open(source, "r") as f2: + f.write(f2.read()) + +def build(env, source, target): + s = str(source[0]) + t = str(target[0]) + copy(s, t) + if target[0].side_effects: + with open(str(target[0].side_effects[0]), "a") as side_effect: + side_effect.write(s + ' -> ' + t + '\\n') + +CacheDir(r'%(cache)s') + +Build = Builder(action=build) +env = Environment(tools=[], BUILDERS={'Build':Build}, SUBDIR='subdir') +env.Build('f1.out', 'f1.in') +env.Build('f2.out', 'f2.in') +env.Build('f3.out', 'f3.in') +SideEffect('log.txt', ['f1.out', 'f2.out', 'f3.out']) +""" % locals()) + +test.write(['work', 'f1.in'], 'f1.in\n') +test.write(['work', 'f2.in'], 'f2.in\n') +test.write(['work', 'f3.in'], 'f3.in\n') + +test.run(chdir='work', arguments='f1.out f2.out') + +expect = """\ +f1.in -> f1.out +f2.in -> f2.out +""" + +test.must_match(['work', 'log.txt'], expect, mode='r') + + + +test.write(['work', 'f2.in'], 'f2.in 2 \n') + +test.run(chdir='work', arguments='log.txt') + +expect = """\ +f1.in -> f1.out +f2.in -> f2.out +f2.in -> f2.out +f3.in -> f3.out +""" + +test.must_match(['work', 'log.txt'], expect, mode='r') + + + +test.write(['work', 'f1.in'], 'f1.in 2 \n') + +test.run(chdir='work', arguments=".") + +expect = """\ +f1.in -> f1.out +f2.in -> f2.out +f2.in -> f2.out +f3.in -> f3.out +f1.in -> f1.out +""" + +test.must_match(['work', 'log.txt'], 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/CacheDir/VariantDir.py b/test/CacheDir/VariantDir.py index 77cd117dd1..9fc82c9cb0 100644 --- a/test/CacheDir/VariantDir.py +++ b/test/CacheDir/VariantDir.py @@ -1,156 +1,156 @@ -#!/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 retrieving derived files from a CacheDir when a VariantDir is used. -""" - -import os.path - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('cache', 'src') - -cache = test.workpath('cache') -cat_out = test.workpath('cat.out') - -test.write(['src', 'SConscript'], """\ -DefaultEnvironment(tools=[]) - -def cat(env, source, target): - target = str(target[0]) - with open('cat.out', 'a') as f: - f.write(target + "\\n") - with open(target, "w") as f: - for src in source: - with open(str(src), "r") as f2: - f.write(f2.read()) -env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -""") - -build_aaa_out = os.path.join('build', 'aaa.out') -build_bbb_out = os.path.join('build', 'bbb.out') -build_ccc_out = os.path.join('build', 'ccc.out') -build_all = os.path.join('build', 'all') - -test.write(['src', 'aaa.in'], "aaa.in\n") -test.write(['src', 'bbb.in'], "bbb.in\n") -test.write(['src', 'ccc.in'], "ccc.in\n") - -# -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -env = Environment(tools=[], TWO = '2') -CacheDir(r'%s') -VariantDir('build', 'src', duplicate=0) -SConscript('build/SConscript') -""" % test.workpath('cache${TWO}')) - -# Verify that a normal build works correctly, and clean up. -# This should populate the cache with our derived files. -test.run() - -test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') -test.must_match('cat.out', "%s\n%s\n%s\n%s\n" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all), mode='r') - -test.up_to_date(arguments = '.') - -test.run(arguments = '-c .') -test.unlink('cat.out') - -# Verify that we now retrieve the derived files from cache, -# not rebuild them. Then clean up. -test.run(stdout = test.wrap_stdout("""\ -Retrieved `%s' from cache -Retrieved `%s' from cache -Retrieved `%s' from cache -Retrieved `%s' from cache -""" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all))) - -test.must_not_exist(cat_out) - -test.up_to_date(arguments = '.') - -test.run(arguments = '-c .') - -# Verify that rebuilding with -n reports that everything was retrieved -# from the cache, but that nothing really was. -test.run(arguments = '-n .', stdout = test.wrap_stdout("""\ -Retrieved `%s' from cache -Retrieved `%s' from cache -Retrieved `%s' from cache -Retrieved `%s' from cache -""" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all))) - -test.must_not_exist(test.workpath('build', 'aaa.out')) -test.must_not_exist(test.workpath('build', 'bbb.out')) -test.must_not_exist(test.workpath('build', 'ccc.out')) -test.must_not_exist(test.workpath('build', 'all')) - -# Verify that rebuilding with -s retrieves everything from the cache -# even though it doesn't report anything. -test.run(arguments = '-s .', stdout = "") - -test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') -test.must_not_exist(cat_out) - -test.up_to_date(arguments = '.') - -test.run(arguments = '-c .') - -# Verify that updating one input file builds its derived file and -# dependency but that the other files are retrieved from cache. -test.write(['src', 'bbb.in'], "bbb.in 2\n") - -test.run(stdout = test.wrap_stdout("""\ -Retrieved `%s' from cache -cat(["%s"], ["%s"]) -Retrieved `%s' from cache -cat(["%s"], ["%s", "%s", "%s"]) -""" % (build_aaa_out, - build_bbb_out, os.path.join('src', 'bbb.in'), - build_ccc_out, - build_all, build_aaa_out, build_bbb_out, build_ccc_out))) - -test.must_match(['build', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') -test.must_match('cat.out', "%s\n%s\n" % (build_bbb_out, build_all), mode='r') - -test.up_to_date(arguments = '.') - - - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: +#!/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 retrieving derived files from a CacheDir when a VariantDir is used. +""" + +import os.path + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('cache', 'src') + +cache = test.workpath('cache') +cat_out = test.workpath('cat.out') + +test.write(['src', 'SConscript'], """\ +DefaultEnvironment(tools=[]) + +def cat(env, source, target): + target = str(target[0]) + with open('cat.out', 'a') as f: + f.write(target + "\\n") + with open(target, "w") as f: + for src in source: + with open(str(src), "r") as f2: + f.write(f2.read()) +env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) +env.Cat('aaa.out', 'aaa.in') +env.Cat('bbb.out', 'bbb.in') +env.Cat('ccc.out', 'ccc.in') +env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) +""") + +build_aaa_out = os.path.join('build', 'aaa.out') +build_bbb_out = os.path.join('build', 'bbb.out') +build_ccc_out = os.path.join('build', 'ccc.out') +build_all = os.path.join('build', 'all') + +test.write(['src', 'aaa.in'], "aaa.in\n") +test.write(['src', 'bbb.in'], "bbb.in\n") +test.write(['src', 'ccc.in'], "ccc.in\n") + +# +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=[], TWO = '2') +CacheDir(r'%s') +VariantDir('build', 'src', duplicate=0) +SConscript('build/SConscript') +""" % test.workpath('cache${TWO}')) + +# Verify that a normal build works correctly, and clean up. +# This should populate the cache with our derived files. +test.run() + +test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match('cat.out', "%s\n%s\n%s\n%s\n" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all), mode='r') + +test.up_to_date(arguments = '.') + +test.run(arguments = '-c .') +test.unlink('cat.out') + +# Verify that we now retrieve the derived files from cache, +# not rebuild them. Then clean up. +test.run(stdout = test.wrap_stdout("""\ +Retrieved `%s' from cache +Retrieved `%s' from cache +Retrieved `%s' from cache +Retrieved `%s' from cache +""" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all))) + +test.must_not_exist(cat_out) + +test.up_to_date(arguments = '.') + +test.run(arguments = '-c .') + +# Verify that rebuilding with -n reports that everything was retrieved +# from the cache, but that nothing really was. +test.run(arguments = '-n .', stdout = test.wrap_stdout("""\ +Retrieved `%s' from cache +Retrieved `%s' from cache +Retrieved `%s' from cache +Retrieved `%s' from cache +""" % (build_aaa_out, build_bbb_out, build_ccc_out, build_all))) + +test.must_not_exist(test.workpath('build', 'aaa.out')) +test.must_not_exist(test.workpath('build', 'bbb.out')) +test.must_not_exist(test.workpath('build', 'ccc.out')) +test.must_not_exist(test.workpath('build', 'all')) + +# Verify that rebuilding with -s retrieves everything from the cache +# even though it doesn't report anything. +test.run(arguments = '-s .', stdout = "") + +test.must_match(['build', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_not_exist(cat_out) + +test.up_to_date(arguments = '.') + +test.run(arguments = '-c .') + +# Verify that updating one input file builds its derived file and +# dependency but that the other files are retrieved from cache. +test.write(['src', 'bbb.in'], "bbb.in 2\n") + +test.run(stdout = test.wrap_stdout("""\ +Retrieved `%s' from cache +cat(["%s"], ["%s"]) +Retrieved `%s' from cache +cat(["%s"], ["%s", "%s", "%s"]) +""" % (build_aaa_out, + build_bbb_out, os.path.join('src', 'bbb.in'), + build_ccc_out, + build_all, build_aaa_out, build_bbb_out, build_ccc_out))) + +test.must_match(['build', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') +test.must_match('cat.out', "%s\n%s\n" % (build_bbb_out, build_all), mode='r') + +test.up_to_date(arguments = '.') + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CacheDir/debug.py b/test/CacheDir/debug.py index 2c7ff0dd54..0ba6bbba2c 100644 --- a/test/CacheDir/debug.py +++ b/test/CacheDir/debug.py @@ -1,201 +1,201 @@ -#!/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 the --cache-debug option to see if it prints the expected messages. - -Note that we don't check for the "race condition" message when someone -else's build populates the CacheDir with a file in between the time we -to build it because it doesn't exist in the CacheDir, and the time our -build of the file completes and we push it out. -""" - -import TestSCons - -test = TestSCons.TestSCons(match=TestSCons.match_re) - -test.subdir('cache', 'src') - -cache = test.workpath('cache') -debug_out = test.workpath('cache-debug.out') - - - -test.write(['src', 'SConstruct'], """\ -DefaultEnvironment(tools=[]) -CacheDir(r'%(cache)s') -SConscript('SConscript') -""" % locals()) - -test.write(['src', 'SConscript'], """\ -def cat(env, source, target): - target = str(target[0]) - with open('cat.out', 'a') as f: - f.write(target + "\\n") - with open(target, "w") as f: - for src in source: - with open(str(src), "r") as f2: - f.write(f2.read()) -env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -""") - -test.write(['src', 'aaa.in'], "aaa.in\n") -test.write(['src', 'bbb.in'], "bbb.in\n") -test.write(['src', 'ccc.in'], "ccc.in\n") - - - -# Test for messages about files not being in CacheDir, with -n (don't -# actually build or push) and sendinig the message to a file. - -expect = \ -r"""cat\(\["aaa.out"\], \["aaa.in"\]\) -cat\(\["bbb.out"\], \["bbb.in"\]\) -cat\(\["ccc.out"\], \["ccc.in"\]\) -cat\(\["all"\], \["aaa.out", "bbb.out", "ccc.out"\]\) -""" - -test.run(chdir='src', - arguments='-n -Q --cache-debug=%s .' % debug_out, - stdout=expect) - -expect = \ -r"""CacheRetrieve\(aaa.out\): [0-9a-fA-F]+ not in cache -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -CacheRetrieve\(bbb.out\): [0-9a-fA-F]+ not in cache -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -CacheRetrieve\(ccc.out\): [0-9a-fA-F]+ not in cache -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -CacheRetrieve\(all\): [0-9a-fA-F]+ not in cache -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -""" - -test.must_match(debug_out, expect, mode='r') - - - -# Test for messages about actually pushing to the cache, without -n -# and to standard ouput. - -expect = \ -r"""CacheRetrieve\(aaa.out\): [0-9a-fA-F]+ not in cache -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -cat\(\["aaa.out"\], \["aaa.in"\]\) -CachePush\(aaa.out\): pushing to [0-9a-fA-F]+ -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -CacheRetrieve\(bbb.out\): [0-9a-fA-F]+ not in cache -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -cat\(\["bbb.out"\], \["bbb.in"\]\) -CachePush\(bbb.out\): pushing to [0-9a-fA-F]+ -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -CacheRetrieve\(ccc.out\): [0-9a-fA-F]+ not in cache -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -cat\(\["ccc.out"\], \["ccc.in"\]\) -CachePush\(ccc.out\): pushing to [0-9a-fA-F]+ -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -CacheRetrieve\(all\): [0-9a-fA-F]+ not in cache -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -cat\(\["all"\], \["aaa.out", "bbb.out", "ccc.out"\]\) -CachePush\(all\): pushing to [0-9a-fA-F]+ -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -""" - -test.run(chdir='src', - arguments='-Q --cache-debug=- .', - stdout=expect) - - - -# Clean up the local targets. - -test.run(chdir='src', arguments='-c --cache-debug=%s .' % debug_out) -test.unlink(['src', 'cat.out']) - - - -# Test for messages about retrieving files from CacheDir, with -n -# and sending the messages to standard output. - -expect = \ -r"""Retrieved `aaa.out' from cache -CacheRetrieve\(aaa.out\): retrieving from [0-9a-fA-F]+ -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -Retrieved `bbb.out' from cache -CacheRetrieve\(bbb.out\): retrieving from [0-9a-fA-F]+ -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -Retrieved `ccc.out' from cache -CacheRetrieve\(ccc.out\): retrieving from [0-9a-fA-F]+ -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -Retrieved `all' from cache -CacheRetrieve\(all\): retrieving from [0-9a-fA-F]+ -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -""" - -test.run(chdir='src', - arguments='-n -Q --cache-debug=- .', - stdout=expect) - - - -# And finally test for message about retrieving file from CacheDir -# *without* -n and sending the message to a file. - -expect = \ -r"""Retrieved `aaa.out' from cache -Retrieved `bbb.out' from cache -Retrieved `ccc.out' from cache -Retrieved `all' from cache -""" - -test.run(chdir='src', - arguments='-Q --cache-debug=%s .' % debug_out, - stdout=expect) - -expect = \ -r"""CacheRetrieve\(aaa.out\): retrieving from [0-9a-fA-F]+ -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -CacheRetrieve\(bbb.out\): retrieving from [0-9a-fA-F]+ -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -CacheRetrieve\(ccc.out\): retrieving from [0-9a-fA-F]+ -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -CacheRetrieve\(all\): retrieving from [0-9a-fA-F]+ -requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% -""" - -test.must_match(debug_out, 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 the --cache-debug option to see if it prints the expected messages. + +Note that we don't check for the "race condition" message when someone +else's build populates the CacheDir with a file in between the time we +to build it because it doesn't exist in the CacheDir, and the time our +build of the file completes and we push it out. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +test.subdir('cache', 'src') + +cache = test.workpath('cache') +debug_out = test.workpath('cache-debug.out') + + + +test.write(['src', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) +CacheDir(r'%(cache)s') +SConscript('SConscript') +""" % locals()) + +test.write(['src', 'SConscript'], """\ +def cat(env, source, target): + target = str(target[0]) + with open('cat.out', 'a') as f: + f.write(target + "\\n") + with open(target, "w") as f: + for src in source: + with open(str(src), "r") as f2: + f.write(f2.read()) +env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) +env.Cat('aaa.out', 'aaa.in') +env.Cat('bbb.out', 'bbb.in') +env.Cat('ccc.out', 'ccc.in') +env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) +""") + +test.write(['src', 'aaa.in'], "aaa.in\n") +test.write(['src', 'bbb.in'], "bbb.in\n") +test.write(['src', 'ccc.in'], "ccc.in\n") + + + +# Test for messages about files not being in CacheDir, with -n (don't +# actually build or push) and sendinig the message to a file. + +expect = \ +r"""cat\(\["aaa.out"\], \["aaa.in"\]\) +cat\(\["bbb.out"\], \["bbb.in"\]\) +cat\(\["ccc.out"\], \["ccc.in"\]\) +cat\(\["all"\], \["aaa.out", "bbb.out", "ccc.out"\]\) +""" + +test.run(chdir='src', + arguments='-n -Q --cache-debug=%s .' % debug_out, + stdout=expect) + +expect = \ +r"""CacheRetrieve\(aaa.out\): [0-9a-fA-F]+ not in cache +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +CacheRetrieve\(bbb.out\): [0-9a-fA-F]+ not in cache +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +CacheRetrieve\(ccc.out\): [0-9a-fA-F]+ not in cache +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +CacheRetrieve\(all\): [0-9a-fA-F]+ not in cache +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +""" + +test.must_match(debug_out, expect, mode='r') + + + +# Test for messages about actually pushing to the cache, without -n +# and to standard ouput. + +expect = \ +r"""CacheRetrieve\(aaa.out\): [0-9a-fA-F]+ not in cache +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +cat\(\["aaa.out"\], \["aaa.in"\]\) +CachePush\(aaa.out\): pushing to [0-9a-fA-F]+ +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +CacheRetrieve\(bbb.out\): [0-9a-fA-F]+ not in cache +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +cat\(\["bbb.out"\], \["bbb.in"\]\) +CachePush\(bbb.out\): pushing to [0-9a-fA-F]+ +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +CacheRetrieve\(ccc.out\): [0-9a-fA-F]+ not in cache +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +cat\(\["ccc.out"\], \["ccc.in"\]\) +CachePush\(ccc.out\): pushing to [0-9a-fA-F]+ +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +CacheRetrieve\(all\): [0-9a-fA-F]+ not in cache +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +cat\(\["all"\], \["aaa.out", "bbb.out", "ccc.out"\]\) +CachePush\(all\): pushing to [0-9a-fA-F]+ +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +""" + +test.run(chdir='src', + arguments='-Q --cache-debug=- .', + stdout=expect) + + + +# Clean up the local targets. + +test.run(chdir='src', arguments='-c --cache-debug=%s .' % debug_out) +test.unlink(['src', 'cat.out']) + + + +# Test for messages about retrieving files from CacheDir, with -n +# and sending the messages to standard output. + +expect = \ +r"""Retrieved `aaa.out' from cache +CacheRetrieve\(aaa.out\): retrieving from [0-9a-fA-F]+ +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +Retrieved `bbb.out' from cache +CacheRetrieve\(bbb.out\): retrieving from [0-9a-fA-F]+ +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +Retrieved `ccc.out' from cache +CacheRetrieve\(ccc.out\): retrieving from [0-9a-fA-F]+ +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +Retrieved `all' from cache +CacheRetrieve\(all\): retrieving from [0-9a-fA-F]+ +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +""" + +test.run(chdir='src', + arguments='-n -Q --cache-debug=- .', + stdout=expect) + + + +# And finally test for message about retrieving file from CacheDir +# *without* -n and sending the message to a file. + +expect = \ +r"""Retrieved `aaa.out' from cache +Retrieved `bbb.out' from cache +Retrieved `ccc.out' from cache +Retrieved `all' from cache +""" + +test.run(chdir='src', + arguments='-Q --cache-debug=%s .' % debug_out, + stdout=expect) + +expect = \ +r"""CacheRetrieve\(aaa.out\): retrieving from [0-9a-fA-F]+ +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +CacheRetrieve\(bbb.out\): retrieving from [0-9a-fA-F]+ +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +CacheRetrieve\(ccc.out\): retrieving from [0-9a-fA-F]+ +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +CacheRetrieve\(all\): retrieving from [0-9a-fA-F]+ +requests: [0-9]+, hits: [0-9]+, misses: [0-9]+, hit rate: [0-9]+\.[0-9]{2,}% +""" + +test.must_match(debug_out, 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/CacheDir/environment.py b/test/CacheDir/environment.py index 60c52ebfa5..17a4f26e0b 100644 --- a/test/CacheDir/environment.py +++ b/test/CacheDir/environment.py @@ -1,170 +1,170 @@ -#!/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 whether or not a target gets retrieved from a CacheDir -is configurable by construction environment. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -cache = test.workpath('cache') - -src_aaa_out = test.workpath('src', 'aaa.out') -src_bbb_out = test.workpath('src', 'bbb.out') -src_ccc_out = test.workpath('src', 'ccc.out') -src_cat_out = test.workpath('src', 'cat.out') -src_all = test.workpath('src', 'all') - -test.subdir('cache', 'src') - -test.write(['src', 'SConstruct'], """\ -DefaultEnvironment(tools=[]) -CacheDir(r'%(cache)s') -SConscript('SConscript') -""" % locals()) - -test.write(['src', 'SConscript'], """\ -def cat(env, source, target): - target = str(target[0]) - with open('cat.out', 'a') as f: - f.write(target + "\\n") - with open(target, "w") as f: - for src in source: - with open(str(src), "r") as f2: - f.write(f2.read()) -env_cache = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) -env_nocache = env_cache.Clone() -env_nocache.CacheDir(None) -env_cache.Cat('aaa.out', 'aaa.in') -env_nocache.Cat('bbb.out', 'bbb.in') -env_cache.Cat('ccc.out', 'ccc.in') -env_nocache.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -""") - -test.write(['src', 'aaa.in'], "aaa.in\n") -test.write(['src', 'bbb.in'], "bbb.in\n") -test.write(['src', 'ccc.in'], "ccc.in\n") - -# Verify that building with -n and an empty cache reports that proper -# build operations would be taken, but that nothing is actually built -# and that the cache is still empty. -test.run(chdir = 'src', arguments = '-n .', stdout = test.wrap_stdout("""\ -cat(["aaa.out"], ["aaa.in"]) -cat(["bbb.out"], ["bbb.in"]) -cat(["ccc.out"], ["ccc.in"]) -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -""")) - -test.must_not_exist(src_aaa_out) -test.must_not_exist(src_bbb_out) -test.must_not_exist(src_ccc_out) -test.must_not_exist(src_all) -# Even if you do -n, the cache will be configured. -test.fail_test(os.listdir(cache) != ['config']) - -# Verify that a normal build works correctly, and clean up. -# This should populate the cache with our derived files. -test.run(chdir = 'src', arguments = '.') - -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') -test.must_match(src_cat_out, "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') - -test.up_to_date(chdir = 'src', arguments = '.') - -test.run(chdir = 'src', arguments = '-c .') -test.unlink(src_cat_out) - -# Verify that we now retrieve the derived files from cache, -# not rebuild them. Then clean up. -test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ -Retrieved `aaa.out' from cache -cat(["bbb.out"], ["bbb.in"]) -Retrieved `ccc.out' from cache -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -""")) - -test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') - -test.up_to_date(chdir = 'src', arguments = '.') - -test.run(chdir = 'src', arguments = '-c .') -test.unlink(src_cat_out) - -# Verify that rebuilding with -n reports that files were retrieved -# from the cache, but that nothing really was. -test.run(chdir = 'src', arguments = '-n .', stdout = test.wrap_stdout("""\ -Retrieved `aaa.out' from cache -cat(["bbb.out"], ["bbb.in"]) -Retrieved `ccc.out' from cache -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -""")) - -test.must_not_exist(src_aaa_out) -test.must_not_exist(src_bbb_out) -test.must_not_exist(src_ccc_out) -test.must_not_exist(src_all) - -# Verify that rebuilding with -s retrieves everything from the cache -# even though it doesn't report anything. -test.run(chdir = 'src', arguments = '-s .', stdout = "") - -test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') - -test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') - -test.up_to_date(chdir = 'src', arguments = '.') - -test.run(chdir = 'src', arguments = '-c .') -test.unlink(src_cat_out) - -# Verify that updating one input file builds its derived file and -# dependency but that the other files are retrieved from cache. -test.write(['src', 'bbb.in'], "bbb.in 2\n") - -test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ -Retrieved `aaa.out' from cache -cat(["bbb.out"], ["bbb.in"]) -Retrieved `ccc.out' from cache -cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) -""")) - -test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') -test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') - -test.up_to_date(chdir = 'src', 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. + +""" +Verify that whether or not a target gets retrieved from a CacheDir +is configurable by construction environment. +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +cache = test.workpath('cache') + +src_aaa_out = test.workpath('src', 'aaa.out') +src_bbb_out = test.workpath('src', 'bbb.out') +src_ccc_out = test.workpath('src', 'ccc.out') +src_cat_out = test.workpath('src', 'cat.out') +src_all = test.workpath('src', 'all') + +test.subdir('cache', 'src') + +test.write(['src', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) +CacheDir(r'%(cache)s') +SConscript('SConscript') +""" % locals()) + +test.write(['src', 'SConscript'], """\ +def cat(env, source, target): + target = str(target[0]) + with open('cat.out', 'a') as f: + f.write(target + "\\n") + with open(target, "w") as f: + for src in source: + with open(str(src), "r") as f2: + f.write(f2.read()) +env_cache = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) +env_nocache = env_cache.Clone() +env_nocache.CacheDir(None) +env_cache.Cat('aaa.out', 'aaa.in') +env_nocache.Cat('bbb.out', 'bbb.in') +env_cache.Cat('ccc.out', 'ccc.in') +env_nocache.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) +""") + +test.write(['src', 'aaa.in'], "aaa.in\n") +test.write(['src', 'bbb.in'], "bbb.in\n") +test.write(['src', 'ccc.in'], "ccc.in\n") + +# Verify that building with -n and an empty cache reports that proper +# build operations would be taken, but that nothing is actually built +# and that the cache is still empty. +test.run(chdir = 'src', arguments = '-n .', stdout = test.wrap_stdout("""\ +cat(["aaa.out"], ["aaa.in"]) +cat(["bbb.out"], ["bbb.in"]) +cat(["ccc.out"], ["ccc.in"]) +cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) +""")) + +test.must_not_exist(src_aaa_out) +test.must_not_exist(src_bbb_out) +test.must_not_exist(src_ccc_out) +test.must_not_exist(src_all) +# Even if you do -n, the cache will be configured. +test.fail_test(os.listdir(cache) != ['config']) + +# Verify that a normal build works correctly, and clean up. +# This should populate the cache with our derived files. +test.run(chdir = 'src', arguments = '.') + +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') +test.must_match(src_cat_out, "aaa.out\nbbb.out\nccc.out\nall\n", mode='r') + +test.up_to_date(chdir = 'src', arguments = '.') + +test.run(chdir = 'src', arguments = '-c .') +test.unlink(src_cat_out) + +# Verify that we now retrieve the derived files from cache, +# not rebuild them. Then clean up. +test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ +Retrieved `aaa.out' from cache +cat(["bbb.out"], ["bbb.in"]) +Retrieved `ccc.out' from cache +cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) +""")) + +test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') + +test.up_to_date(chdir = 'src', arguments = '.') + +test.run(chdir = 'src', arguments = '-c .') +test.unlink(src_cat_out) + +# Verify that rebuilding with -n reports that files were retrieved +# from the cache, but that nothing really was. +test.run(chdir = 'src', arguments = '-n .', stdout = test.wrap_stdout("""\ +Retrieved `aaa.out' from cache +cat(["bbb.out"], ["bbb.in"]) +Retrieved `ccc.out' from cache +cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) +""")) + +test.must_not_exist(src_aaa_out) +test.must_not_exist(src_bbb_out) +test.must_not_exist(src_ccc_out) +test.must_not_exist(src_all) + +# Verify that rebuilding with -s retrieves everything from the cache +# even though it doesn't report anything. +test.run(chdir = 'src', arguments = '-s .', stdout = "") + +test.must_match(['src', 'all'], "aaa.in\nbbb.in\nccc.in\n", mode='r') + +test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') + +test.up_to_date(chdir = 'src', arguments = '.') + +test.run(chdir = 'src', arguments = '-c .') +test.unlink(src_cat_out) + +# Verify that updating one input file builds its derived file and +# dependency but that the other files are retrieved from cache. +test.write(['src', 'bbb.in'], "bbb.in 2\n") + +test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ +Retrieved `aaa.out' from cache +cat(["bbb.out"], ["bbb.in"]) +Retrieved `ccc.out' from cache +cat(["all"], ["aaa.out", "bbb.out", "ccc.out"]) +""")) + +test.must_match(['src', 'all'], "aaa.in\nbbb.in 2\nccc.in\n", mode='r') +test.must_match(src_cat_out, "bbb.out\nall\n", mode='r') + +test.up_to_date(chdir = 'src', 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/CacheDir/multi-targets.py b/test/CacheDir/multi-targets.py index ed11f779ca..72c7e66a2b 100644 --- a/test/CacheDir/multi-targets.py +++ b/test/CacheDir/multi-targets.py @@ -1,78 +1,78 @@ -#!/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 multiple target files get retrieved from a CacheDir correctly. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('cache', 'multiple') - -cache = test.workpath('cache') - -multiple_bar = test.workpath('multiple', 'bar') -multiple_foo = test.workpath('multiple', 'foo') - -test.write(['multiple', 'SConstruct'], """\ -DefaultEnvironment(tools=[]) -def touch(env, source, target): - with open('foo', 'w') as f: - f.write("") - with open('bar', 'w') as f: - f.write("") -CacheDir(r'%(cache)s') -env = Environment(tools=[]) -env.Command(['foo', 'bar'], ['input'], touch) -""" % locals()) - -test.write(['multiple', 'input'], "multiple/input\n") - -test.run(chdir = 'multiple') - -test.must_exist(multiple_foo) -test.must_exist(multiple_bar) - -test.run(chdir = 'multiple', arguments = '-c') - -test.must_not_exist(multiple_foo) -test.must_not_exist(multiple_bar) - -test.run(chdir = 'multiple') - -test.must_exist(multiple_foo) -test.must_exist(multiple_bar) - - - -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 multiple target files get retrieved from a CacheDir correctly. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('cache', 'multiple') + +cache = test.workpath('cache') + +multiple_bar = test.workpath('multiple', 'bar') +multiple_foo = test.workpath('multiple', 'foo') + +test.write(['multiple', 'SConstruct'], """\ +DefaultEnvironment(tools=[]) +def touch(env, source, target): + with open('foo', 'w') as f: + f.write("") + with open('bar', 'w') as f: + f.write("") +CacheDir(r'%(cache)s') +env = Environment(tools=[]) +env.Command(['foo', 'bar'], ['input'], touch) +""" % locals()) + +test.write(['multiple', 'input'], "multiple/input\n") + +test.run(chdir = 'multiple') + +test.must_exist(multiple_foo) +test.must_exist(multiple_bar) + +test.run(chdir = 'multiple', arguments = '-c') + +test.must_not_exist(multiple_foo) +test.must_not_exist(multiple_bar) + +test.run(chdir = 'multiple') + +test.must_exist(multiple_foo) +test.must_exist(multiple_bar) + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CacheDir/option--cf.py b/test/CacheDir/option--cf.py index f93b4db4f7..4750b40b99 100644 --- a/test/CacheDir/option--cf.py +++ b/test/CacheDir/option--cf.py @@ -1,131 +1,131 @@ -#!/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 populating a CacheDir with the --cache-force option. -""" - -import os.path -import shutil - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('cache', 'src') - -test.write(['src', 'SConstruct'], """ -DefaultEnvironment(tools=[]) -def cat(env, source, target): - target = str(target[0]) - with open('cat.out', 'a') as f: - f.write(target + "\\n") - with open(target, "w") as f: - for src in source: - with open(str(src), "r") as f2: - f.write(f2.read()) -env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) -env.Cat('aaa.out', 'aaa.in') -env.Cat('bbb.out', 'bbb.in') -env.Cat('ccc.out', 'ccc.in') -env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) -CacheDir(r'%s') -""" % test.workpath('cache')) - -test.write(['src', 'aaa.in'], "aaa.in\n") -test.write(['src', 'bbb.in'], "bbb.in\n") -test.write(['src', 'ccc.in'], "ccc.in\n") - -# Verify that a normal build works correctly, and clean up. -# This should populate the cache with our derived files. -test.run(chdir = 'src', arguments = '.') - -test.must_match(['src','all'],"aaa.in\nbbb.in\nccc.in\n", mode='r') -# test.fail_test(test.read(['src', 'all']) != "aaa.in\nbbb.in\nccc.in\n") -test.must_match(['src','cat.out'],"aaa.out\nbbb.out\nccc.out\nall\n", mode='r') -# test.fail_test(test.read(['src', 'cat.out']) != "aaa.out\nbbb.out\nccc.out\nall\n") - -test.up_to_date(chdir = 'src', arguments = '.') - -test.run(chdir = 'src', arguments = '-c .') -test.unlink(['src', 'cat.out']) - -# Verify that we now retrieve the derived files from cache, -# not rebuild them. DO NOT CLEAN UP. -test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ -Retrieved `aaa.out' from cache -Retrieved `bbb.out' from cache -Retrieved `ccc.out' from cache -Retrieved `all' from cache -""")) - -test.fail_test(os.path.exists(test.workpath('src', 'cat.out'))) - -test.up_to_date(chdir = 'src', arguments = '.') - -# Blow away and recreate the CacheDir, then verify that --cache-force -# repopulates the cache with the local built targets. DO NOT CLEAN UP. -shutil.rmtree(test.workpath('cache')) -test.subdir('cache') - -test.run(chdir = 'src', arguments = '--cache-force .') - -test.run(chdir = 'src', arguments = '-c .') - -test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ -Retrieved `aaa.out' from cache -Retrieved `bbb.out' from cache -Retrieved `ccc.out' from cache -Retrieved `all' from cache -""")) - -test.fail_test(os.path.exists(test.workpath('src', 'cat.out'))) - -# Blow away and recreate the CacheDir, then verify that --cache-populate -# repopulates the cache with the local built targets. DO NOT CLEAN UP. -shutil.rmtree(test.workpath('cache')) -test.subdir('cache') - -test.run(chdir = 'src', arguments = '--cache-populate .') - -test.run(chdir = 'src', arguments = '-c .') - -test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ -Retrieved `aaa.out' from cache -Retrieved `bbb.out' from cache -Retrieved `ccc.out' from cache -Retrieved `all' from cache -""")) - -test.fail_test(os.path.exists(test.workpath('src', 'cat.out'))) - -# All done. -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 populating a CacheDir with the --cache-force option. +""" + +import os.path +import shutil + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('cache', 'src') + +test.write(['src', 'SConstruct'], """ +DefaultEnvironment(tools=[]) +def cat(env, source, target): + target = str(target[0]) + with open('cat.out', 'a') as f: + f.write(target + "\\n") + with open(target, "w") as f: + for src in source: + with open(str(src), "r") as f2: + f.write(f2.read()) +env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) +env.Cat('aaa.out', 'aaa.in') +env.Cat('bbb.out', 'bbb.in') +env.Cat('ccc.out', 'ccc.in') +env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) +CacheDir(r'%s') +""" % test.workpath('cache')) + +test.write(['src', 'aaa.in'], "aaa.in\n") +test.write(['src', 'bbb.in'], "bbb.in\n") +test.write(['src', 'ccc.in'], "ccc.in\n") + +# Verify that a normal build works correctly, and clean up. +# This should populate the cache with our derived files. +test.run(chdir = 'src', arguments = '.') + +test.must_match(['src','all'],"aaa.in\nbbb.in\nccc.in\n", mode='r') +# test.fail_test(test.read(['src', 'all']) != "aaa.in\nbbb.in\nccc.in\n") +test.must_match(['src','cat.out'],"aaa.out\nbbb.out\nccc.out\nall\n", mode='r') +# test.fail_test(test.read(['src', 'cat.out']) != "aaa.out\nbbb.out\nccc.out\nall\n") + +test.up_to_date(chdir = 'src', arguments = '.') + +test.run(chdir = 'src', arguments = '-c .') +test.unlink(['src', 'cat.out']) + +# Verify that we now retrieve the derived files from cache, +# not rebuild them. DO NOT CLEAN UP. +test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ +Retrieved `aaa.out' from cache +Retrieved `bbb.out' from cache +Retrieved `ccc.out' from cache +Retrieved `all' from cache +""")) + +test.fail_test(os.path.exists(test.workpath('src', 'cat.out'))) + +test.up_to_date(chdir = 'src', arguments = '.') + +# Blow away and recreate the CacheDir, then verify that --cache-force +# repopulates the cache with the local built targets. DO NOT CLEAN UP. +shutil.rmtree(test.workpath('cache')) +test.subdir('cache') + +test.run(chdir = 'src', arguments = '--cache-force .') + +test.run(chdir = 'src', arguments = '-c .') + +test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ +Retrieved `aaa.out' from cache +Retrieved `bbb.out' from cache +Retrieved `ccc.out' from cache +Retrieved `all' from cache +""")) + +test.fail_test(os.path.exists(test.workpath('src', 'cat.out'))) + +# Blow away and recreate the CacheDir, then verify that --cache-populate +# repopulates the cache with the local built targets. DO NOT CLEAN UP. +shutil.rmtree(test.workpath('cache')) +test.subdir('cache') + +test.run(chdir = 'src', arguments = '--cache-populate .') + +test.run(chdir = 'src', arguments = '-c .') + +test.run(chdir = 'src', arguments = '.', stdout = test.wrap_stdout("""\ +Retrieved `aaa.out' from cache +Retrieved `bbb.out' from cache +Retrieved `ccc.out' from cache +Retrieved `all' from cache +""")) + +test.fail_test(os.path.exists(test.workpath('src', 'cat.out'))) + +# All done. +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CacheDir/symlink.py b/test/CacheDir/symlink.py index 9645f4d2df..36ca4be34f 100644 --- a/test/CacheDir/symlink.py +++ b/test/CacheDir/symlink.py @@ -1,76 +1,76 @@ -#!/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._" -import os -import sys - -import TestSCons - -""" -Verify that we push and retrieve a built symlink to/from a CacheDir() -as an actualy symlink, not by copying the file contents. -""" - - - - -test = TestSCons.TestSCons() - -if not hasattr(os, 'symlink') or sys.platform == 'win32': - # Skip test on windows as well, because this requires permissions which aren't default - import sys - test.skip_test('%s has no os.symlink() method; skipping test\n' % sys.executable) - -test.write('SConstruct', """\ -CacheDir('cache') -import os -Symlink = Action(lambda target, source, env: - os.symlink(str(source[0]), str(target[0])), - "os.symlink($SOURCE, $TARGET)") -Command('file.symlink', 'file.txt', Symlink) -""") - -test.write('file.txt', "file.txt\n") - -test.run(arguments = '.') - -test.fail_test(not os.path.islink('file.symlink')) -test.must_match('file.symlink', "file.txt\n") - -test.run(arguments = '-c .') - -test.must_not_exist('file.symlink') - -test.run(arguments = '.') - -test.fail_test(not os.path.islink('file.symlink')) -test.must_match('file.symlink', "file.txt\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._" +import os +import sys + +import TestSCons + +""" +Verify that we push and retrieve a built symlink to/from a CacheDir() +as an actualy symlink, not by copying the file contents. +""" + + + + +test = TestSCons.TestSCons() + +if not hasattr(os, 'symlink') or sys.platform == 'win32': + # Skip test on windows as well, because this requires permissions which aren't default + import sys + test.skip_test('%s has no os.symlink() method; skipping test\n' % sys.executable) + +test.write('SConstruct', """\ +CacheDir('cache') +import os +Symlink = Action(lambda target, source, env: + os.symlink(str(source[0]), str(target[0])), + "os.symlink($SOURCE, $TARGET)") +Command('file.symlink', 'file.txt', Symlink) +""") + +test.write('file.txt', "file.txt\n") + +test.run(arguments = '.') + +test.fail_test(not os.path.islink('file.symlink')) +test.must_match('file.symlink', "file.txt\n") + +test.run(arguments = '-c .') + +test.must_not_exist('file.symlink') + +test.run(arguments = '.') + +test.fail_test(not os.path.islink('file.symlink')) +test.must_match('file.symlink', "file.txt\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/CacheDir/up-to-date-q.py b/test/CacheDir/up-to-date-q.py index c25a6777ad..c8fa1e3805 100644 --- a/test/CacheDir/up-to-date-q.py +++ b/test/CacheDir/up-to-date-q.py @@ -1,86 +1,86 @@ -#!/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 targets retrieved from CacheDir() are reported as -up-to-date by the -q option. - -Thanks to dvitek for the test case. -""" - -# Demonstrate a regression between 0.96.1 and 0.96.93. -# -# SCons would incorrectly believe files are stale if they were retrieved -# from the cache in a previous invocation. -# -# What this script does: -# 1. Set up two identical C project directories called 'alpha' and -# 'beta', which use the same cache -# 2. Invoke scons on 'alpha' -# 3. Invoke scons on 'beta', which successfully draws output -# files from the cache -# 4. Invoke scons again, asserting (with -q) that 'beta' is up to date -# -# Step 4 failed in 0.96.93. In practice, this problem would lead to -# lots of unecessary fetches from the cache during incremental -# builds (because they behaved like non-incremental builds). - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('cache', 'alpha', 'beta') - -foo_c = """ -int main(void){ return 0; } -""" - -sconstruct = """ -CacheDir(r'%s') -Program('foo', 'foo.c') -""" % test.workpath('cache') - -test.write('alpha/foo.c', foo_c) -test.write('alpha/SConstruct', sconstruct) - -test.write('beta/foo.c', foo_c) -test.write('beta/SConstruct', sconstruct) - -# First build, populates the cache -test.run(chdir = 'alpha', arguments = '.') - -# Second build, everything is a cache hit -test.run(chdir = 'beta', arguments = '.') - -# Since we just built 'beta', it ought to be up to date. -test.run(chdir = 'beta', arguments = '. -q') - -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 targets retrieved from CacheDir() are reported as +up-to-date by the -q option. + +Thanks to dvitek for the test case. +""" + +# Demonstrate a regression between 0.96.1 and 0.96.93. +# +# SCons would incorrectly believe files are stale if they were retrieved +# from the cache in a previous invocation. +# +# What this script does: +# 1. Set up two identical C project directories called 'alpha' and +# 'beta', which use the same cache +# 2. Invoke scons on 'alpha' +# 3. Invoke scons on 'beta', which successfully draws output +# files from the cache +# 4. Invoke scons again, asserting (with -q) that 'beta' is up to date +# +# Step 4 failed in 0.96.93. In practice, this problem would lead to +# lots of unecessary fetches from the cache during incremental +# builds (because they behaved like non-incremental builds). + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('cache', 'alpha', 'beta') + +foo_c = """ +int main(void){ return 0; } +""" + +sconstruct = """ +CacheDir(r'%s') +Program('foo', 'foo.c') +""" % test.workpath('cache') + +test.write('alpha/foo.c', foo_c) +test.write('alpha/SConstruct', sconstruct) + +test.write('beta/foo.c', foo_c) +test.write('beta/SConstruct', sconstruct) + +# First build, populates the cache +test.run(chdir = 'alpha', arguments = '.') + +# Second build, everything is a cache hit +test.run(chdir = 'beta', arguments = '.') + +# Since we just built 'beta', it ought to be up to date. +test.run(chdir = 'beta', arguments = '. -q') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/CacheDir/value_dependencies.py b/test/CacheDir/value_dependencies.py index 73ebc60e04..b34401dc9c 100644 --- a/test/CacheDir/value_dependencies.py +++ b/test/CacheDir/value_dependencies.py @@ -1,51 +1,51 @@ -#!/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 bwuilds with caching work for an action with a Value as a child -in a variety of cases. Specifically: - -1. A source file that depends on a Value. -2. A source directory that depends on a Value. -3. A scanner that returns a Value and a directory that depends on a Value. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.dir_fixture('value_dependencies') -test.subdir('cache') - -# First build, populates the cache -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._" + +""" +Verify that bwuilds with caching work for an action with a Value as a child +in a variety of cases. Specifically: + +1. A source file that depends on a Value. +2. A source directory that depends on a Value. +3. A scanner that returns a Value and a directory that depends on a Value. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.dir_fixture('value_dependencies') +test.subdir('cache') + +# First build, populates the cache +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/Clang/clang_default_environment.py b/test/Clang/clang_default_environment.py index dc75bd4898..41bb44e15f 100644 --- a/test/Clang/clang_default_environment.py +++ b/test/Clang/clang_default_environment.py @@ -1,62 +1,62 @@ -#!/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. - -import TestSCons - -_exe = TestSCons._exe -test = TestSCons.TestSCons() - -if not test.where_is('clang'): - test.skip_test("Could not find 'clang', skipping test.\n") - -## This will likely NOT use clang - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -env = Environment(tools=['clang','link']) -env.Program('foo.c') -""") - -test.write('foo.c', """\ -#include -int main(int argc, char ** argv) { - printf("Hello!"); - return 0; -} -""") - -test.run() - -test.run(program=test.workpath('foo'+_exe)) - -test.fail_test(not test.stdout() == 'Hello!') - -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. + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang', skipping test.\n") + +## This will likely NOT use clang + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +env = Environment(tools=['clang','link']) +env.Program('foo.c') +""") + +test.write('foo.c', """\ +#include +int main(int argc, char ** argv) { + printf("Hello!"); + return 0; +} +""") + +test.run() + +test.run(program=test.workpath('foo'+_exe)) + +test.fail_test(not test.stdout() == 'Hello!') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clang_specific_environment.py b/test/Clang/clang_specific_environment.py index d0e145d206..10637e6635 100644 --- a/test/Clang/clang_specific_environment.py +++ b/test/Clang/clang_specific_environment.py @@ -1,60 +1,60 @@ -#!/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. - -import TestSCons - -_exe = TestSCons._exe -test = TestSCons.TestSCons() - -if not test.where_is('clang'): - test.skip_test("Could not find 'clang', skipping test.\n") - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -env = Environment(tools=['clang', 'link']) -env.Program('foo.c') -""") - -test.write('foo.c', """\ -#include -int main(int argc, char ** argv) { - printf("Hello!"); - return 0; -} -""") - -test.run() - -test.run(program=test.workpath('foo'+_exe)) - -test.fail_test(not test.stdout() == 'Hello!') - -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. + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang', skipping test.\n") + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=['clang', 'link']) +env.Program('foo.c') +""") + +test.write('foo.c', """\ +#include +int main(int argc, char ** argv) { + printf("Hello!"); + return 0; +} +""") + +test.run() + +test.run(program=test.workpath('foo'+_exe)) + +test.fail_test(not test.stdout() == 'Hello!') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clang_static_library.py b/test/Clang/clang_static_library.py index 9d21def92d..c0d86d19c5 100644 --- a/test/Clang/clang_static_library.py +++ b/test/Clang/clang_static_library.py @@ -1,68 +1,68 @@ -#!/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. - -import TestSCons -from TestCmd import IS_WINDOWS - -_exe = TestSCons._exe -test = TestSCons.TestSCons() - -if not test.where_is('clang'): - test.skip_test("Could not find 'clang', skipping test.\n") - -if IS_WINDOWS: - foo_lib = 'foo.lib' - archiver = 'mslib' - # TODO: other Windows combinations exist (not depending on - # mslib (lib.exe) from MS Build Tools / Visual Studio). - # Expand this if there is demand. -else: - foo_lib = 'libfoo.a' - archiver = 'ar' - - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -env = Environment(tools=['mingw','clang', '%s']) -env.StaticLibrary('foo', 'foo.c') -""" % archiver) - -test.write('foo.c', """\ -int bar() { - return 42; -} -""") - -test.run() - -test.must_exist(test.workpath(foo_lib)) - -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. + +import TestSCons +from TestCmd import IS_WINDOWS + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang', skipping test.\n") + +if IS_WINDOWS: + foo_lib = 'foo.lib' + archiver = 'mslib' + # TODO: other Windows combinations exist (not depending on + # mslib (lib.exe) from MS Build Tools / Visual Studio). + # Expand this if there is demand. +else: + foo_lib = 'libfoo.a' + archiver = 'ar' + + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=['mingw','clang', '%s']) +env.StaticLibrary('foo', 'foo.c') +""" % archiver) + +test.write('foo.c', """\ +int bar() { + return 42; +} +""") + +test.run() + +test.must_exist(test.workpath(foo_lib)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clangxx_default_environment.py b/test/Clang/clangxx_default_environment.py index 82d99aa24f..ef5929e7dc 100644 --- a/test/Clang/clangxx_default_environment.py +++ b/test/Clang/clangxx_default_environment.py @@ -1,62 +1,62 @@ -#!/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. - -import TestSCons - -_exe = TestSCons._exe -test = TestSCons.TestSCons() - -if not test.where_is('clang'): - test.skip_test("Could not find 'clang++', skipping test.\n") - -## This will likely NOT use clang++. - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -env = Environment(tools=['clangxx','link']) -env.Program('foo.cpp') -""") - -test.write('foo.cpp', """\ -#include -int main(int argc, char ** argv) { - std::cout << "Hello!" << std::endl; - return 0; -} -""") - -test.run() - -test.run(program=test.workpath('foo'+_exe)) - -test.fail_test(not test.stdout() == 'Hello!\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. + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang++', skipping test.\n") + +## This will likely NOT use clang++. + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=['clangxx','link']) +env.Program('foo.cpp') +""") + +test.write('foo.cpp', """\ +#include +int main(int argc, char ** argv) { + std::cout << "Hello!" << std::endl; + return 0; +} +""") + +test.run() + +test.run(program=test.workpath('foo'+_exe)) + +test.fail_test(not test.stdout() == 'Hello!\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/Clang/clangxx_shared_library.py b/test/Clang/clangxx_shared_library.py index dbc4831b9b..8471aa1680 100644 --- a/test/Clang/clangxx_shared_library.py +++ b/test/Clang/clangxx_shared_library.py @@ -1,77 +1,77 @@ -#!/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. - -import TestSCons - -from SCons.Environment import Base - -_exe = TestSCons._exe -test = TestSCons.TestSCons() - -if not test.where_is('clang'): - test.skip_test("Could not find 'clang++', skipping test.\n") - -platform = Base()['PLATFORM'] -if platform == 'posix': - filename_options = ['foo.os'] - libraryname = 'libfoo.so' -elif platform == 'darwin': - filename_options = ['foo.os'] - libraryname = 'libfoo.dylib' -elif platform == 'win32': - filename_options = ['foo.obj','foo.os'] - libraryname = 'foo.dll' -elif platform == 'sunos': - filename_options = ['foo.pic.o'] - libraryname = 'libfoo.so' -else: - test.fail_test() - - - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -env = Environment(tools=['clang++', 'link']) -env.SharedLibrary('foo', 'foo.cpp') -""") - -test.write('foo.cpp', """\ -int bar() { - return 42; -} -""") - -test.run() - -test.must_exist_one_of([test.workpath(f) for f in filename_options]) -test.must_exist(test.workpath(libraryname)) - -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. + +import TestSCons + +from SCons.Environment import Base + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang++', skipping test.\n") + +platform = Base()['PLATFORM'] +if platform == 'posix': + filename_options = ['foo.os'] + libraryname = 'libfoo.so' +elif platform == 'darwin': + filename_options = ['foo.os'] + libraryname = 'libfoo.dylib' +elif platform == 'win32': + filename_options = ['foo.obj','foo.os'] + libraryname = 'foo.dll' +elif platform == 'sunos': + filename_options = ['foo.pic.o'] + libraryname = 'libfoo.so' +else: + test.fail_test() + + + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=['clang++', 'link']) +env.SharedLibrary('foo', 'foo.cpp') +""") + +test.write('foo.cpp', """\ +int bar() { + return 42; +} +""") + +test.run() + +test.must_exist_one_of([test.workpath(f) for f in filename_options]) +test.must_exist(test.workpath(libraryname)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clang/clangxx_specific_environment.py b/test/Clang/clangxx_specific_environment.py index 5ca3c1229e..f26ebf92c8 100644 --- a/test/Clang/clangxx_specific_environment.py +++ b/test/Clang/clangxx_specific_environment.py @@ -1,60 +1,60 @@ -#!/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. - -import TestSCons - -_exe = TestSCons._exe -test = TestSCons.TestSCons() - -if not test.where_is('clang'): - test.skip_test("Could not find 'clang++', skipping test.\n") - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -env = Environment(tools=['clang++', 'link']) -env.Program('foo.cpp') -""") - -test.write('foo.cpp', """\ -#include -int main(int argc, char ** argv) { - std::cout << "Hello!" << std::endl; - return 0; -} -""") - -test.run() - -test.run(program=test.workpath('foo'+_exe)) - -test.fail_test(not test.stdout() == 'Hello!\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. + +import TestSCons + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang++', skipping test.\n") + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=['clang++', 'link']) +env.Program('foo.cpp') +""") + +test.write('foo.cpp', """\ +#include +int main(int argc, char ** argv) { + std::cout << "Hello!" << std::endl; + return 0; +} +""") + +test.run() + +test.run(program=test.workpath('foo'+_exe)) + +test.fail_test(not test.stdout() == 'Hello!\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/Clang/clangxx_static_library.py b/test/Clang/clangxx_static_library.py index 62711115ef..d697f1a9f5 100644 --- a/test/Clang/clangxx_static_library.py +++ b/test/Clang/clangxx_static_library.py @@ -1,68 +1,68 @@ -#!/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. - -import TestSCons -from TestCmd import IS_WINDOWS - -_exe = TestSCons._exe -test = TestSCons.TestSCons() - -if not test.where_is('clang'): - test.skip_test("Could not find 'clang++', skipping test.\n") - -if IS_WINDOWS: - foo_lib = 'foo.lib' - archiver = 'mslib' - # TODO: other Windows combinations exist (not depending on - # mslib (lib.exe) from MS Build Tools / Visual Studio). - # Expand this if there is demand. -else: - foo_lib = 'libfoo.a' - archiver = 'ar' - - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -env = Environment(tools=['mingw','clang++', '%s']) -env.StaticLibrary('foo', 'foo.cpp') -""" % archiver) - -test.write('foo.cpp', """\ -int bar() { - return 42; -} -""") - -test.run() - -test.must_exist(test.workpath(foo_lib)) - -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. + +import TestSCons +from TestCmd import IS_WINDOWS + +_exe = TestSCons._exe +test = TestSCons.TestSCons() + +if not test.where_is('clang'): + test.skip_test("Could not find 'clang++', skipping test.\n") + +if IS_WINDOWS: + foo_lib = 'foo.lib' + archiver = 'mslib' + # TODO: other Windows combinations exist (not depending on + # mslib (lib.exe) from MS Build Tools / Visual Studio). + # Expand this if there is demand. +else: + foo_lib = 'libfoo.a' + archiver = 'ar' + + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +env = Environment(tools=['mingw','clang++', '%s']) +env.StaticLibrary('foo', 'foo.cpp') +""" % archiver) + +test.write('foo.cpp', """\ +int bar() { + return 42; +} +""") + +test.run() + +test.must_exist(test.workpath(foo_lib)) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clean/basic.py b/test/Clean/basic.py index 1fc90efdde..ee510cbbde 100644 --- a/test/Clean/basic.py +++ b/test/Clean/basic.py @@ -1,185 +1,185 @@ -#!/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 various basic uses of the -c (clean) option. -""" - -import os - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.write('build.py', r""" -import sys -with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp: - ofp.write(ifp.read()) -""") - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -B = Builder(action = r'%(_python_)s build.py $TARGETS $SOURCES') -env = Environment(tools=[], BUILDERS = { 'B' : B }) -env.B(target = 'foo1.out', source = 'foo1.in') -env.B(target = 'foo2.out', source = 'foo2.xxx') -env.B(target = 'foo2.xxx', source = 'foo2.in') -env.B(target = 'foo3.out', source = 'foo3.in') -env.B(target = 'foo4.out', source = 'foo4.in') -env.NoClean('foo4.out') -import os -import sys -if hasattr(os, 'symlink') and sys.platform !='win32': - def symlink1(env, target, source): - # symlink to a file that exists - os.symlink(str(source[0]), str(target[0])) - env.Command(target = 'symlink1', source = 'foo1.in', action = symlink1) - def symlink2(env, target, source): - # force symlink to a file that doesn't exist - os.symlink('does_not_exist', str(target[0])) - env.Command(target = 'symlink2', source = 'foo1.in', action = symlink2) -# Test handling of Builder calls that have multiple targets. -env.Command(['touch1.out', 'touch2.out'], - [], - [Touch('${TARGETS[0]}'), Touch('${TARGETS[1]}')]) -""" % locals()) - -test.write('foo1.in', "foo1.in\n") - -test.write('foo2.in', "foo2.in\n") - -test.write('foo3.in', "foo3.in\n") - -test.write('foo4.in', "foo4.in\n") - -test.run(arguments = 'foo1.out foo2.out foo3.out foo4.out') - -test.must_match(test.workpath('foo1.out'), "foo1.in\n") -test.must_match(test.workpath('foo2.xxx'), "foo2.in\n") -test.must_match(test.workpath('foo2.out'), "foo2.in\n") -test.must_match(test.workpath('foo3.out'), "foo3.in\n") -test.must_match(test.workpath('foo4.out'), "foo4.in\n") - -test.run(arguments = '-c foo1.out', - stdout = test.wrap_stdout("Removed foo1.out\n", cleaning=1)) - -test.must_not_exist(test.workpath('foo1.out')) -test.must_exist(test.workpath('foo2.xxx')) -test.must_exist(test.workpath('foo2.out')) -test.must_exist(test.workpath('foo3.out')) -test.must_exist(test.workpath('foo4.out')) - -test.run(arguments = '--clean foo2.out foo2.xxx', - stdout = test.wrap_stdout("Removed foo2.xxx\nRemoved foo2.out\n", - cleaning=1)) - -test.must_not_exist(test.workpath('foo1.out')) -test.must_not_exist(test.workpath('foo2.xxx')) -test.must_not_exist(test.workpath('foo2.out')) -test.must_exist(test.workpath('foo3.out')) -test.must_exist(test.workpath('foo4.out')) - -test.run(arguments = '--remove foo3.out', - stdout = test.wrap_stdout("Removed foo3.out\n", cleaning=1)) - -test.must_not_exist(test.workpath('foo1.out')) -test.must_not_exist(test.workpath('foo2.xxx')) -test.must_not_exist(test.workpath('foo2.out')) -test.must_not_exist(test.workpath('foo3.out')) -test.must_exist(test.workpath('foo4.out')) - -test.run(arguments = '.') - -test.must_match(test.workpath('foo1.out'), "foo1.in\n") -test.must_match(test.workpath('foo2.xxx'), "foo2.in\n") -test.must_match(test.workpath('foo2.out'), "foo2.in\n") -test.must_match(test.workpath('foo3.out'), "foo3.in\n") -test.must_match(test.workpath('foo3.out'), "foo3.in\n") -test.must_match(test.workpath('foo4.out'), "foo4.in\n") -test.must_exist(test.workpath('touch1.out')) -test.must_exist(test.workpath('touch2.out')) - -if test.platform_has_symlink(): - test.fail_test(not os.path.islink(test.workpath('symlink1'))) - test.fail_test(not os.path.islink(test.workpath('symlink2'))) - -test.run(arguments = '-c foo2.xxx', - stdout = test.wrap_stdout("Removed foo2.xxx\n", cleaning=1)) - -test.must_match(test.workpath('foo1.out'), "foo1.in\n") -test.must_not_exist(test.workpath('foo2.xxx')) -test.must_match(test.workpath('foo2.out'), "foo2.in\n") -test.must_match(test.workpath('foo3.out'), "foo3.in\n") -test.must_match(test.workpath('foo4.out'), "foo4.in\n") -test.must_exist(test.workpath('touch1.out')) -test.must_exist(test.workpath('touch2.out')) - -test.run(arguments = '-c .') - -test.must_not_exist(test.workpath('foo1.out')) -test.must_not_exist(test.workpath('foo2.out')) -test.must_not_exist(test.workpath('foo3.out')) -test.must_exist(test.workpath('foo4.out')) -test.must_not_exist(test.workpath('touch1.out')) -test.must_not_exist(test.workpath('touch2.out')) - -if test.platform_has_symlink(): - test.fail_test(os.path.islink(test.workpath('symlink1'))) - test.fail_test(os.path.islink(test.workpath('symlink2'))) - -args = 'foo1.out foo2.out foo3.out touch1.out' - -expect = test.wrap_stdout("""\ -Removed foo1.out -Removed foo2.xxx -Removed foo2.out -Removed foo3.out -Removed touch1.out -Removed touch2.out -""", cleaning=1) - -test.run(arguments = args) - -test.run(arguments = '-c -n ' + args, stdout = expect) - -test.run(arguments = '-n -c ' + args, stdout = expect) - -test.must_match(test.workpath('foo1.out'), "foo1.in\n") -test.must_match(test.workpath('foo2.xxx'), "foo2.in\n") -test.must_match(test.workpath('foo2.out'), "foo2.in\n") -test.must_match(test.workpath('foo3.out'), "foo3.in\n") -test.must_match(test.workpath('foo4.out'), "foo4.in\n") -test.must_exist(test.workpath('touch1.out')) -test.must_exist(test.workpath('touch2.out')) - -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 various basic uses of the -c (clean) option. +""" + +import os + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.write('build.py', r""" +import sys +with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp: + ofp.write(ifp.read()) +""") + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +B = Builder(action = r'%(_python_)s build.py $TARGETS $SOURCES') +env = Environment(tools=[], BUILDERS = { 'B' : B }) +env.B(target = 'foo1.out', source = 'foo1.in') +env.B(target = 'foo2.out', source = 'foo2.xxx') +env.B(target = 'foo2.xxx', source = 'foo2.in') +env.B(target = 'foo3.out', source = 'foo3.in') +env.B(target = 'foo4.out', source = 'foo4.in') +env.NoClean('foo4.out') +import os +import sys +if hasattr(os, 'symlink') and sys.platform !='win32': + def symlink1(env, target, source): + # symlink to a file that exists + os.symlink(str(source[0]), str(target[0])) + env.Command(target = 'symlink1', source = 'foo1.in', action = symlink1) + def symlink2(env, target, source): + # force symlink to a file that doesn't exist + os.symlink('does_not_exist', str(target[0])) + env.Command(target = 'symlink2', source = 'foo1.in', action = symlink2) +# Test handling of Builder calls that have multiple targets. +env.Command(['touch1.out', 'touch2.out'], + [], + [Touch('${TARGETS[0]}'), Touch('${TARGETS[1]}')]) +""" % locals()) + +test.write('foo1.in', "foo1.in\n") + +test.write('foo2.in', "foo2.in\n") + +test.write('foo3.in', "foo3.in\n") + +test.write('foo4.in', "foo4.in\n") + +test.run(arguments = 'foo1.out foo2.out foo3.out foo4.out') + +test.must_match(test.workpath('foo1.out'), "foo1.in\n") +test.must_match(test.workpath('foo2.xxx'), "foo2.in\n") +test.must_match(test.workpath('foo2.out'), "foo2.in\n") +test.must_match(test.workpath('foo3.out'), "foo3.in\n") +test.must_match(test.workpath('foo4.out'), "foo4.in\n") + +test.run(arguments = '-c foo1.out', + stdout = test.wrap_stdout("Removed foo1.out\n", cleaning=1)) + +test.must_not_exist(test.workpath('foo1.out')) +test.must_exist(test.workpath('foo2.xxx')) +test.must_exist(test.workpath('foo2.out')) +test.must_exist(test.workpath('foo3.out')) +test.must_exist(test.workpath('foo4.out')) + +test.run(arguments = '--clean foo2.out foo2.xxx', + stdout = test.wrap_stdout("Removed foo2.xxx\nRemoved foo2.out\n", + cleaning=1)) + +test.must_not_exist(test.workpath('foo1.out')) +test.must_not_exist(test.workpath('foo2.xxx')) +test.must_not_exist(test.workpath('foo2.out')) +test.must_exist(test.workpath('foo3.out')) +test.must_exist(test.workpath('foo4.out')) + +test.run(arguments = '--remove foo3.out', + stdout = test.wrap_stdout("Removed foo3.out\n", cleaning=1)) + +test.must_not_exist(test.workpath('foo1.out')) +test.must_not_exist(test.workpath('foo2.xxx')) +test.must_not_exist(test.workpath('foo2.out')) +test.must_not_exist(test.workpath('foo3.out')) +test.must_exist(test.workpath('foo4.out')) + +test.run(arguments = '.') + +test.must_match(test.workpath('foo1.out'), "foo1.in\n") +test.must_match(test.workpath('foo2.xxx'), "foo2.in\n") +test.must_match(test.workpath('foo2.out'), "foo2.in\n") +test.must_match(test.workpath('foo3.out'), "foo3.in\n") +test.must_match(test.workpath('foo3.out'), "foo3.in\n") +test.must_match(test.workpath('foo4.out'), "foo4.in\n") +test.must_exist(test.workpath('touch1.out')) +test.must_exist(test.workpath('touch2.out')) + +if test.platform_has_symlink(): + test.fail_test(not os.path.islink(test.workpath('symlink1'))) + test.fail_test(not os.path.islink(test.workpath('symlink2'))) + +test.run(arguments = '-c foo2.xxx', + stdout = test.wrap_stdout("Removed foo2.xxx\n", cleaning=1)) + +test.must_match(test.workpath('foo1.out'), "foo1.in\n") +test.must_not_exist(test.workpath('foo2.xxx')) +test.must_match(test.workpath('foo2.out'), "foo2.in\n") +test.must_match(test.workpath('foo3.out'), "foo3.in\n") +test.must_match(test.workpath('foo4.out'), "foo4.in\n") +test.must_exist(test.workpath('touch1.out')) +test.must_exist(test.workpath('touch2.out')) + +test.run(arguments = '-c .') + +test.must_not_exist(test.workpath('foo1.out')) +test.must_not_exist(test.workpath('foo2.out')) +test.must_not_exist(test.workpath('foo3.out')) +test.must_exist(test.workpath('foo4.out')) +test.must_not_exist(test.workpath('touch1.out')) +test.must_not_exist(test.workpath('touch2.out')) + +if test.platform_has_symlink(): + test.fail_test(os.path.islink(test.workpath('symlink1'))) + test.fail_test(os.path.islink(test.workpath('symlink2'))) + +args = 'foo1.out foo2.out foo3.out touch1.out' + +expect = test.wrap_stdout("""\ +Removed foo1.out +Removed foo2.xxx +Removed foo2.out +Removed foo3.out +Removed touch1.out +Removed touch2.out +""", cleaning=1) + +test.run(arguments = args) + +test.run(arguments = '-c -n ' + args, stdout = expect) + +test.run(arguments = '-n -c ' + args, stdout = expect) + +test.must_match(test.workpath('foo1.out'), "foo1.in\n") +test.must_match(test.workpath('foo2.xxx'), "foo2.in\n") +test.must_match(test.workpath('foo2.out'), "foo2.in\n") +test.must_match(test.workpath('foo3.out'), "foo3.in\n") +test.must_match(test.workpath('foo4.out'), "foo4.in\n") +test.must_exist(test.workpath('touch1.out')) +test.must_exist(test.workpath('touch2.out')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clean/function.py b/test/Clean/function.py index b73fe6757b..2476e61143 100644 --- a/test/Clean/function.py +++ b/test/Clean/function.py @@ -1,119 +1,119 @@ -#!/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 use of the Clean() function. -""" - -import os - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.write('build.py', r""" -import sys -with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp: - ofp.write(ifp.read()) -""") - -test.subdir('subd') - -subd_SConscript = os.path.join('subd', 'SConscript') -subd_foon_in = os.path.join('subd', 'foon.in') -subd_foox_in = os.path.join('subd', 'foox.in') - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -B = Builder(action = r'%(_python_)s build.py $TARGETS $SOURCES') -env = Environment(tools=[], BUILDERS = { 'B' : B }, FOO = 'foo2') -env.B(target = 'foo1.out', source = 'foo1.in') -env.B(target = 'foo2.out', source = 'foo2.xxx') -foo2_xxx = env.B(target = 'foo2.xxx', source = 'foo2.in') -env.B(target = 'foo3.out', source = 'foo3.in') -SConscript('subd/SConscript') -Clean(foo2_xxx, ['aux1.x']) -env.Clean(['${FOO}.xxx'], ['aux2.x']) -Clean('.', ['subd']) -""" % locals()) - -test.write(['subd', 'SConscript'], """ -Clean('.', 'foox.in') -""") - -test.write('foo1.in', "foo1.in\n") -test.write('foo2.in', "foo2.in\n") -test.write('foo3.in', "foo3.in\n") -test.write(['subd', 'foon.in'], "foon.in\n") -test.write(['subd', 'foox.in'], "foox.in\n") -test.write('aux1.x', "aux1.x\n") -test.write('aux2.x', "aux2.x\n") - -test.run() - -expect = test.wrap_stdout("""Removed foo2.xxx -Removed aux1.x -Removed aux2.x -""", cleaning=1) -test.run(arguments = '-c foo2.xxx', stdout=expect) -test.must_match(test.workpath('foo1.out'), "foo1.in\n") -test.must_not_exist(test.workpath('foo2.xxx')) -test.must_match(test.workpath('foo2.out'), "foo2.in\n") -test.must_match(test.workpath('foo3.out'), "foo3.in\n") - -expect = test.wrap_stdout("Removed %s\n" % subd_foox_in, cleaning = 1) -test.run(arguments = '-c subd', stdout=expect) -test.must_not_exist(test.workpath('foox.in')) - -expect = test.wrap_stdout("""Removed foo1.out -Removed foo2.xxx -Removed foo2.out -Removed foo3.out -Removed %(subd_SConscript)s -Removed %(subd_foon_in)s -Removed directory subd -""" % locals(), cleaning = 1) -test.run(arguments = '-c -n .', stdout=expect) - -expect = test.wrap_stdout("""Removed foo1.out -Removed foo2.out -Removed foo3.out -Removed %(subd_SConscript)s -Removed %(subd_foon_in)s -Removed directory subd -""" % locals(), cleaning = 1) -test.run(arguments = '-c .', stdout=expect) -test.must_not_exist(test.workpath('subdir', 'foon.in')) -test.must_not_exist(test.workpath('subdir')) - -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 use of the Clean() function. +""" + +import os + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.write('build.py', r""" +import sys +with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp: + ofp.write(ifp.read()) +""") + +test.subdir('subd') + +subd_SConscript = os.path.join('subd', 'SConscript') +subd_foon_in = os.path.join('subd', 'foon.in') +subd_foox_in = os.path.join('subd', 'foox.in') + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +B = Builder(action = r'%(_python_)s build.py $TARGETS $SOURCES') +env = Environment(tools=[], BUILDERS = { 'B' : B }, FOO = 'foo2') +env.B(target = 'foo1.out', source = 'foo1.in') +env.B(target = 'foo2.out', source = 'foo2.xxx') +foo2_xxx = env.B(target = 'foo2.xxx', source = 'foo2.in') +env.B(target = 'foo3.out', source = 'foo3.in') +SConscript('subd/SConscript') +Clean(foo2_xxx, ['aux1.x']) +env.Clean(['${FOO}.xxx'], ['aux2.x']) +Clean('.', ['subd']) +""" % locals()) + +test.write(['subd', 'SConscript'], """ +Clean('.', 'foox.in') +""") + +test.write('foo1.in', "foo1.in\n") +test.write('foo2.in', "foo2.in\n") +test.write('foo3.in', "foo3.in\n") +test.write(['subd', 'foon.in'], "foon.in\n") +test.write(['subd', 'foox.in'], "foox.in\n") +test.write('aux1.x', "aux1.x\n") +test.write('aux2.x', "aux2.x\n") + +test.run() + +expect = test.wrap_stdout("""Removed foo2.xxx +Removed aux1.x +Removed aux2.x +""", cleaning=1) +test.run(arguments = '-c foo2.xxx', stdout=expect) +test.must_match(test.workpath('foo1.out'), "foo1.in\n") +test.must_not_exist(test.workpath('foo2.xxx')) +test.must_match(test.workpath('foo2.out'), "foo2.in\n") +test.must_match(test.workpath('foo3.out'), "foo3.in\n") + +expect = test.wrap_stdout("Removed %s\n" % subd_foox_in, cleaning = 1) +test.run(arguments = '-c subd', stdout=expect) +test.must_not_exist(test.workpath('foox.in')) + +expect = test.wrap_stdout("""Removed foo1.out +Removed foo2.xxx +Removed foo2.out +Removed foo3.out +Removed %(subd_SConscript)s +Removed %(subd_foon_in)s +Removed directory subd +""" % locals(), cleaning = 1) +test.run(arguments = '-c -n .', stdout=expect) + +expect = test.wrap_stdout("""Removed foo1.out +Removed foo2.out +Removed foo3.out +Removed %(subd_SConscript)s +Removed %(subd_foon_in)s +Removed directory subd +""" % locals(), cleaning = 1) +test.run(arguments = '-c .', stdout=expect) +test.must_not_exist(test.workpath('subdir', 'foon.in')) +test.must_not_exist(test.workpath('subdir')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clean/mkfifo.py b/test/Clean/mkfifo.py index cfe20c6b6b..62d19d0465 100644 --- a/test/Clean/mkfifo.py +++ b/test/Clean/mkfifo.py @@ -1,81 +1,81 @@ -#!/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 SCons reports an error when cleaning up a target directory -containing a named pipe created with o.mkfifo(). -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -if not hasattr(os, 'mkfifo'): - test.skip_test('No os.mkfifo() function; skipping test\n') - -test_dir_name = 'testdir' -pipe_path = os.path.join(test_dir_name, 'namedpipe') - -test.write('SConstruct', """\ -Execute(Mkdir("{0}")) -dir = Dir("{0}") -Clean(dir, '{0}') -""".format(test_dir_name)) - -test.run(arguments='-Q -q', stdout='Mkdir("{0}")\n'.format(test_dir_name)) - -os.mkfifo(pipe_path) - -test.must_exist(test.workpath(pipe_path)) - -expect1 = """\ -Mkdir("{0}") -Path '{1}' exists but isn't a file or directory. -scons: Could not remove '{0}': Directory not empty -""".format(test_dir_name, pipe_path) - -expect2 = """\ -Mkdir("{0}") -Path '{1}' exists but isn't a file or directory. -scons: Could not remove '{0}': File exists -""".format(test_dir_name, pipe_path) - -test.run(arguments='-c -Q -q') - -test.must_exist(test.workpath(pipe_path)) - -if test.stdout() not in [expect1, expect2]: - test.diff(expect1, test.stdout(), 'STDOUT ') - test.fail_test() - -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 SCons reports an error when cleaning up a target directory +containing a named pipe created with o.mkfifo(). +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +if not hasattr(os, 'mkfifo'): + test.skip_test('No os.mkfifo() function; skipping test\n') + +test_dir_name = 'testdir' +pipe_path = os.path.join(test_dir_name, 'namedpipe') + +test.write('SConstruct', """\ +Execute(Mkdir("{0}")) +dir = Dir("{0}") +Clean(dir, '{0}') +""".format(test_dir_name)) + +test.run(arguments='-Q -q', stdout='Mkdir("{0}")\n'.format(test_dir_name)) + +os.mkfifo(pipe_path) + +test.must_exist(test.workpath(pipe_path)) + +expect1 = """\ +Mkdir("{0}") +Path '{1}' exists but isn't a file or directory. +scons: Could not remove '{0}': Directory not empty +""".format(test_dir_name, pipe_path) + +expect2 = """\ +Mkdir("{0}") +Path '{1}' exists but isn't a file or directory. +scons: Could not remove '{0}': File exists +""".format(test_dir_name, pipe_path) + +test.run(arguments='-c -Q -q') + +test.must_exist(test.workpath(pipe_path)) + +if test.stdout() not in [expect1, expect2]: + test.diff(expect1, test.stdout(), 'STDOUT ') + test.fail_test() + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Clean/symlinks.py b/test/Clean/symlinks.py index 2f5a1f8602..05fb08be53 100644 --- a/test/Clean/symlinks.py +++ b/test/Clean/symlinks.py @@ -1,63 +1,63 @@ -#!/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 correct deletion of broken symlinks. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -if not test.platform_has_symlink(): - test.skip_test('No os.symlink() function; skipping test\n') - -test.write('SConstruct', """\ -Execute(Mkdir("testdir")) -dir = Dir("testdir") -Clean(dir, 'testdir') -""") - -test.run(arguments = '-Q -q', stdout='Mkdir("testdir")\n') - -os.symlink('testdir/symlinksrc', 'testdir/symlinkdst') - -expect = """\ -Mkdir("testdir") -Removed %s -Removed directory testdir -""" % os.path.join('testdir', 'symlinkdst') - -test.run(arguments = '-c -Q -q', stdout=expect) - -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 correct deletion of broken symlinks. +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +if not test.platform_has_symlink(): + test.skip_test('No os.symlink() function; skipping test\n') + +test.write('SConstruct', """\ +Execute(Mkdir("testdir")) +dir = Dir("testdir") +Clean(dir, 'testdir') +""") + +test.run(arguments = '-Q -q', stdout='Mkdir("testdir")\n') + +os.symlink('testdir/symlinksrc', 'testdir/symlinkdst') + +expect = """\ +Mkdir("testdir") +Removed %s +Removed directory testdir +""" % os.path.join('testdir', 'symlinkdst') + +test.run(arguments = '-c -Q -q', stdout=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Climb/U-Default-dir.py b/test/Climb/U-Default-dir.py index 4c0eb6689f..f26fe75fcc 100644 --- a/test/Climb/U-Default-dir.py +++ b/test/Climb/U-Default-dir.py @@ -1,48 +1,48 @@ -#!/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 that a Default() directory doesn't cause an exception -when used with the -U option. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -Default('.') -""") - -test.run(arguments = '-U') - -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 that a Default() directory doesn't cause an exception +when used with the -U option. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +Default('.') +""") + +test.run(arguments = '-U') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Climb/U-Default-no-target.py b/test/Climb/U-Default-no-target.py index f580bffb23..331863e210 100644 --- a/test/Climb/U-Default-no-target.py +++ b/test/Climb/U-Default-no-target.py @@ -1,50 +1,50 @@ -#!/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 a Default() target that doesn't exist is handled with -the correct failure when used with the -U option. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -Default('not_a_target.in') -""") - -test.run(arguments = '-U', status=2, match=TestSCons.match_re, stderr=\ -r"""scons: \*\*\* Do not know how to make File target `not_a_target.in' \(.*not_a_target.in\). Stop. -""") - -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 a Default() target that doesn't exist is handled with +the correct failure when used with the -U option. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +Default('not_a_target.in') +""") + +test.run(arguments = '-U', status=2, match=TestSCons.match_re, stderr=\ +r"""scons: \*\*\* Do not know how to make File target `not_a_target.in' \(.*not_a_target.in\). Stop. +""") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Climb/U-no-Default.py b/test/Climb/U-no-Default.py index 9cd1ebf157..940414b934 100644 --- a/test/Climb/U-no-Default.py +++ b/test/Climb/U-no-Default.py @@ -1,47 +1,47 @@ -#!/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 no Default() targets in the SConstruct doesn't cause an -exception when used with the -U option. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', "\n") - -test.run(arguments = '-U', - stderr = "scons: *** No targets specified and no Default() targets found. Stop.\n", - status = 2) - -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 no Default() targets in the SConstruct doesn't cause an +exception when used with the -U option. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', "\n") + +test.run(arguments = '-U', + stderr = "scons: *** No targets specified and no Default() targets found. Stop.\n", + status = 2) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Climb/explicit-parent--D.py b/test/Climb/explicit-parent--D.py index 51686fe48f..c44dc38401 100644 --- a/test/Climb/explicit-parent--D.py +++ b/test/Climb/explicit-parent--D.py @@ -1,79 +1,79 @@ -#!/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 explicit targets beginning with ../ get built correctly -by the -D option. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir(['subdir']) - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -def cat(env, source, target): - target = str(target[0]) - with open(target, 'wb') as ofp: - for src in source: - with open(str(src), 'rb') as ifp: - ofp.write(ifp.read()) -env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) -env.Cat('f1.out', 'f1.in') -f2 = env.Cat('f2.out', 'f2.in') -Default(f2) -SConscript('subdir/SConscript', "env") -""") - -test.write('f1.in', "f1.in\n") -test.write('f2.in', "f2.in\n") - -test.write(['subdir', 'SConscript'], """\ -Import("env") -f3 = env.Cat('f3.out', 'f3.in') -env.Cat('f4.out', 'f4.in') -Default(f3) -""") - -test.write(['subdir', 'f3.in'], "subdir/f3.in\n") -test.write(['subdir', 'f4.in'], "subdir/f4.in\n") - -test.run(chdir = 'subdir', arguments = '-D ../f1.out') - -test.must_exist(test.workpath('f1.out')) -test.must_not_exist(test.workpath('f2.out')) -test.must_not_exist(test.workpath('dir', 'f3.out')) -test.must_not_exist(test.workpath('dir', 'f4.out')) - - -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 explicit targets beginning with ../ get built correctly +by the -D option. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir(['subdir']) + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +def cat(env, source, target): + target = str(target[0]) + with open(target, 'wb') as ofp: + for src in source: + with open(str(src), 'rb') as ifp: + ofp.write(ifp.read()) +env = Environment(tools=[], BUILDERS={'Cat':Builder(action=cat)}) +env.Cat('f1.out', 'f1.in') +f2 = env.Cat('f2.out', 'f2.in') +Default(f2) +SConscript('subdir/SConscript', "env") +""") + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") + +test.write(['subdir', 'SConscript'], """\ +Import("env") +f3 = env.Cat('f3.out', 'f3.in') +env.Cat('f4.out', 'f4.in') +Default(f3) +""") + +test.write(['subdir', 'f3.in'], "subdir/f3.in\n") +test.write(['subdir', 'f4.in'], "subdir/f4.in\n") + +test.run(chdir = 'subdir', arguments = '-D ../f1.out') + +test.must_exist(test.workpath('f1.out')) +test.must_not_exist(test.workpath('f2.out')) +test.must_not_exist(test.workpath('dir', 'f3.out')) +test.must_not_exist(test.workpath('dir', 'f4.out')) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Climb/explicit-parent--U.py b/test/Climb/explicit-parent--U.py index 973ce26cc1..a37d5a1608 100644 --- a/test/Climb/explicit-parent--U.py +++ b/test/Climb/explicit-parent--U.py @@ -1,72 +1,72 @@ -#!/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 explicit targets beginning with ../ get built correctly. -by the -U option. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('subdir') - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -def cat(env, source, target): - target = str(target[0]) - with open(target, 'wb') as ofp: - for src in source: - with open(str(src), 'rb') as ifp: - ofp.write(ifp.read()) -env = Environment(tools=[], - BUILDERS={'Cat':Builder(action=cat)}) -env.Cat('foo.out', 'foo.in') -SConscript('subdir/SConscript', "env") -""") - -test.write('foo.in', "foo.in\n") - -test.write(['subdir', 'SConscript'], """\ -Import("env") -bar = env.Cat('bar.out', 'bar.in') -Default(bar) -""") - -test.write(['subdir', 'bar.in'], "subdir/bar.in\n") - -test.run(chdir = 'subdir', arguments = '-U ../foo.out') - -test.must_exist(test.workpath('foo.out')) -test.must_not_exist(test.workpath('subdir', 'bar.out')) - -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 explicit targets beginning with ../ get built correctly. +by the -U option. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('subdir') + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +def cat(env, source, target): + target = str(target[0]) + with open(target, 'wb') as ofp: + for src in source: + with open(str(src), 'rb') as ifp: + ofp.write(ifp.read()) +env = Environment(tools=[], + BUILDERS={'Cat':Builder(action=cat)}) +env.Cat('foo.out', 'foo.in') +SConscript('subdir/SConscript', "env") +""") + +test.write('foo.in', "foo.in\n") + +test.write(['subdir', 'SConscript'], """\ +Import("env") +bar = env.Cat('bar.out', 'bar.in') +Default(bar) +""") + +test.write(['subdir', 'bar.in'], "subdir/bar.in\n") + +test.run(chdir = 'subdir', arguments = '-U ../foo.out') + +test.must_exist(test.workpath('foo.out')) +test.must_not_exist(test.workpath('subdir', 'bar.out')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Climb/explicit-parent-u.py b/test/Climb/explicit-parent-u.py index c42e9db2ab..c8c5da23e0 100644 --- a/test/Climb/explicit-parent-u.py +++ b/test/Climb/explicit-parent-u.py @@ -1,78 +1,78 @@ -#!/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 -u option only builds targets at or below -the current directory. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -# Make sure explicit targets beginning with ../ get built. -test.subdir('subdir') - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -def cat(env, source, target): - target = str(target[0]) - with open(target, 'wb') as ofp: - for src in source: - with open(str(src), 'rb') as ifp: - ofp.write(ifp.read()) -env = Environment(tools=[], - BUILDERS={'Cat':Builder(action=cat)}) -env.Cat('f1.out', 'f1.in') -env.Cat('f2.out', 'f2.in') -SConscript('subdir/SConscript', "env") -""") - -test.write('f1.in', "f1.in\n") -test.write('f2.in', "f2.in\n") - -test.write(['subdir', 'SConscript'], """\ -Import("env") -env.Cat('f3.out', 'f3.in') -env.Cat('f4.out', 'f4.in') -""") - -test.write(['subdir', 'f3.in'], "subdir/f3.in\n") -test.write(['subdir', 'f4.in'], "subdir/f4.in\n") - -test.run(chdir = 'subdir', arguments = '-u ../f2.out') - -test.must_not_exist(test.workpath('f1.out')) -test.must_exist(test.workpath('f2.out')) -test.must_not_exist(test.workpath('dir', 'f3.out')) -test.must_not_exist(test.workpath('dir', 'f4.out')) - -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 -u option only builds targets at or below +the current directory. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +# Make sure explicit targets beginning with ../ get built. +test.subdir('subdir') + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +def cat(env, source, target): + target = str(target[0]) + with open(target, 'wb') as ofp: + for src in source: + with open(str(src), 'rb') as ifp: + ofp.write(ifp.read()) +env = Environment(tools=[], + BUILDERS={'Cat':Builder(action=cat)}) +env.Cat('f1.out', 'f1.in') +env.Cat('f2.out', 'f2.in') +SConscript('subdir/SConscript', "env") +""") + +test.write('f1.in', "f1.in\n") +test.write('f2.in', "f2.in\n") + +test.write(['subdir', 'SConscript'], """\ +Import("env") +env.Cat('f3.out', 'f3.in') +env.Cat('f4.out', 'f4.in') +""") + +test.write(['subdir', 'f3.in'], "subdir/f3.in\n") +test.write(['subdir', 'f4.in'], "subdir/f4.in\n") + +test.run(chdir = 'subdir', arguments = '-u ../f2.out') + +test.must_not_exist(test.workpath('f1.out')) +test.must_exist(test.workpath('f2.out')) +test.must_not_exist(test.workpath('dir', 'f3.out')) +test.must_not_exist(test.workpath('dir', 'f4.out')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Climb/filename--D.py b/test/Climb/filename--D.py index c747a81871..38a337b204 100644 --- a/test/Climb/filename--D.py +++ b/test/Climb/filename--D.py @@ -1,79 +1,79 @@ -#!/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 the ability to use the -D option with the -f option to -specify a different top-level file name. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('subdir', 'other') - -test.write('main.scons', """\ -DefaultEnvironment(tools=[]) -print("main.scons") -SConscript('subdir/sub.scons') -""") - -test.write(['subdir', 'sub.scons'], """\ -print("subdir/sub.scons") -""") - - - -read_str = """\ -main.scons -subdir/sub.scons -""" - -expect = "scons: Entering directory `%s'\n" % test.workpath() \ - + test.wrap_stdout(read_str = read_str, - build_str = "scons: `subdir' is up to date.\n") - -test.run(chdir='subdir', arguments='-D -f main.scons .', stdout=expect) - - - -expect = test.wrap_stdout(read_str = "subdir/sub.scons\n", - build_str = "scons: `.' is up to date.\n") - -test.run(chdir='other', arguments='-D -f ../subdir/sub.scons .', stdout=expect) - -test.run(chdir='other', - arguments='-D -f %s .' % test.workpath('subdir', 'sub.scons'), - stdout=expect) - - - -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 the ability to use the -D option with the -f option to +specify a different top-level file name. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('subdir', 'other') + +test.write('main.scons', """\ +DefaultEnvironment(tools=[]) +print("main.scons") +SConscript('subdir/sub.scons') +""") + +test.write(['subdir', 'sub.scons'], """\ +print("subdir/sub.scons") +""") + + + +read_str = """\ +main.scons +subdir/sub.scons +""" + +expect = "scons: Entering directory `%s'\n" % test.workpath() \ + + test.wrap_stdout(read_str = read_str, + build_str = "scons: `subdir' is up to date.\n") + +test.run(chdir='subdir', arguments='-D -f main.scons .', stdout=expect) + + + +expect = test.wrap_stdout(read_str = "subdir/sub.scons\n", + build_str = "scons: `.' is up to date.\n") + +test.run(chdir='other', arguments='-D -f ../subdir/sub.scons .', stdout=expect) + +test.run(chdir='other', + arguments='-D -f %s .' % test.workpath('subdir', 'sub.scons'), + stdout=expect) + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Climb/filename--U.py b/test/Climb/filename--U.py index 5242add13e..f14593374a 100644 --- a/test/Climb/filename--U.py +++ b/test/Climb/filename--U.py @@ -1,77 +1,77 @@ -#!/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 the ability to use the -U option with the -f option to -specify a different top-level file name. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('subdir', 'other') - -test.write('main.scons', """\ -DefaultEnvironment(tools=[]) -print("main.scons") -SConscript('subdir/sub.scons') -""") - -test.write(['subdir', 'sub.scons'], """\ -print("subdir/sub.scons") -""") - -read_str = """\ -main.scons -subdir/sub.scons -""" - -expect = "scons: Entering directory `%s'\n" % test.workpath() \ - + test.wrap_stdout(read_str = read_str, - build_str = "scons: `subdir' is up to date.\n") - -test.run(chdir='subdir', arguments='-U -f main.scons .', stdout=expect) - - - -expect = test.wrap_stdout(read_str = "subdir/sub.scons\n", - build_str = "scons: `.' is up to date.\n") - -test.run(chdir='other', arguments='-U -f ../subdir/sub.scons .', stdout=expect) - -test.run(chdir='other', - arguments='-U -f %s .' % test.workpath('subdir', 'sub.scons'), - stdout=expect) - - - -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 the ability to use the -U option with the -f option to +specify a different top-level file name. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('subdir', 'other') + +test.write('main.scons', """\ +DefaultEnvironment(tools=[]) +print("main.scons") +SConscript('subdir/sub.scons') +""") + +test.write(['subdir', 'sub.scons'], """\ +print("subdir/sub.scons") +""") + +read_str = """\ +main.scons +subdir/sub.scons +""" + +expect = "scons: Entering directory `%s'\n" % test.workpath() \ + + test.wrap_stdout(read_str = read_str, + build_str = "scons: `subdir' is up to date.\n") + +test.run(chdir='subdir', arguments='-U -f main.scons .', stdout=expect) + + + +expect = test.wrap_stdout(read_str = "subdir/sub.scons\n", + build_str = "scons: `.' is up to date.\n") + +test.run(chdir='other', arguments='-U -f ../subdir/sub.scons .', stdout=expect) + +test.run(chdir='other', + arguments='-U -f %s .' % test.workpath('subdir', 'sub.scons'), + stdout=expect) + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Climb/filename-u.py b/test/Climb/filename-u.py index 844f2cda1f..4806c16c63 100644 --- a/test/Climb/filename-u.py +++ b/test/Climb/filename-u.py @@ -1,77 +1,77 @@ -#!/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 the ability to use the -u option with the -f option to -specify a different top-level file name. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('subdir', 'other') - -test.write('main.scons', """\ -DefaultEnvironment(tools=[]) -print("main.scons") -SConscript('subdir/sub.scons') -""") - -test.write(['subdir', 'sub.scons'], """\ -print("subdir/sub.scons") -""") - -read_str = """\ -main.scons -subdir/sub.scons -""" - -expect = "scons: Entering directory `%s'\n" % test.workpath() \ - + test.wrap_stdout(read_str = read_str, - build_str = "scons: `subdir' is up to date.\n") - -test.run(chdir='subdir', arguments='-u -f main.scons .', stdout=expect) - - - -expect = test.wrap_stdout(read_str = "subdir/sub.scons\n", - build_str = "scons: `.' is up to date.\n") - -test.run(chdir='other', arguments='-u -f ../subdir/sub.scons .', stdout=expect) - -test.run(chdir='other', - arguments='-u -f %s .' % test.workpath('subdir', 'sub.scons'), - stdout=expect) - - - -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 the ability to use the -u option with the -f option to +specify a different top-level file name. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('subdir', 'other') + +test.write('main.scons', """\ +DefaultEnvironment(tools=[]) +print("main.scons") +SConscript('subdir/sub.scons') +""") + +test.write(['subdir', 'sub.scons'], """\ +print("subdir/sub.scons") +""") + +read_str = """\ +main.scons +subdir/sub.scons +""" + +expect = "scons: Entering directory `%s'\n" % test.workpath() \ + + test.wrap_stdout(read_str = read_str, + build_str = "scons: `subdir' is up to date.\n") + +test.run(chdir='subdir', arguments='-u -f main.scons .', stdout=expect) + + + +expect = test.wrap_stdout(read_str = "subdir/sub.scons\n", + build_str = "scons: `.' is up to date.\n") + +test.run(chdir='other', arguments='-u -f ../subdir/sub.scons .', stdout=expect) + +test.run(chdir='other', + arguments='-u -f %s .' % test.workpath('subdir', 'sub.scons'), + stdout=expect) + + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Climb/option--D.py b/test/Climb/option--D.py index 5b66f6865c..169678aef5 100644 --- a/test/Climb/option--D.py +++ b/test/Climb/option--D.py @@ -1,89 +1,89 @@ -#!/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. - -import TestSCons - -_python_ = TestSCons._python_ - -test = TestSCons.TestSCons() - -test.subdir('sub1', 'sub2') - -test.write('build.py', r""" -import sys -with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp: - ofp.write(ifp.read()) -""") - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -import SCons.Defaults -B = Builder(action=r'%(_python_)s build.py $TARGET $SOURCES') -env = Environment(tools=[]) -env['BUILDERS']['B'] = B -env.B(target = 'sub1/foo.out', source = 'sub1/foo.in') -Export('env') -SConscript('sub1/SConscript') -SConscript('sub2/SConscript') -""" % locals()) - -test.write(['sub1', 'SConscript'], """ -Import('env') -env.B(target = 'foo.out', source = 'foo.in') -Default('.') -""") - -test.write(['sub1', 'foo.in'], "sub1/foo.in") - -test.write(['sub2', 'SConscript'], """ -Import('env') -env.Alias('bar', env.B(target = 'bar.out', source = 'bar.in')) -Default('.') - -""") - -test.write(['sub2', 'bar.in'], "sub2/bar.in") - -test.run(arguments = '-D', chdir = 'sub1') - -test.must_match(['sub1', 'foo.out'], "sub1/foo.in") -test.must_match(['sub2', 'bar.out'], "sub2/bar.in") - -test.unlink(['sub1', 'foo.out']) -test.unlink(['sub2', 'bar.out']) - -test.run(arguments = '-D bar', chdir = 'sub1') - -test.must_not_exist(test.workpath('sub1', 'foo.out')) -test.must_exist(test.workpath('sub2', 'bar.out')) - - -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. + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +test.subdir('sub1', 'sub2') + +test.write('build.py', r""" +import sys +with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp: + ofp.write(ifp.read()) +""") + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +import SCons.Defaults +B = Builder(action=r'%(_python_)s build.py $TARGET $SOURCES') +env = Environment(tools=[]) +env['BUILDERS']['B'] = B +env.B(target = 'sub1/foo.out', source = 'sub1/foo.in') +Export('env') +SConscript('sub1/SConscript') +SConscript('sub2/SConscript') +""" % locals()) + +test.write(['sub1', 'SConscript'], """ +Import('env') +env.B(target = 'foo.out', source = 'foo.in') +Default('.') +""") + +test.write(['sub1', 'foo.in'], "sub1/foo.in") + +test.write(['sub2', 'SConscript'], """ +Import('env') +env.Alias('bar', env.B(target = 'bar.out', source = 'bar.in')) +Default('.') + +""") + +test.write(['sub2', 'bar.in'], "sub2/bar.in") + +test.run(arguments = '-D', chdir = 'sub1') + +test.must_match(['sub1', 'foo.out'], "sub1/foo.in") +test.must_match(['sub2', 'bar.out'], "sub2/bar.in") + +test.unlink(['sub1', 'foo.out']) +test.unlink(['sub2', 'bar.out']) + +test.run(arguments = '-D bar', chdir = 'sub1') + +test.must_not_exist(test.workpath('sub1', 'foo.out')) +test.must_exist(test.workpath('sub2', 'bar.out')) + + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Climb/option--U.py b/test/Climb/option--U.py index 4bf5b3558e..8c34462b45 100644 --- a/test/Climb/option--U.py +++ b/test/Climb/option--U.py @@ -1,144 +1,144 @@ -#!/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. - -import sys - -import TestSCons - -test = TestSCons.TestSCons() - -_python_ = TestSCons._python_ - -test.subdir('sub1', 'sub2', 'sub3') - -test.write('build.py', r""" -import sys -with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp: - ofp.write(ifp.read()) -""") - -test.write('SConstruct', r""" -DefaultEnvironment(tools=[]) -import SCons.Defaults -env = Environment(tools=[]) -env['BUILDERS']['B'] = Builder(action=r'%(_python_)s build.py $TARGET $SOURCES', multi=1) -Default(env.B(target = 'sub1/foo.out', source = 'sub1/foo.in')) -Export('env') -SConscript('sub2/SConscript') -Default(env.B(target = 'sub3/baz.out', source = 'sub3/baz.in')) -VariantDir('sub2b', 'sub2') -SConscript('sub2b/SConscript') -Default(env.B(target = 'sub2/xxx.out', source = 'xxx.in')) -SConscript('SConscript') -""" % locals()) - -test.write(['sub2', 'SConscript'], """ -Import('env') -bar = env.B(target = 'bar.out', source = 'bar.in') -Default(bar) -env.Alias('bar', bar) -Default(env.B(target = '../bar.out', source = 'bar.in')) -""") - - -test.write(['sub1', 'foo.in'], "sub1/foo.in\n") -test.write(['sub2', 'bar.in'], "sub2/bar.in\n") -test.write(['sub3', 'baz.in'], "sub3/baz.in\n") -test.write('xxx.in', "xxx.in\n") - -test.write('SConscript', """assert GetLaunchDir() == r'%s'\n"""%test.workpath('sub1')) -test.run(arguments = '-U foo.out', chdir = 'sub1') - -test.must_exist(test.workpath('sub1', 'foo.out')) -test.must_not_exist(test.workpath('sub2', 'bar.out')) -test.must_not_exist(test.workpath('sub2b', 'bar.out')) -test.must_not_exist(test.workpath('sub3', 'baz.out')) -test.must_not_exist(test.workpath('bar.out')) -test.must_not_exist(test.workpath('sub2/xxx.out')) - -test.unlink(['sub1', 'foo.out']) - -test.write('SConscript', """\ -env = Environment(tools=[], ) -assert env.GetLaunchDir() == r'%s' -"""%test.workpath('sub1')) -test.run(arguments = '-U', - chdir = 'sub1', - stderr = "scons: *** No targets specified and no Default() targets found. Stop.\n", - status = 2) -test.must_not_exist(test.workpath('sub1', 'foo.out')) -test.must_not_exist(test.workpath('sub2', 'bar.out')) -test.must_not_exist(test.workpath('sub2b', 'bar.out')) -test.must_not_exist(test.workpath('sub3', 'baz.out')) -test.must_not_exist(test.workpath('bar.out')) -test.must_not_exist(test.workpath('sub2/xxx.out')) - - -if sys.platform == 'win32': - sub2 = 'SUB2' -else: - sub2 = 'sub2' -test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath(sub2)) -test.run(chdir = sub2, arguments = '-U') -test.must_not_exist(test.workpath('sub1', 'foo.out')) -test.must_exist(test.workpath('sub2', 'bar.out')) -test.must_exist(test.workpath('sub2b', 'bar.out')) -test.must_not_exist(test.workpath('sub3', 'baz.out')) -test.must_exist(test.workpath('bar.out')) -test.must_not_exist(test.workpath('sub2/xxx.out')) - -test.unlink(['sub2', 'bar.out']) -test.unlink(['sub2b', 'bar.out']) -test.unlink('bar.out') - -test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath()) -test.run(arguments='-U') -test.must_exist(test.workpath('sub1', 'foo.out')) -test.must_not_exist(test.workpath('sub2', 'bar.out')) -test.must_not_exist(test.workpath('sub2b', 'bar.out')) -test.must_exist(test.workpath('sub3', 'baz.out')) -test.must_not_exist(test.workpath('bar.out')) -test.must_exist(test.workpath('sub2/xxx.out')) - -test.unlink(['sub1', 'foo.out']) -test.unlink(['sub3', 'baz.out']) -test.unlink(['sub2', 'xxx.out']) - -test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath('sub3')) -test.run(chdir = 'sub3', arguments='-U bar') -test.must_not_exist(test.workpath('sub1', 'foo.out')) -test.must_exist(test.workpath('sub2', 'bar.out')) -test.must_exist(test.workpath('sub2b', 'bar.out')) -test.must_not_exist(test.workpath('sub3', 'baz.out')) -test.must_not_exist(test.workpath('bar.out')) -test.must_not_exist(test.workpath('sub2/xxx.out')) - -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. + +import sys + +import TestSCons + +test = TestSCons.TestSCons() + +_python_ = TestSCons._python_ + +test.subdir('sub1', 'sub2', 'sub3') + +test.write('build.py', r""" +import sys +with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp: + ofp.write(ifp.read()) +""") + +test.write('SConstruct', r""" +DefaultEnvironment(tools=[]) +import SCons.Defaults +env = Environment(tools=[]) +env['BUILDERS']['B'] = Builder(action=r'%(_python_)s build.py $TARGET $SOURCES', multi=1) +Default(env.B(target = 'sub1/foo.out', source = 'sub1/foo.in')) +Export('env') +SConscript('sub2/SConscript') +Default(env.B(target = 'sub3/baz.out', source = 'sub3/baz.in')) +VariantDir('sub2b', 'sub2') +SConscript('sub2b/SConscript') +Default(env.B(target = 'sub2/xxx.out', source = 'xxx.in')) +SConscript('SConscript') +""" % locals()) + +test.write(['sub2', 'SConscript'], """ +Import('env') +bar = env.B(target = 'bar.out', source = 'bar.in') +Default(bar) +env.Alias('bar', bar) +Default(env.B(target = '../bar.out', source = 'bar.in')) +""") + + +test.write(['sub1', 'foo.in'], "sub1/foo.in\n") +test.write(['sub2', 'bar.in'], "sub2/bar.in\n") +test.write(['sub3', 'baz.in'], "sub3/baz.in\n") +test.write('xxx.in', "xxx.in\n") + +test.write('SConscript', """assert GetLaunchDir() == r'%s'\n"""%test.workpath('sub1')) +test.run(arguments = '-U foo.out', chdir = 'sub1') + +test.must_exist(test.workpath('sub1', 'foo.out')) +test.must_not_exist(test.workpath('sub2', 'bar.out')) +test.must_not_exist(test.workpath('sub2b', 'bar.out')) +test.must_not_exist(test.workpath('sub3', 'baz.out')) +test.must_not_exist(test.workpath('bar.out')) +test.must_not_exist(test.workpath('sub2/xxx.out')) + +test.unlink(['sub1', 'foo.out']) + +test.write('SConscript', """\ +env = Environment(tools=[], ) +assert env.GetLaunchDir() == r'%s' +"""%test.workpath('sub1')) +test.run(arguments = '-U', + chdir = 'sub1', + stderr = "scons: *** No targets specified and no Default() targets found. Stop.\n", + status = 2) +test.must_not_exist(test.workpath('sub1', 'foo.out')) +test.must_not_exist(test.workpath('sub2', 'bar.out')) +test.must_not_exist(test.workpath('sub2b', 'bar.out')) +test.must_not_exist(test.workpath('sub3', 'baz.out')) +test.must_not_exist(test.workpath('bar.out')) +test.must_not_exist(test.workpath('sub2/xxx.out')) + + +if sys.platform == 'win32': + sub2 = 'SUB2' +else: + sub2 = 'sub2' +test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath(sub2)) +test.run(chdir = sub2, arguments = '-U') +test.must_not_exist(test.workpath('sub1', 'foo.out')) +test.must_exist(test.workpath('sub2', 'bar.out')) +test.must_exist(test.workpath('sub2b', 'bar.out')) +test.must_not_exist(test.workpath('sub3', 'baz.out')) +test.must_exist(test.workpath('bar.out')) +test.must_not_exist(test.workpath('sub2/xxx.out')) + +test.unlink(['sub2', 'bar.out']) +test.unlink(['sub2b', 'bar.out']) +test.unlink('bar.out') + +test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath()) +test.run(arguments='-U') +test.must_exist(test.workpath('sub1', 'foo.out')) +test.must_not_exist(test.workpath('sub2', 'bar.out')) +test.must_not_exist(test.workpath('sub2b', 'bar.out')) +test.must_exist(test.workpath('sub3', 'baz.out')) +test.must_not_exist(test.workpath('bar.out')) +test.must_exist(test.workpath('sub2/xxx.out')) + +test.unlink(['sub1', 'foo.out']) +test.unlink(['sub3', 'baz.out']) +test.unlink(['sub2', 'xxx.out']) + +test.write('SConscript', """assert GetLaunchDir() == r'%s'"""%test.workpath('sub3')) +test.run(chdir = 'sub3', arguments='-U bar') +test.must_not_exist(test.workpath('sub1', 'foo.out')) +test.must_exist(test.workpath('sub2', 'bar.out')) +test.must_exist(test.workpath('sub2b', 'bar.out')) +test.must_not_exist(test.workpath('sub3', 'baz.out')) +test.must_not_exist(test.workpath('bar.out')) +test.must_not_exist(test.workpath('sub2/xxx.out')) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Climb/option-u.py b/test/Climb/option-u.py index f7c1e9110e..b7298d2801 100644 --- a/test/Climb/option-u.py +++ b/test/Climb/option-u.py @@ -1,148 +1,148 @@ -#!/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 -u option only builds targets at or below -the current directory. -""" - -import os - -import TestSCons - -test = TestSCons.TestSCons() - -test.subdir('sub1', - 'sub2', ['sub2', 'dir'], - 'sub3', - 'sub4', ['sub4', 'dir']) - -test.write('SConstruct', """ -DefaultEnvironment(tools=[]) -def cat(env, source, target): - target = str(target[0]) - with open(target, 'wb') as ofp: - for src in source: - with open(str(src), 'rb') as ifp: - ofp.write(ifp.read()) -env = Environment(tools=[]) -env.Append(BUILDERS = {'Cat' : Builder(action=cat)}) -env.Cat(target = 'sub1/f1a.out', source = 'sub1/f1a.in') -env.Cat(target = 'sub1/f1b.out', source = 'sub1/f1b.in') -Export('env') -SConscript('sub2/SConscript') -f3 = env.Cat(target = 'sub3/f3.out', source = 'sub3/f3.in') -env.Alias('my_alias', f3) -VariantDir('build', 'sub4') -SConscript('build/SConscript') -""") - -test.write(['sub2', 'SConscript'], """ -Import('env') -env.Cat(target = 'f2a.out', source = 'f2a.in') -env.Cat(target = 'dir/f2b.out', source = 'dir/f2b.in') -""") - -test.write(['sub4', 'SConscript'], """ -Import('env') -env.Cat(target = 'f4a.out', source = 'f4a.in') -f4b_in = File('dir/f4b.in') -f4b_in.exists() -f4b_in.is_derived() -env.Cat(target = 'dir/f4b.out', source = f4b_in) -""") - -test.write(['sub1', 'f1a.in'], "sub1/f1a.in") -test.write(['sub1', 'f1b.in'], "sub1/f1b.in") -test.write(['sub2', 'f2a.in'], "sub2/f2a.in") -test.write(['sub2', 'dir', 'f2b.in'], "sub2/dir/f2b.in") -test.write(['sub3', 'f3.in'], "sub3/f3.in") -test.write(['sub4', 'f4a.in'], "sub4/f4a.in") -test.write(['sub4', 'dir', 'f4b.in'], "sub4/dir/f4b.in") - -# Verify that we only build the specified local argument. -test.run(chdir = 'sub1', arguments = '-u f1a.out') - -test.must_match(['sub1', 'f1a.out'], "sub1/f1a.in") -test.must_not_exist(test.workpath('sub1', 'sub1/f1b.out')) -test.must_not_exist(test.workpath('sub2', 'f2a.out')) -test.must_not_exist(test.workpath('sub2', 'dir', 'f2b.out')) -test.must_not_exist(test.workpath('sub3', 'f3.out')) -test.must_not_exist(test.workpath('sub4', 'f4a.out')) -test.must_not_exist(test.workpath('sub4', 'dir', 'f4b.out')) -test.must_not_exist(test.workpath('build', 'f4a.out')) -test.must_not_exist(test.workpath('build', 'dir', 'f4b.out')) - -# Verify that we build everything at or below our current directory. -test.run(chdir = 'sub2', arguments = '-u') - -test.must_not_exist(test.workpath('sub1', 'sub1/f1b.out')) -test.must_match(['sub2', 'f2a.out'], "sub2/f2a.in") -test.must_match(['sub2', 'dir', 'f2b.out'], "sub2/dir/f2b.in") -test.must_not_exist(test.workpath('sub3', 'f3.out')) -test.must_not_exist(test.workpath('sub4', 'f4a.out')) -test.must_not_exist(test.workpath('sub4', 'dir', 'f4b.out')) -test.must_not_exist(test.workpath('build', 'f4a.out')) -test.must_not_exist(test.workpath('build', 'dir', 'f4b.out')) - -# Verify that we build a specified alias, regardless of where. -test.run(chdir = 'sub2', arguments = '-u my_alias') - -test.must_not_exist(test.workpath('sub1', 'sub1/f1b.out')) -test.must_match(['sub3', 'f3.out'], "sub3/f3.in") -test.must_not_exist(test.workpath('sub4', 'f4a.out')) -test.must_not_exist(test.workpath('sub4', 'dir', 'f4b.out')) -test.must_not_exist(test.workpath('build', 'f4a.out')) -test.must_not_exist(test.workpath('build', 'dir', 'f4b.out')) - -# Verify that we build things in a linked VariantDir. -f4a_in = os.path.join('build', 'f4a.in') -f4a_out = os.path.join('build', 'f4a.out') -f4b_in = os.path.join('build', 'dir', 'f4b.in') -f4b_out = os.path.join('build', 'dir', 'f4b.out') -test.run(chdir = 'sub4', - arguments = '-u', - stdout = "scons: Entering directory `%s'\n" % test.workpath() + \ - test.wrap_stdout("""\ -scons: building associated VariantDir targets: build -cat(["%s"], ["%s"]) -cat(["%s"], ["%s"]) -scons: `sub4' is up to date. -""" % (f4b_out, f4b_in, f4a_out, f4a_in))) - -test.must_not_exist(test.workpath('sub1', 'sub1/f1b.out')) -test.must_not_exist(test.workpath('sub4', 'f4a.out')) -test.must_not_exist(test.workpath('sub4', 'dir', 'f4b.out')) -test.must_match(['build', 'f4a.out'], "sub4/f4a.in") -test.must_match(['build', 'dir', 'f4b.out'], "sub4/dir/f4b.in") - - -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 -u option only builds targets at or below +the current directory. +""" + +import os + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('sub1', + 'sub2', ['sub2', 'dir'], + 'sub3', + 'sub4', ['sub4', 'dir']) + +test.write('SConstruct', """ +DefaultEnvironment(tools=[]) +def cat(env, source, target): + target = str(target[0]) + with open(target, 'wb') as ofp: + for src in source: + with open(str(src), 'rb') as ifp: + ofp.write(ifp.read()) +env = Environment(tools=[]) +env.Append(BUILDERS = {'Cat' : Builder(action=cat)}) +env.Cat(target = 'sub1/f1a.out', source = 'sub1/f1a.in') +env.Cat(target = 'sub1/f1b.out', source = 'sub1/f1b.in') +Export('env') +SConscript('sub2/SConscript') +f3 = env.Cat(target = 'sub3/f3.out', source = 'sub3/f3.in') +env.Alias('my_alias', f3) +VariantDir('build', 'sub4') +SConscript('build/SConscript') +""") + +test.write(['sub2', 'SConscript'], """ +Import('env') +env.Cat(target = 'f2a.out', source = 'f2a.in') +env.Cat(target = 'dir/f2b.out', source = 'dir/f2b.in') +""") + +test.write(['sub4', 'SConscript'], """ +Import('env') +env.Cat(target = 'f4a.out', source = 'f4a.in') +f4b_in = File('dir/f4b.in') +f4b_in.exists() +f4b_in.is_derived() +env.Cat(target = 'dir/f4b.out', source = f4b_in) +""") + +test.write(['sub1', 'f1a.in'], "sub1/f1a.in") +test.write(['sub1', 'f1b.in'], "sub1/f1b.in") +test.write(['sub2', 'f2a.in'], "sub2/f2a.in") +test.write(['sub2', 'dir', 'f2b.in'], "sub2/dir/f2b.in") +test.write(['sub3', 'f3.in'], "sub3/f3.in") +test.write(['sub4', 'f4a.in'], "sub4/f4a.in") +test.write(['sub4', 'dir', 'f4b.in'], "sub4/dir/f4b.in") + +# Verify that we only build the specified local argument. +test.run(chdir = 'sub1', arguments = '-u f1a.out') + +test.must_match(['sub1', 'f1a.out'], "sub1/f1a.in") +test.must_not_exist(test.workpath('sub1', 'sub1/f1b.out')) +test.must_not_exist(test.workpath('sub2', 'f2a.out')) +test.must_not_exist(test.workpath('sub2', 'dir', 'f2b.out')) +test.must_not_exist(test.workpath('sub3', 'f3.out')) +test.must_not_exist(test.workpath('sub4', 'f4a.out')) +test.must_not_exist(test.workpath('sub4', 'dir', 'f4b.out')) +test.must_not_exist(test.workpath('build', 'f4a.out')) +test.must_not_exist(test.workpath('build', 'dir', 'f4b.out')) + +# Verify that we build everything at or below our current directory. +test.run(chdir = 'sub2', arguments = '-u') + +test.must_not_exist(test.workpath('sub1', 'sub1/f1b.out')) +test.must_match(['sub2', 'f2a.out'], "sub2/f2a.in") +test.must_match(['sub2', 'dir', 'f2b.out'], "sub2/dir/f2b.in") +test.must_not_exist(test.workpath('sub3', 'f3.out')) +test.must_not_exist(test.workpath('sub4', 'f4a.out')) +test.must_not_exist(test.workpath('sub4', 'dir', 'f4b.out')) +test.must_not_exist(test.workpath('build', 'f4a.out')) +test.must_not_exist(test.workpath('build', 'dir', 'f4b.out')) + +# Verify that we build a specified alias, regardless of where. +test.run(chdir = 'sub2', arguments = '-u my_alias') + +test.must_not_exist(test.workpath('sub1', 'sub1/f1b.out')) +test.must_match(['sub3', 'f3.out'], "sub3/f3.in") +test.must_not_exist(test.workpath('sub4', 'f4a.out')) +test.must_not_exist(test.workpath('sub4', 'dir', 'f4b.out')) +test.must_not_exist(test.workpath('build', 'f4a.out')) +test.must_not_exist(test.workpath('build', 'dir', 'f4b.out')) + +# Verify that we build things in a linked VariantDir. +f4a_in = os.path.join('build', 'f4a.in') +f4a_out = os.path.join('build', 'f4a.out') +f4b_in = os.path.join('build', 'dir', 'f4b.in') +f4b_out = os.path.join('build', 'dir', 'f4b.out') +test.run(chdir = 'sub4', + arguments = '-u', + stdout = "scons: Entering directory `%s'\n" % test.workpath() + \ + test.wrap_stdout("""\ +scons: building associated VariantDir targets: build +cat(["%s"], ["%s"]) +cat(["%s"], ["%s"]) +scons: `sub4' is up to date. +""" % (f4b_out, f4b_in, f4a_out, f4a_in))) + +test.must_not_exist(test.workpath('sub1', 'sub1/f1b.out')) +test.must_not_exist(test.workpath('sub4', 'f4a.out')) +test.must_not_exist(test.workpath('sub4', 'dir', 'f4b.out')) +test.must_match(['build', 'f4a.out'], "sub4/f4a.in") +test.must_match(['build', 'dir', 'f4b.out'], "sub4/dir/f4b.in") + + +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/Action-error.py b/test/Configure/Action-error.py index 69ba7f7045..5021e1cc49 100644 --- a/test/Configure/Action-error.py +++ b/test/Configure/Action-error.py @@ -1,55 +1,55 @@ -#!/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 Configure from an Action results in a readable error. -""" - -import TestSCons - -test = TestSCons.TestSCons() - -test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) -def ConfigureAction(target, source, env): - env.Configure() - return 0 -env = Environment(tools=[], - BUILDERS = {'MyAction' : - Builder(action=Action(ConfigureAction))}) -env.MyAction('target', []) -""") - -expect = "scons: *** [target] Calling Configure from Builders is not supported.\n" - -test.run(status=2, stderr=expect) - -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 Configure from an Action results in a readable error. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.write('SConstruct', """\ +DefaultEnvironment(tools=[]) +def ConfigureAction(target, source, env): + env.Configure() + return 0 +env = Environment(tools=[], + BUILDERS = {'MyAction' : + Builder(action=Action(ConfigureAction))}) +env.MyAction('target', []) +""") + +expect = "scons: *** [target] Calling Configure from Builders is not supported.\n" + +test.run(status=2, stderr=expect) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Configure/Builder-call.py b/test/Configure/Builder-call.py index 3427fafde0..bbe3366f06 100644 --- a/test/Configure/Builder-call.py +++ b/test/Configure/Builder-call.py @@ -1,64 +1,64 @@ -#!/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: +#!/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 61d0b56e7e..4777b823fc 100644 --- a/test/Configure/CONFIGUREDIR.py +++ b/test/Configure/CONFIGUREDIR.py @@ -1,57 +1,57 @@ -#!/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: +#!/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 e10a0aa2fa..7ced290473 100644 --- a/test/Configure/CONFIGURELOG.py +++ b/test/Configure/CONFIGURELOG.py @@ -1,68 +1,68 @@ -#!/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: +#!/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 4bca8c134d..8378f85560 100644 --- a/test/Configure/SConscript.py +++ b/test/Configure/SConscript.py @@ -1,80 +1,80 @@ -#!/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: +#!/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 2b29c40adc..c2312be91b 100644 --- a/test/Configure/Streamer1.py +++ b/test/Configure/Streamer1.py @@ -1,85 +1,85 @@ -#!/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: +#!/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.py b/test/Configure/VariantDir.py index 0296d1c7f1..a883d48d32 100644 --- a/test/Configure/VariantDir.py +++ b/test/Configure/VariantDir.py @@ -1,99 +1,99 @@ -#!/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: +#!/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/basic.py b/test/Configure/basic.py index d2f7111d8e..9d555659f5 100644 --- a/test/Configure/basic.py +++ b/test/Configure/basic.py @@ -1,91 +1,91 @@ -#!/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 basic builds work with Configure contexts. -""" - -from TestSCons import TestSCons, ConfigCheckInfo, _obj -from TestCmd import IS_WINDOWS - - -test = 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() -import os -env.AppendENVPath('PATH', os.environ['PATH']) -# Throw in a bad variable name intentionally used by Ubuntu packaging. -env['ENV']['HASH(0x12345678)'] = 'Bad variable name!' -conf = Configure(env) -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" ); -} -""") - -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))]], - "config.log", ".sconf_temp", "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))]], - "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 basic builds work with Configure contexts. +""" + +from TestSCons import TestSCons, ConfigCheckInfo, _obj +from TestCmd import IS_WINDOWS + + +test = 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() +import os +env.AppendENVPath('PATH', os.environ['PATH']) +# Throw in a bad variable name intentionally used by Ubuntu packaging. +env['ENV']['HASH(0x12345678)'] = 'Bad variable name!' +conf = Configure(env) +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" ); +} +""") + +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))]], + "config.log", ".sconf_temp", "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))]], + "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/build-fail.py b/test/Configure/build-fail.py index b835cb7418..21d4b5e079 100644 --- a/test/Configure/build-fail.py +++ b/test/Configure/build-fail.py @@ -1,97 +1,97 @@ -#!/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: +#!/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 0944996441..04a348658d 100644 --- a/test/Configure/cache-not-ok.py +++ b/test/Configure/cache-not-ok.py @@ -1,102 +1,102 @@ -#!/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: +#!/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 dc2d0c32b9..a2ef8fa216 100644 --- a/test/Configure/cache-ok.py +++ b/test/Configure/cache-ok.py @@ -1,126 +1,126 @@ -#!/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: +#!/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 3370cd251c..19e4879a2a 100644 --- a/test/Configure/clean.py +++ b/test/Configure/clean.py @@ -1,84 +1,84 @@ -#!/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: +#!/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/custom-tests.py b/test/Configure/custom-tests.py index a4c29c78e1..3f5bcb6db3 100644 --- a/test/Configure/custom-tests.py +++ b/test/Configure/custom-tests.py @@ -1,202 +1,202 @@ -#!/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: +#!/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 5d16592be4..17d975b0e7 100644 --- a/test/Configure/from-SConscripts.py +++ b/test/Configure/from-SConscripts.py @@ -1,63 +1,63 @@ -#!/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: +#!/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 abe446d13c..b7184eea93 100644 --- a/test/Configure/help.py +++ b/test/Configure/help.py @@ -1,94 +1,94 @@ -#!/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: +#!/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/option--Q.py b/test/Configure/option--Q.py index 4602a50f68..8316ab0268 100644 --- a/test/Configure/option--Q.py +++ b/test/Configure/option--Q.py @@ -1,52 +1,52 @@ -#!/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: +#!/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: From 09c4a1250f0c73a1c04a8e78d129bfac80692357 Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Thu, 30 May 2024 16:57:28 -0500 Subject: [PATCH 3/3] eol commit to `.git-blame-ignore-revs` --- .git-blame-ignore-revs | 2 ++ CHANGES.txt | 1 + RELEASE.txt | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 538cb23c92..a798490c6e 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,2 +1,4 @@ # files reformatted from DOS line-endings 1277d8e5ab6457ed18d291100539f31d1bdb2d7c +# enforced .editorconfig eol settings +fbb026ef1145fe29e0ec3c1b66a3e99cac51e18d diff --git a/CHANGES.txt b/CHANGES.txt index e5e6f5de25..4dff9dad4b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -13,6 +13,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - GetSConsVersion() to grab the latest SCons version without needing to access SCons internals. - Migrate setup.cfg logic to pyproject.toml; remove setup.cfg. + - Update .gitattributes to match .editorconfig; enforce eol settings. From Raymond Li: - Fix issue #3935: OSErrors are now no longer hidden during execution of diff --git a/RELEASE.txt b/RELEASE.txt index a8d121ef36..fd269d65b1 100644 --- a/RELEASE.txt +++ b/RELEASE.txt @@ -88,6 +88,10 @@ DEVELOPMENT by adding SKIP_PDF=1. This should help with distro packaging of SCons, which now does not need "fop" and other tools to be set up in order to build pdf versions which are then ignored. +- .gitattributes has been setup to mirror .editorconfig's eol settings. + The repo-wide line-ending is now `lf`, with the exception of a few + Windows-only files using `crlf` instead. Any files not already fitting + this format have been explicitly converted. Thanks to the following contributors listed below for their contributions to this release.