From 9fc18579b415b39cfb69e8af80551f9a5f83d2f0 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Tue, 25 Jun 2024 08:08:56 -0600 Subject: [PATCH 1/2] Some minor test tweaking Don't """code block""" % locals() if there's not actually a substitution in the code block. While there, fix any old-style file headers, and add a DefaultEnvironment call if not present. Signed-off-by: Mats Wichmann --- bin/scons-time.py | 1 + test/CacheDir/value_dependencies/SConstruct | 4 +- test/Configure/custom-tests.py | 4 +- test/Errors/preparation.py | 10 ++--- test/GetBuildFailures/option-k.py | 11 +++-- test/Java/JARCHDIR.py | 3 +- test/Java/JARFLAGS.py | 4 +- test/Java/JAVACFLAGS.py | 2 +- test/Java/JAVACLASSPATH.py | 2 +- test/Java/JAVAH.py | 5 +-- test/Java/multi-step.py | 5 ++- test/Java/no-JARCHDIR.py | 7 +-- test/Java/swig-dependencies.py | 15 ++++--- test/LEX/no_lex.py | 2 +- test/MSVC/MSVC_USE_SCRIPT.py | 3 +- test/MSVC/MSVC_USE_SETTINGS.py | 7 +-- test/MSVC/PCH-source.py | 2 +- test/MSVC/TARGET_ARCH.py | 8 ++-- test/MSVC/batch-longlines.py | 2 +- test/MinGW/MinGWSharedLibrary.py | 2 +- test/MinGW/WINDOWS_INSERT_DEF.py | 2 +- test/Removed/Old/warn-missing-sconscript.py | 2 +- test/TEX/LATEX2.py | 4 +- test/TEX/LATEXCOMSTR.py | 12 ++--- test/TEX/PDFLATEXCOMSTR.py | 12 ++--- test/TEX/PDFTEXCOMSTR.py | 12 ++--- test/TEX/TEXCOMSTR.py | 22 ++++----- test/TEX/configure.py | 15 ++++--- test/TEX/dryrun.py | 13 +++--- test/TEX/rename_result.py | 11 ++--- test/TEX/usepackage.py | 11 ++--- test/Variables/import.py | 4 +- test/YACC/live-check-output-cleaned.py | 2 +- test/ZIP/ZIP.py | 3 +- test/ZIP/ZIPROOT.py | 3 +- test/ZIP/ZIP_OVERRIDE_TIMESTAMP.py | 5 ++- test/gettext/POTUpdate/UserExamples.py | 19 +++++--- test/implicit-cache/DualTargets.py | 15 +++---- test/no-global-dependencies.py | 37 ++++++++-------- test/sconsign/script/SConsignFile.py | 49 +++++++++++---------- testing/framework/TestCommonTests.py | 12 +++-- testing/framework/TestSCons.py | 4 +- 42 files changed, 196 insertions(+), 172 deletions(-) diff --git a/bin/scons-time.py b/bin/scons-time.py index c8121fb6f2..f8858f772f 100644 --- a/bin/scons-time.py +++ b/bin/scons-time.py @@ -278,6 +278,7 @@ class SConsTimer: name = 'scons-time' name_spaces = ' ' * len(name) + @staticmethod def makedict(**kw): return kw diff --git a/test/CacheDir/value_dependencies/SConstruct b/test/CacheDir/value_dependencies/SConstruct index 9e971c64d3..3923228bf1 100644 --- a/test/CacheDir/value_dependencies/SConstruct +++ b/test/CacheDir/value_dependencies/SConstruct @@ -7,8 +7,8 @@ import SCons.Node CacheDir('cache') def b(target, source, env): - with open(target[0].abspath, 'w') as f: - pass + with open(target[0].abspath, 'w') as f: + pass def scan(node, env, path): """Have the node depend on a directory, which depends on a Value node.""" diff --git a/test/Configure/custom-tests.py b/test/Configure/custom-tests.py index 3f5bcb6db3..9a6d0f61ab 100644 --- a/test/Configure/custom-tests.py +++ b/test/Configure/custom-tests.py @@ -55,7 +55,7 @@ """) test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) +DefaultEnvironment(tools=[]) def CheckCustom(test): test.Message( 'Executing MyTest ... ' ) retCompileOK = test.TryCompile( '%(compileOK)s', '.c' ) @@ -164,7 +164,7 @@ def CheckEmptyDict(test): conf.CheckDict() conf.CheckEmptyDict() env = conf.Finish() -""" % locals()) +""") test.run() diff --git a/test/Errors/preparation.py b/test/Errors/preparation.py index 914827a713..51ca2de9b2 100644 --- a/test/Errors/preparation.py +++ b/test/Errors/preparation.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,9 +22,6 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 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__" """ A currently disabled test that used to verify that we print a useful @@ -49,6 +48,7 @@ test.subdir('install', 'work') test.write(['work', 'SConstruct'], """\ +_ = DefaultEnvironment(tools=[]) file_out = Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE')) Alias("install", file_out) @@ -56,7 +56,7 @@ # IOError or OSError when we try to open it to read its signature. import os os.mkdir('file.in') -""" % locals()) +""") if sys.platform == 'win32': error_message = "Permission denied" diff --git a/test/GetBuildFailures/option-k.py b/test/GetBuildFailures/option-k.py index 039ad50a91..50ad302980 100644 --- a/test/GetBuildFailures/option-k.py +++ b/test/GetBuildFailures/option-k.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,14 +22,11 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 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 failed build action with -k works as expected. """ -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - import TestSCons _python_ = TestSCons._python_ @@ -85,7 +84,7 @@ def print_build_failures(): scons: done building targets (errors occurred during build). f4 failed: Error 1 f5 failed: Error 1 -""" % locals() +""" expect_stderr = """\ scons: *** [f4] Error 1 @@ -99,7 +98,7 @@ def print_build_failures(): test.must_match(test.workpath('f3'), 'f3.in\n') test.must_not_exist(test.workpath('f4')) test.must_not_exist(test.workpath('f5')) -test.must_match(test.workpath('f6'), 'f6.in\n') +test.must_match(test.workpath('f6'), 'f6.in\n') test.pass_test() diff --git a/test/Java/JARCHDIR.py b/test/Java/JARCHDIR.py index c24717231d..c84509bd5d 100644 --- a/test/Java/JARCHDIR.py +++ b/test/Java/JARCHDIR.py @@ -32,7 +32,6 @@ ${TARGET} or ${SOURCE} work. """ - import TestSCons test = TestSCons.TestSCons() @@ -60,7 +59,7 @@ source_env.Jar('out/s.jar', 'in/s.class') Default(bin, jar, inner) -""" % locals()) +""") test.subdir('in') diff --git a/test/Java/JARFLAGS.py b/test/Java/JARFLAGS.py index 36af5929ec..957464d98d 100644 --- a/test/Java/JARFLAGS.py +++ b/test/Java/JARFLAGS.py @@ -39,7 +39,7 @@ env['JARFLAGS'] = 'cvf' class_files = env.Java(target='classes', source='src') env.Jar(target='test.jar', source=class_files) -""" % locals()) +""") test.write(['src', 'Example1.java'], """\ package src; @@ -60,7 +60,7 @@ jar cvf test.jar -C classes src.Example1\\.class .* adding: src.Example1\\.class.* -""" % locals()) +""") test.run(arguments = '.', diff --git a/test/Java/JAVACFLAGS.py b/test/Java/JAVACFLAGS.py index 3a555a3a1a..51bf3f68dd 100644 --- a/test/Java/JAVACFLAGS.py +++ b/test/Java/JAVACFLAGS.py @@ -37,7 +37,7 @@ DefaultEnvironment(tools=[]) env = Environment(tools=['javac'], JAVACFLAGS='-O') env.Java(target='classes', source='src') -""" % locals()) +""") test.write(['src', 'Example1.java'], """\ package src; diff --git a/test/Java/JAVACLASSPATH.py b/test/Java/JAVACLASSPATH.py index 38f01cc03b..48034dd096 100644 --- a/test/Java/JAVACLASSPATH.py +++ b/test/Java/JAVACLASSPATH.py @@ -59,7 +59,7 @@ j1 = env.Java(target='class1', source='com.1/Example1.java') j2 = env.Java(target='class2', source='com.2/Example2.java') env.JavaH(target='outdir', source=[j1, j2], JAVACLASSPATH='class2') -""" % locals()) +""") test.subdir('com.1', 'com.2') diff --git a/test/Java/JAVAH.py b/test/Java/JAVAH.py index 27e98216f2..1ad3933c05 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.py @@ -39,7 +39,7 @@ # Skip this test as SCons doesn't (currently) predict the generated # inner/anonymous class generated .class files generated by gcj -# and so will always fail +# and so will always fail if test.javac_is_gcj: test.skip_test('Test not valid for gcj (gnu java); skipping test(s).\n') @@ -242,8 +242,7 @@ class Private { test.must_match( 'wrapper.out', - "wrapper_with_args.py javah -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n" - % locals(), + "wrapper_with_args.py javah -d outdir2 -classpath class2 com.sub.bar.Example4 com.other.Example5 com.sub.bar.Example6\n", mode='r', ) diff --git a/test/Java/multi-step.py b/test/Java/multi-step.py index ab627cb46f..05ef90d40e 100644 --- a/test/Java/multi-step.py +++ b/test/Java/multi-step.py @@ -49,7 +49,7 @@ # Skip this test as SCons doesn't (currently) predict the generated # inner/anonymous class generated .class files generated by gcj -# and so will always fail +# and so will always fail if test.javac_is_gcj: test.skip_test('Test not valid for gcj (gnu java); skipping test(s).\n') @@ -96,6 +96,7 @@ else: tools = ['default', 'javac', 'javah', 'swig'] +_ = DefaultEnvironment(tools=[]) env = Environment(tools=tools, CPPPATH=["$JAVAINCLUDES"]) Export('env') # env.PrependENVPath('PATH',os.environ.get('PATH',[])) @@ -125,7 +126,7 @@ 'buildout/javah/SConscript', ] ) -""" % locals()) +""") test.write(['src', 'HelloApplet', 'Hello.html'], """\ diff --git a/test/Java/no-JARCHDIR.py b/test/Java/no-JARCHDIR.py index d3392518c8..0798b090ad 100644 --- a/test/Java/no-JARCHDIR.py +++ b/test/Java/no-JARCHDIR.py @@ -51,10 +51,11 @@ """) test.write('SConstruct', """\ -env = Environment(tools = ['javac', 'jar']) +_ = DefaultEnvironment(tools=[]) +env = Environment(tools=['javac', 'jar']) jar = env.Jar('x.jar', env.Java(target = 'classes', source = 'src')) -""" % locals()) +""") test.run(arguments = '.') test.run(program = where_jar, arguments = 'tf x.jar') @@ -73,7 +74,7 @@ JARCHDIR = None) jar = env.Jar('x.jar', env.Java(target = 'classes', source = 'src')) -""" % locals()) +""") test.run(arguments = '.') diff --git a/test/Java/swig-dependencies.py b/test/Java/swig-dependencies.py index 48010ad8f0..3fa563dd44 100644 --- a/test/Java/swig-dependencies.py +++ b/test/Java/swig-dependencies.py @@ -47,6 +47,7 @@ test.write(['SConstruct'], """\ import os +_ = DefaultEnvironment(tools=[]) env = Environment(ENV=os.environ) if env['PLATFORM'] != 'win32': env.Append(CPPFLAGS=' -g -Wall') @@ -56,7 +57,7 @@ SConscript('#foo/SConscript') SConscript('#java/SConscript') -""" % locals()) +""") test.write(['foo', 'SConscript'], """\ Import('env') @@ -68,7 +69,7 @@ #include "foo.h" int fooAdd(int a, int b) { - return a + b; + return a + b; } """) @@ -115,11 +116,11 @@ swigflags = '-c++ -java -Wall -Ifoo -DTEST_$PLATFORM' Java_foo_interface = env.SharedLibrary( - 'Java_foo_interface', - 'Java_foo_interface.i', - LIBS = libadd, - LIBPATH = libpath, - SWIGFLAGS = swigflags, + 'Java_foo_interface', + 'Java_foo_interface.i', + LIBS = libadd, + LIBPATH = libpath, + SWIGFLAGS = swigflags, SWIGOUTDIR = Dir('build'), SWIGCXXFILESUFFIX = "_wrap.cpp") diff --git a/test/LEX/no_lex.py b/test/LEX/no_lex.py index e53b02e8e9..969dd3840f 100644 --- a/test/LEX/no_lex.py +++ b/test/LEX/no_lex.py @@ -46,7 +46,7 @@ def Detect(self, progs): DefaultEnvironment(tools=[]) foo = TestEnvironment(tools=['default', 'lex']) print(foo.Dictionary('LEX')) -""" % locals()) +""") test.run(arguments='-Q -s', stdout='None\n') diff --git a/test/MSVC/MSVC_USE_SCRIPT.py b/test/MSVC/MSVC_USE_SCRIPT.py index 67eddfc1e9..d6c683ffe5 100644 --- a/test/MSVC/MSVC_USE_SCRIPT.py +++ b/test/MSVC/MSVC_USE_SCRIPT.py @@ -35,8 +35,9 @@ test.skip_if_not_msvc() test.write('SConstruct', """ +_ = DefaultEnvironment(tools=[]) env = Environment(tools=['msvc'], MSVC_USE_SCRIPT='nosuchscriptexists') -""" % locals()) +""") test.run(arguments = ".", status=2, stderr=None) test.must_contain_all(test.stderr(), "Script specified by MSVC_USE_SCRIPT not found") diff --git a/test/MSVC/MSVC_USE_SETTINGS.py b/test/MSVC/MSVC_USE_SETTINGS.py index fd6f85ceb5..a473862fa3 100644 --- a/test/MSVC/MSVC_USE_SETTINGS.py +++ b/test/MSVC/MSVC_USE_SETTINGS.py @@ -35,6 +35,7 @@ test.skip_if_not_msvc() test.write('SConstruct', """ +_ = DefaultEnvironment(tools=[]) e1 = Environment() cl1 = e1.WhereIs('cl.exe') @@ -46,21 +47,21 @@ if cl1 == cl3: print("CL.EXE PATHS MATCH") -""" % locals()) +""") test.run(arguments=".", status=0, stderr=None) test.must_contain_all(test.stdout(), "CL.EXE PATHS MATCH") test.write('SConstruct', """ env = Environment(MSVC_USE_SETTINGS={}) -""" % locals()) +""") test.run(arguments="--warn=visual-c-missing .", status=0, stderr=None) test.must_contain_all(test.stderr(), "Could not find requested MSVC compiler 'cl'") test.write('SConstruct', """ env = Environment(MSVC_USE_SETTINGS='dict or None') -""" % locals()) +""") test.run(arguments=".", status=2, stderr=None) test.must_contain_all(test.stderr(), "MSVCUseSettingsError: MSVC_USE_SETTINGS type error") diff --git a/test/MSVC/PCH-source.py b/test/MSVC/PCH-source.py index 84a39bd78b..99683171b7 100644 --- a/test/MSVC/PCH-source.py +++ b/test/MSVC/PCH-source.py @@ -41,7 +41,7 @@ env['PCH'] = env.PCH('Source1.cpp')[0] env['PCHSTOP'] = 'Header1.hpp' env.Program('foo', ['foo.cpp', 'Source2.cpp', 'Source1.cpp']) -""" % locals()) +""") test.write('Header1.hpp', r""" """) diff --git a/test/MSVC/TARGET_ARCH.py b/test/MSVC/TARGET_ARCH.py index d8a2f933e7..f093a425d8 100644 --- a/test/MSVC/TARGET_ARCH.py +++ b/test/MSVC/TARGET_ARCH.py @@ -38,7 +38,7 @@ DefaultEnvironment(tools=[]) env_64 = Environment(tools=['default', 'msvc'], TARGET_ARCH='amd64') env_32 = Environment(tools=['default', 'msvc'], TARGET_ARCH='x86') -""" % locals()) +""") test.run(arguments=".") @@ -47,7 +47,7 @@ test.write('SConstruct', """ DefaultEnvironment(tools=[]) env_xx = Environment(tools=['default', 'msvc'], TARGET_ARCH='nosucharch') -""" % locals()) +""") test.run(arguments=".", status=2, stderr=None) test.must_contain_any_line(test.stderr(), "Unrecognized target architecture") @@ -58,7 +58,7 @@ env = Environment(tools=['default', 'msvc'], TARGET_ARCH='arm', MSVC_VERSION='11.0') if env.Detect('cl'): env.Command('checkarm', [], 'cl') -""" % locals()) +""") test.run(arguments=".", stderr=None) if test.stderr().strip() != "" and "ARM" not in test.stderr(): test.fail_test() @@ -68,7 +68,7 @@ env = Environment(tools=['default', 'msvc'], TARGET_ARCH='arm64', MSVC_VERSION='11.0') if env.Detect('cl'): env.Command('checkarm64', [], 'cl') -""" % locals()) +""") test.run(arguments=".", stderr=None) if test.stderr().strip() != "" and "ARM64" not in test.stderr(): test.fail_test() diff --git a/test/MSVC/batch-longlines.py b/test/MSVC/batch-longlines.py index addf001806..0e78fd5ae6 100644 --- a/test/MSVC/batch-longlines.py +++ b/test/MSVC/batch-longlines.py @@ -45,7 +45,7 @@ env = Environment(tools=['msvc', 'mslink'], MSVC_BATCH=ARGUMENTS.get('MSVC_BATCH')) env.SharedLibrary('mylib', Glob('source*.cxx')) -""" % locals()) +""") test.run(arguments='MSVC_BATCH=1 .') test.must_exist('mylib.dll') diff --git a/test/MinGW/MinGWSharedLibrary.py b/test/MinGW/MinGWSharedLibrary.py index 9fac820d9e..9dbac50576 100644 --- a/test/MinGW/MinGWSharedLibrary.py +++ b/test/MinGW/MinGWSharedLibrary.py @@ -63,7 +63,7 @@ # Now verify versioned shared library doesn't fail env.SharedLibrary('foobar_ver', foobar_obj, SHLIBVERSION='2.4') -""" % locals()) +""") test.run(arguments = ".") diff --git a/test/MinGW/WINDOWS_INSERT_DEF.py b/test/MinGW/WINDOWS_INSERT_DEF.py index 5119c97518..27e075f393 100644 --- a/test/MinGW/WINDOWS_INSERT_DEF.py +++ b/test/MinGW/WINDOWS_INSERT_DEF.py @@ -55,7 +55,7 @@ DefaultEnvironment(tools=[]) env = Environment(TOOLS=['mingw']) hello_dll = env.SharedLibrary(WINDOWS_INSERT_DEF=0, target='hello', source='hello.c') -""" % locals()) +""") test.run(arguments = ".") diff --git a/test/Removed/Old/warn-missing-sconscript.py b/test/Removed/Old/warn-missing-sconscript.py index 7859b6423e..2c733aae7d 100644 --- a/test/Removed/Old/warn-missing-sconscript.py +++ b/test/Removed/Old/warn-missing-sconscript.py @@ -59,7 +59,7 @@ def build(target, source, env): # this is the old message: #expect = r""" #scons: warning: Ignoring missing SConscript 'no_such_file' -"" + TestSCons.file_expr +#"""" + TestSCons.file_expr test.run(arguments='--warn=missing-sconscript .', stderr=expect) test.run(arguments='--warn=no-missing-sconscript .', stderr="") diff --git a/test/TEX/LATEX2.py b/test/TEX/LATEX2.py index 6dc5050d93..a7215e906b 100644 --- a/test/TEX/LATEX2.py +++ b/test/TEX/LATEX2.py @@ -47,10 +47,12 @@ test.write('SConstruct', """ import os + +_ = DefaultEnvironment(tools=[]) foo = Environment() foo['TEXINPUTS'] = ['subdir',os.environ.get('TEXINPUTS', '')] foo.PDF(source = ['foo.ltx','bar.latex','makeindex.tex','latexi.tex']) -""" % locals()) +""") latex = r""" \documentclass{letter} diff --git a/test/TEX/LATEXCOMSTR.py b/test/TEX/LATEXCOMSTR.py index 41c5dc72c6..de63ebfa33 100644 --- a/test/TEX/LATEXCOMSTR.py +++ b/test/TEX/LATEXCOMSTR.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,11 +22,8 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 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__" - -r""" +""" Test that the $LATEXCOMSTR construction variable allows you to configure the C compilation output. """ @@ -38,6 +37,7 @@ test.file_fixture('mycompile.py') test.write('SConstruct', """ +_ = DefaultEnvironment(tools=[]) env = Environment(TOOLS = ['latex'], LATEXCOM = r'%(_python_)s mycompile.py latex $TARGET $SOURCE', LATEXCOMSTR = 'Building $TARGET from $SOURCE') @@ -51,7 +51,7 @@ test.run(stdout = test.wrap_stdout("""\ Building test1.dvi from test1.latex -""" % locals())) +""")) test.must_match('test1.dvi', "test1.latex\n") diff --git a/test/TEX/PDFLATEXCOMSTR.py b/test/TEX/PDFLATEXCOMSTR.py index d695bdec10..f0e9467d5b 100644 --- a/test/TEX/PDFLATEXCOMSTR.py +++ b/test/TEX/PDFLATEXCOMSTR.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,11 +22,8 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 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__" - -r""" +""" Test that the $PDFLATEXCOMSTR construction variable allows you to configure the C compilation output. """ @@ -38,6 +37,7 @@ test.file_fixture('mycompile.py') test.write('SConstruct', """ +_ = DefaultEnvironment(tools=[]) env = Environment(TOOLS = ['pdflatex'], PDFLATEXCOM = r'%(_python_)s mycompile.py latex $TARGET $SOURCE', PDFLATEXCOMSTR = 'Building $TARGET from $SOURCE') @@ -51,7 +51,7 @@ test.run(stdout = test.wrap_stdout("""\ Building test1.pdf from test1.latex -""" % locals())) +""")) test.must_match('test1.pdf', "test1.latex\n") diff --git a/test/TEX/PDFTEXCOMSTR.py b/test/TEX/PDFTEXCOMSTR.py index 50edd28a07..30f3539264 100644 --- a/test/TEX/PDFTEXCOMSTR.py +++ b/test/TEX/PDFTEXCOMSTR.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,11 +22,8 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 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__" - -r""" +""" Test that the $PDFTEXCOMSTR construction variable allows you to configure the C compilation output. """ @@ -38,6 +37,7 @@ test.file_fixture('mycompile.py') test.write('SConstruct', """ +_ = DefaultEnvironment(tools=[]) env = Environment(TOOLS = ['pdftex'], PDFTEXCOM = r'%(_python_)s mycompile.py tex $TARGET $SOURCE', PDFTEXCOMSTR = 'Building $TARGET from $SOURCE') @@ -51,7 +51,7 @@ test.run(stdout = test.wrap_stdout("""\ Building test1.pdf from test1.tex -""" % locals())) +""")) test.must_match('test1.pdf', "test1.tex\n") diff --git a/test/TEX/TEXCOMSTR.py b/test/TEX/TEXCOMSTR.py index 9dbba133ab..c41de6d191 100644 --- a/test/TEX/TEXCOMSTR.py +++ b/test/TEX/TEXCOMSTR.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,11 +22,8 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 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__" - -r""" +""" Test that the $TEXCOMSTR construction variable allows you to configure the C compilation output. """ @@ -38,9 +37,12 @@ test.file_fixture('mycompile.py') test.write('SConstruct', """ -env = Environment(TOOLS = ['tex'], - TEXCOM = r'%(_python_)s mycompile.py tex $TARGET $SOURCE', - TEXCOMSTR = 'Building $TARGET from $SOURCE') +_ = DefaultEnvironment(tools=[]) +env = Environment( + TOOLS=['tex'], + TEXCOM=r'%(_python_)s mycompile.py tex $TARGET $SOURCE', + TEXCOMSTR='Building $TARGET from $SOURCE', +) env.DVI('test1') """ % locals()) @@ -49,9 +51,9 @@ /*tex*/ """) -test.run(stdout = test.wrap_stdout("""\ +test.run(stdout=test.wrap_stdout("""\ Building test1.dvi from test1.tex -""" % locals())) +""")) test.must_match('test1.dvi', "test1.tex\n") diff --git a/test/TEX/configure.py b/test/TEX/configure.py index 9fb4b3e8a5..31bec050a8 100644 --- a/test/TEX/configure.py +++ b/test/TEX/configure.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,11 +22,8 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 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__" - -r""" +""" Verify execution of custom test case. The old code base would not be able to fail the test """ @@ -50,6 +49,8 @@ # misspell package name to ensure failure test.write('SConstruct', r""" +import os + lmodern_test_text = r''' \documentclass{article} \usepackage{lmodernD} @@ -68,13 +69,13 @@ def CheckLModern(context): context.Result(is_ok) return is_ok -import os +_ = DefaultEnvironment(tools=[]) env = Environment() env['TEXINPUTS'] = '.' conf = Configure( env, custom_tests={'CheckLModern' : CheckLModern} ) conf.CheckLModern() env = conf.Finish() -""" % locals()) +""") test.run() diff --git a/test/TEX/dryrun.py b/test/TEX/dryrun.py index 90357fcc66..4dc12e4e35 100644 --- a/test/TEX/dryrun.py +++ b/test/TEX/dryrun.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,11 +22,8 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 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__" -r""" +""" Validate that we can set the LATEX string to our own utility, that the produced .dvi, .aux and .log files get removed by the -c option, and that we can use this to wrap calls to the real latex utility. @@ -43,9 +42,11 @@ test.write('SConstruct', """ import os + +_ = DefaultEnvironment(tools=[]) foo = Environment() foo.DVI(target = 'foo.dvi', source = 'foo.ltx') -""" % locals()) +""") test.write('foo.ltx', r""" \documentclass{letter} diff --git a/test/TEX/rename_result.py b/test/TEX/rename_result.py index f67e5692e3..5d9f1b0368 100644 --- a/test/TEX/rename_result.py +++ b/test/TEX/rename_result.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,9 +22,6 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 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__" r""" Validate that we can rename the output from latex to the @@ -42,11 +41,13 @@ test.write('SConstruct', """ import os + +_ = DefaultEnvironment(tools=[]) foo = Environment() foo['TEXINPUTS'] = [ 'subdir', os.environ.get('TEXINPUTS', '') ] foo.DVI(target = 'foobar.dvi', source = 'foo.ltx') foo.PDF(target = 'bar.xyz', source = 'bar.ltx') -""" % locals()) +""") test.write('foo.ltx', r""" \documentclass{letter} diff --git a/test/TEX/usepackage.py b/test/TEX/usepackage.py index 66510c2e35..34d22b35f9 100644 --- a/test/TEX/usepackage.py +++ b/test/TEX/usepackage.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,9 +22,6 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 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__" r""" Validate that we can set the LATEX string to our own utility, that @@ -43,10 +42,12 @@ test.write('SConstruct', """ import os + +_ = DefaultEnvironment(tools=[]) foo = Environment() foo['TEXINPUTS'] = [ 'subdir', os.environ.get('TEXINPUTS', '') ] foo.DVI(target = 'foo.dvi', source = 'foo.ltx') -""" % locals()) +""") test.write('foo.ltx', r""" \documentclass{letter} diff --git a/test/Variables/import.py b/test/Variables/import.py index 8e0cd2595c..85c75fd39c 100644 --- a/test/Variables/import.py +++ b/test/Variables/import.py @@ -37,6 +37,7 @@ test.subdir('bin', 'subdir') test.write('SConstruct', """\ +_ = DefaultEnvironment(tools=[]) opts = Variables('../bin/opts.cfg', ARGUMENTS) opts.Add('VARIABLE') Export("opts") @@ -45,7 +46,6 @@ SConscript_contents = """\ Import("opts") -_ = DefaultEnvironment(tools=[]) env = Environment(tools=[]) opts.Update(env) print("VARIABLE = %s"%env.get('VARIABLE')) @@ -53,7 +53,7 @@ test.write(['bin', 'opts.cfg'], """\ from local_options import VARIABLE -""" % locals()) +""") test.write(['bin', 'local_options.py'], """\ VARIABLE = 'bin/local_options.py' diff --git a/test/YACC/live-check-output-cleaned.py b/test/YACC/live-check-output-cleaned.py index aef47deb28..b4914a892e 100644 --- a/test/YACC/live-check-output-cleaned.py +++ b/test/YACC/live-check-output-cleaned.py @@ -42,7 +42,7 @@ DefaultEnvironment(tools=[]) foo = Environment(YACCFLAGS='-v -d', tools = ['default', 'yacc']) foo.CFile(source = 'foo.y') -""" % locals()) +""") yacc = r""" %%{ diff --git a/test/ZIP/ZIP.py b/test/ZIP/ZIP.py index b79173c4a4..09115fea13 100644 --- a/test/ZIP/ZIP.py +++ b/test/ZIP/ZIP.py @@ -35,12 +35,13 @@ test.subdir('sub1') test.write('SConstruct', """ +_ = DefaultEnvironment(tools=[]) env = Environment(tools = ['zip']) env.Zip(target = 'aaa.zip', source = ['file1', 'file2']) env.Zip(target = 'aaa.zip', source = 'file3') env.Zip(target = 'bbb', source = 'sub1') env.Zip(target = 'bbb', source = 'file4') -""" % locals()) +""") test.write('file1', "file1\n") test.write('file2', "file2\n") diff --git a/test/ZIP/ZIPROOT.py b/test/ZIP/ZIPROOT.py index 10e01d950f..42579c2ac2 100644 --- a/test/ZIP/ZIPROOT.py +++ b/test/ZIP/ZIPROOT.py @@ -37,10 +37,11 @@ test.subdir(['sub1', 'sub2']) test.write('SConstruct', """ +_ = DefaultEnvironment(tools=[]) env = Environment(tools = ['zip']) env.Zip(target = 'aaa.zip', source = ['sub1/file1'], ZIPROOT='sub1') env.Zip(target = 'bbb.zip', source = ['sub1/file2', 'sub1/sub2/file2'], ZIPROOT='sub1') -""" % locals()) +""") test.write(['sub1', 'file1'], "file1\n") test.write(['sub1', 'file2'], "file2a\n") diff --git a/test/ZIP/ZIP_OVERRIDE_TIMESTAMP.py b/test/ZIP/ZIP_OVERRIDE_TIMESTAMP.py index 89049445dd..1c9a2c0426 100644 --- a/test/ZIP/ZIP_OVERRIDE_TIMESTAMP.py +++ b/test/ZIP/ZIP_OVERRIDE_TIMESTAMP.py @@ -39,14 +39,15 @@ def zipfile_get_file_datetime(zipfilename, fname): for info in zf.infolist(): if info.filename == fname: return info.date_time - + raise Exception("Unable to find %s" % fname) test.write('SConstruct', """ +_ = DefaultEnvironment(tools=[]) env = Environment(tools = ['zip']) env.Zip(target = 'aaa.zip', source = ['file1'], ZIP_OVERRIDE_TIMESTAMP=(1983,3,11,1,2,2)) -""" % locals()) +""") test.write(['file1'], "file1\n") diff --git a/test/gettext/POTUpdate/UserExamples.py b/test/gettext/POTUpdate/UserExamples.py index 06203fafa7..a3075ebca1 100644 --- a/test/gettext/POTUpdate/UserExamples.py +++ b/test/gettext/POTUpdate/UserExamples.py @@ -1,6 +1,8 @@ -2#!/usr/bin/env python +#!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,9 +22,6 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 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__" """ End-to-end tests for POTUpdate. Assure, that the examples from user's @@ -44,6 +43,7 @@ test.subdir(['ex1', 'po']) test.write( ['ex1', 'po', 'SConstruct' ], """ +_ = DefaultEnvironment(tools=[]) env = Environment( tools = ['default', 'xgettext'] ) env.POTUpdate(['foo'], ['../a.cpp', '../b.cpp']) env.POTUpdate(['bar'], ['../c.cpp', '../d.cpp']) @@ -88,6 +88,7 @@ test.subdir(['ex2']) test.write( ['ex2', 'SConstruct'], """ +_ = DefaultEnvironment(tools=[]) env = Environment( tools = ['default', 'xgettext'] ) env['POTDOMAIN'] = "foo" env.POTUpdate(source = ["a.cpp", "b.cpp"]) # Creates foo.pot ... @@ -121,6 +122,7 @@ test.write( ['ex3', 'po', 'SConstruct'], """ # SConstruct file in 'po/' subdirectory +_ = DefaultEnvironment(tools=[]) env = Environment( tools = ['default', 'xgettext'] ) env.POTUpdate(XGETTEXTFROM = 'POTFILES.in') """) @@ -147,6 +149,7 @@ test.write( ['ex4', 'po', 'SConstruct'], """ # SConstruct file in 'po/' subdirectory +_ = DefaultEnvironment(tools=[]) env = Environment( tools = ['default', 'xgettext'] ) env.POTUpdate(XGETTEXTFROM = 'POTFILES.in', XGETTEXTPATH='../') """) @@ -176,6 +179,7 @@ test.write( ['ex5', '0', '1', 'po', 'SConstruct'], """ # SConstruct file in '0/1/po/' subdirectory +_ = DefaultEnvironment(tools=[]) env = Environment( tools = ['default', 'xgettext'] ) env.POTUpdate(XGETTEXTFROM = 'POTFILES.in', XGETTEXTPATH=['../', '../../']) """) @@ -191,14 +195,15 @@ # scons 'pot-update' creates messages.pot test.run(arguments = 'pot-update', chdir = path.join('ex5', '0', '1', 'po')) test.must_exist( ['ex5', '0', '1', 'po', 'messages.pot']) -test.must_contain( ['ex5', '0', '1', 'po', 'messages.pot'], +test.must_contain( ['ex5', '0', '1', 'po', 'messages.pot'], 'Hello from ../a.cpp', mode='r' ) -test.must_not_contain( ['ex5', '0', '1', 'po', 'messages.pot'], +test.must_not_contain( ['ex5', '0', '1', 'po', 'messages.pot'], 'Hello from ../../a.cpp', mode='r' ) test.write(['ex5', '0', '1', 'po', 'SConstruct'], """ # SConstruct file in '0/1/po/' subdirectory +_ = DefaultEnvironment(tools=[]) env = Environment( tools = ['default', 'xgettext'] ) env.POTUpdate(XGETTEXTFROM = 'POTFILES.in', XGETTEXTPATH=['../../', '../']) """) diff --git a/test/implicit-cache/DualTargets.py b/test/implicit-cache/DualTargets.py index 8612d1a531..174d39c149 100644 --- a/test/implicit-cache/DualTargets.py +++ b/test/implicit-cache/DualTargets.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,9 +22,6 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Test that --implicit-cache works correctly in conjonction with a @@ -53,9 +52,9 @@ def source_scan(node, env, path): env = Environment(tools=[]) env['BUILDERS']['DualTarget'] = Builder( action = Action( - [ - Copy( '$TARGET', '$SOURCE' ), - Copy( '${TARGET.base}.b', '$SOURCE' ), + [ + Copy( '$TARGET', '$SOURCE' ), + Copy( '${TARGET.base}.b', '$SOURCE' ), ], ), suffix = '.a', @@ -69,7 +68,7 @@ def source_scan(node, env, path): env.Command( 'x.lib', '', Touch('$TARGET') ) env.DualTarget('x.cpp') -""" % locals()) +""") test.must_not_exist('x.cpp') test.must_not_exist('x.lib') diff --git a/test/no-global-dependencies.py b/test/no-global-dependencies.py index 95761e7de3..541a645ec0 100644 --- a/test/no-global-dependencies.py +++ b/test/no-global-dependencies.py @@ -48,11 +48,12 @@ BoolVariable('duplicate', 'Duplicate sources to variant dir', True) ) +_ = DefaultEnvironment(tools=[]) env = Environment(options=opts) Export('env') SConscript(dirs='.', variant_dir='build', duplicate=env['duplicate']) -""" % locals()) +""") test.write('SConscript', """\ @@ -62,7 +63,7 @@ SConscript(dirs='dir1') SConscript(dirs='dir2') -""" % locals()) +""") test.write('dir1/SConscript', """\ Import('env') @@ -70,13 +71,13 @@ env.Command('x.cpp', '', Touch('$TARGET')) env.Object(env.File('x.cpp')) -""" % locals()) +""") test.write('dir2/SConscript', """\ Import('env') env.Object(env.File('#/build/dir1/x.cpp')) -""" % locals()) +""") test.must_not_exist('build/dir1/x.cpp') @@ -87,36 +88,36 @@ # # Build everything first. -test.run(arguments = 'duplicate=False view_all_dependencies=True .') +test.run(arguments='duplicate=False view_all_dependencies=True .') test.must_exist('build/dir1/x.cpp') test.must_not_contain_any_line(test.stdout(), ["`.' is up to date."]) # Double check that targets are not rebuilt. -test.run(arguments = 'duplicate=False view_all_dependencies=True .') +test.run(arguments='duplicate=False view_all_dependencies=True .') test.must_exist('build/dir1/x.cpp') test.must_contain_all_lines(test.stdout(), ["`.' is up to date."]) # Clean-up only the object file -test.run(arguments = 'duplicate=False view_all_dependencies=False -c .') +test.run(arguments='duplicate=False view_all_dependencies=False -c .') test.must_exist('build/dir1/x.cpp') # Rebuild the only object file without seeing all the dependencies. -test.run(arguments = 'duplicate=False view_all_dependencies=False .') +test.run(arguments='duplicate=False view_all_dependencies=False .') test.must_exist('build/dir1/x.cpp') test.must_not_contain_any_line(test.stdout(), ["`.' is up to date."]) # Double check that targets are not rebuilt without and with all the # dependencies. -test.run(arguments = 'duplicate=False view_all_dependencies=False .') +test.run(arguments='duplicate=False view_all_dependencies=False .') test.must_exist('build/dir1/x.cpp') test.must_contain_all_lines(test.stdout(), ["`.' is up to date."]) -test.run(arguments = 'duplicate=False view_all_dependencies=True .') +test.run(arguments='duplicate=False view_all_dependencies=True .') test.must_exist('build/dir1/x.cpp') test.must_contain_all_lines(test.stdout(), ["`.' is up to date."]) # Clean-up everything. -test.run(arguments = 'duplicate=False view_all_dependencies=True -c .') +test.run(arguments='duplicate=False view_all_dependencies=True -c .') test.must_not_exist('build/dir1/x.cpp') @@ -131,36 +132,36 @@ # # # Build everything first. -# test.run(arguments = 'duplicate=True view_all_dependencies=True .') +# test.run(arguments='duplicate=True view_all_dependencies=True .') # test.must_exist('build/dir1/x.cpp') # test.must_not_contain_any_line(test.stdout(), ["`.' is up to date."]) # # Double check that targets are not rebuilt. -# test.run(arguments = 'duplicate=True view_all_dependencies=True .') +# test.run(arguments='duplicate=True view_all_dependencies=True .') # test.must_exist('build/dir1/x.cpp') # test.must_contain_all_lines(test.stdout(), ["`.' is up to date."]) # # Clean-up only the object file -# test.run(arguments = 'duplicate=True view_all_dependencies=False -c .') +# test.run(arguments='duplicate=True view_all_dependencies=False -c .') # test.must_exist('build/dir1/x.cpp') # # Rebuild the only object file without seeing all the dependencies. -# test.run(arguments = 'duplicate=True view_all_dependencies=False .') +# test.run(arguments='duplicate=True view_all_dependencies=False .') # test.must_exist('build/dir1/x.cpp') # test.must_not_contain_any_line(test.stdout(), ["`.' is up to date."]) # # Double check that targets are not rebuilt without and with all the # # dependencies. -# test.run(arguments = 'duplicate=True view_all_dependencies=False .') +# test.run(arguments='duplicate=True view_all_dependencies=False .') # test.must_exist('build/dir1/x.cpp') # test.must_contain_all_lines(test.stdout(), ["`.' is up to date."]) -# test.run(arguments = 'duplicate=True view_all_dependencies=True .') +# test.run(arguments='duplicate=True view_all_dependencies=True .') # test.must_exist('build/dir1/x.cpp') # test.must_contain_all_lines(test.stdout(), ["`.' is up to date."]) # # Clean-up everything. -# test.run(arguments = 'duplicate=True view_all_dependencies=True -c .') +# test.run(arguments='duplicate=True view_all_dependencies=True -c .') # test.must_not_exist('build/dir1/x.cpp') diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py index d19cfab290..680eae5451 100644 --- a/test/sconsign/script/SConsignFile.py +++ b/test/sconsign/script/SConsignFile.py @@ -111,6 +111,7 @@ def process(infp, outfp): ['SConstruct'], f"""\ SConsignFile() +_ = DefaultEnvironment(tools=[]) env1 = Environment( PROGSUFFIX='.exe', OBJSUFFIX='.obj', @@ -155,14 +156,14 @@ def process(infp, outfp): #define STRING2 "inc2.h" """) -test.run(arguments = '--implicit-cache .') +test.run(arguments='--implicit-cache .') sig_re = r'[0-9a-fA-F]{32,64}' database_name = test.get_sconsignname() -test.run_sconsign(arguments = database_name, - stdout = r"""=== .: +test.run_sconsign(arguments=database_name, + stdout=r"""=== .: SConstruct: None \d+ \d+ fake_cc\.py: %(sig_re)s \d+ \d+ fake_link\.py: %(sig_re)s \d+ \d+ @@ -192,8 +193,8 @@ def process(infp, outfp): inc2.h: %(sig_re)s \d+ \d+ """ % locals()) -test.run_sconsign(arguments = "--raw " + database_name, - stdout = r"""=== .: +test.run_sconsign(arguments="--raw " + database_name, + stdout=r"""=== .: SConstruct: {'csig': None, 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2} @@ -320,10 +321,10 @@ def process(infp, outfp): size: \d+ """ % locals() -test.run_sconsign(arguments = "-v " + database_name, stdout=expect) +test.run_sconsign(arguments="-v " + database_name, stdout=expect) -test.run_sconsign(arguments = "-c -v " + database_name, - stdout = r"""=== .: +test.run_sconsign(arguments="-c -v " + database_name, + stdout=r"""=== .: SConstruct: csig: None fake_cc\.py: @@ -350,8 +351,8 @@ def process(infp, outfp): csig: %(sig_re)s """ % locals()) -test.run_sconsign(arguments = "-s -v " + database_name, - stdout = r"""=== .: +test.run_sconsign(arguments="-s -v " + database_name, + stdout=r"""=== .: SConstruct: size: \d+ fake_cc\.py: @@ -376,10 +377,10 @@ def process(infp, outfp): size: \d+ inc2.h: size: \d+ -""" % locals()) +""") -test.run_sconsign(arguments = "-t -v " + database_name, - stdout = r"""=== .: +test.run_sconsign(arguments="-t -v " + database_name, + stdout=r"""=== .: SConstruct: timestamp: \d+ fake_cc\.py: @@ -404,10 +405,10 @@ def process(infp, outfp): timestamp: \d+ inc2.h: timestamp: \d+ -""" % locals()) +""") -test.run_sconsign(arguments = "-e hello.obj " + database_name, - stdout = r"""=== .: +test.run_sconsign(arguments="-e hello.obj " + database_name, + stdout=r"""=== .: === sub1: hello.obj: %(sig_re)s \d+ \d+ %(sub1_hello_c)s: %(sig_re)s \d+ \d+ @@ -421,11 +422,11 @@ def process(infp, outfp): fake_cc\.py: %(sig_re)s \d+ \d+ %(sig_re)s \[.*\] """ % locals(), - stderr = r"""sconsign: no entry `hello\.obj' in `\.' -""" % locals()) + stderr=r"""sconsign: no entry `hello\.obj' in `\.' +""") -test.run_sconsign(arguments = "-e hello.obj -e hello.exe -e hello.obj " + database_name, - stdout = r"""=== .: +test.run_sconsign(arguments="-e hello.obj -e hello.exe -e hello.obj " + database_name, + stdout=r"""=== .: === sub1: hello.obj: %(sig_re)s \d+ \d+ %(sub1_hello_c)s: %(sig_re)s \d+ \d+ @@ -457,13 +458,13 @@ def process(infp, outfp): fake_cc\.py: %(sig_re)s \d+ \d+ %(sig_re)s \[.*\] """ % locals(), - stderr = r"""sconsign: no entry `hello\.obj' in `\.' + stderr=r"""sconsign: no entry `hello\.obj' in `\.' sconsign: no entry `hello\.exe' in `\.' sconsign: no entry `hello\.obj' in `\.' -""" % locals()) +""") -#test.run_sconsign(arguments = "-i -v " + database_name, -# stdout = r"""=== sub1: +#test.run_sconsign(arguments="-i -v " + database_name, +# stdout=r"""=== sub1: #hello.exe: # implicit: # hello.obj: %(sig_re)s diff --git a/testing/framework/TestCommonTests.py b/testing/framework/TestCommonTests.py index 31e13e9b51..014a018766 100644 --- a/testing/framework/TestCommonTests.py +++ b/testing/framework/TestCommonTests.py @@ -762,7 +762,7 @@ def test_failure(self) -> None: 'www' 'zzz' Extra output =================================================================== - """ % globals()) + """) run_env.run(program=sys.executable, stdin=script) stdout = run_env.stdout() @@ -848,7 +848,7 @@ def test_title(self) -> None: 'www' 'zzz' Extra STDOUT =================================================================== - """ % globals()) + """) run_env.run(program=sys.executable, stdin=script) stdout = run_env.stdout() @@ -2234,10 +2234,14 @@ def test_options_plus_arguments(self) -> None: self.run_execution_test(script, "", "") def test_signal_handling(self) -> None: - """Test run(): signal handling""" + """Test run(): signal handling. + Only strange platforms unlikely to support SCons like the + webassembly ones don't support kill(), but keep the test + in place anyway. + """ try: - os.kill + _ = os.kill except AttributeError: sys.stderr.write('can not test, no os.kill ... ') return diff --git a/testing/framework/TestSCons.py b/testing/framework/TestSCons.py index 2b40a361de..e0b45377b1 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -426,12 +426,12 @@ def wrap_stdout(self, build_str: str="", read_str: str="", error: int=0, cleanin Makes a complete message to match against. Args: - read_str: the message for the execution part of the output. + build_str: the message for the execution part of the output. If non-empty, needs to be newline-terminated. read_str: the message for the reading-sconscript part of the output. If non-empty, needs to be newline-terminated. error: if true, expect a fail message rather than a done message. - cleaning (int): index into type messages, if 0 selects + cleaning: index into type messages, if 0 selects build messages, if 1 selects clean messages. """ cap, lc = [('Build', 'build'), From 93a7d1e3755da1f08431889fcdd8d004bf07b518 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sat, 6 Jul 2024 08:22:20 -0600 Subject: [PATCH 2/2] Fix scons-time fix Apparently, the weird structor of the SConsTimer class is such that the previous fix for the "makedict" method fails on older Pythons. Just moved the "static method" outside the class to be a top-level function, that seems to work better. Signed-off-by: Mats Wichmann --- CHANGES.txt | 1 + bin/scons-time.py | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7b5cf5ba51..b89cebf974 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -178,6 +178,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Regularized header (copyright, licens) at top of documentation files using SPDX. - Updated introductory section of manual page. + - Minor cleanups in tests - drop unused "% locals()" stanzas. RELEASE 4.7.0 - Sun, 17 Mar 2024 17:22:20 -0700 diff --git a/bin/scons-time.py b/bin/scons-time.py index f8858f772f..d81d4c4e00 100644 --- a/bin/scons-time.py +++ b/bin/scons-time.py @@ -260,6 +260,8 @@ def redirect_to_file(command, log): def tee_to_file(command, log): return '%s 2>&1 | tee %s' % (command, log) +def makedict(**kw): + return kw class SConsTimer: """ @@ -278,10 +280,6 @@ class SConsTimer: name = 'scons-time' name_spaces = ' ' * len(name) - @staticmethod - def makedict(**kw): - return kw - default_settings = makedict( chdir=None, config_file=None,