From 9fc18579b415b39cfb69e8af80551f9a5f83d2f0 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Tue, 25 Jun 2024 08:08:56 -0600 Subject: [PATCH] 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 c8121fb6f..f8858f772 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 9e971c64d..3923228bf 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 3f5bcb6db..9a6d0f61a 100644 --- a/test/Configure/custom-tests.py +++ b/test/Configure/custom-tests.py @@ -55,7 +55,7 @@ sys.exit(int(sys.argv[1])) """) test.write('SConstruct', """\ -DefaultEnvironment(tools=[]) +DefaultEnvironment(tools=[]) def CheckCustom(test): test.Message( 'Executing MyTest ... ' ) retCompileOK = test.TryCompile( '%(compileOK)s', '.c' ) @@ -164,7 +164,7 @@ conf.CheckEmptyStr() conf.CheckDict() conf.CheckEmptyDict() env = conf.Finish() -""" % locals()) +""") test.run() diff --git a/test/Errors/preparation.py b/test/Errors/preparation.py index 914827a71..51ca2de9b 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 @@ work_file_out = test.workpath('work', 'file.out') 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 @@ Alias("install", file_out) # 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 039ad50a9..50ad30298 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 @@ scons: Building targets ... 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 @@ test.must_contain_exactly_lines(test.stderr(), expect_stderr, title='stderr') 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 c24717231..c84509bd5 100644 --- a/test/Java/JARCHDIR.py +++ b/test/Java/JARCHDIR.py @@ -32,7 +32,6 @@ Includes logic to make sure that expansions of $JARCHDIR that include ${TARGET} or ${SOURCE} work. """ - import TestSCons test = TestSCons.TestSCons() @@ -60,7 +59,7 @@ source_env = env.Clone(JARCHDIR='${SOURCE.dir}') 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 36af5929e..957464d98 100644 --- a/test/Java/JARFLAGS.py +++ b/test/Java/JARFLAGS.py @@ -39,7 +39,7 @@ env = Environment(tools=['javac', 'jar'], JARFLAGS='cvf') 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 @@ javac -d classes -sourcepath src src.Example1\\.java 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 3a555a3a1..51bf3f68d 100644 --- a/test/Java/JAVACFLAGS.py +++ b/test/Java/JAVACFLAGS.py @@ -37,7 +37,7 @@ test.write('SConstruct', """ 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 38f01cc03..48034dd09 100644 --- a/test/Java/JAVACLASSPATH.py +++ b/test/Java/JAVACLASSPATH.py @@ -59,7 +59,7 @@ env = Environment(tools=['javac', 'javah']) 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 27e98216f..1ad3933c0 100644 --- a/test/Java/JAVAH.py +++ b/test/Java/JAVAH.py @@ -39,7 +39,7 @@ if java_version: # 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 @@ test.run(arguments = '.') 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 ab627cb46..05ef90d40 100644 --- a/test/Java/multi-step.py +++ b/test/Java/multi-step.py @@ -49,7 +49,7 @@ if not swig: # 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 @@ if sys.platform == 'win32': 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 @@ env.SConscript( '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 d3392518c..0798b090a 100644 --- a/test/Java/no-JARCHDIR.py +++ b/test/Java/no-JARCHDIR.py @@ -51,10 +51,11 @@ public class b {} """) 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 @@ env = Environment(tools = ['javac', 'jar'], 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 48010ad8f..3fa563dd4 100644 --- a/test/Java/swig-dependencies.py +++ b/test/Java/swig-dependencies.py @@ -47,6 +47,7 @@ test.subdir(['foo'], 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 @@ Export('env') SConscript('#foo/SConscript') SConscript('#java/SConscript') -""" % locals()) +""") test.write(['foo', 'SConscript'], """\ Import('env') @@ -68,7 +69,7 @@ test.write(['foo', 'foo.cpp'], """\ #include "foo.h" int fooAdd(int a, int b) { - return a + b; + return a + b; } """) @@ -115,11 +116,11 @@ libpath = ['#foo',] 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 e53b02e8e..969dd3840 100644 --- a/test/LEX/no_lex.py +++ b/test/LEX/no_lex.py @@ -46,7 +46,7 @@ SCons.Tool.find_program_path = no_lex 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 67eddfc1e..d6c683ffe 100644 --- a/test/MSVC/MSVC_USE_SCRIPT.py +++ b/test/MSVC/MSVC_USE_SCRIPT.py @@ -35,8 +35,9 @@ test = TestSCons.TestSCons() 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 fd6f85ceb..a473862fa 100644 --- a/test/MSVC/MSVC_USE_SETTINGS.py +++ b/test/MSVC/MSVC_USE_SETTINGS.py @@ -35,6 +35,7 @@ test = TestSCons.TestSCons() test.skip_if_not_msvc() test.write('SConstruct', """ +_ = DefaultEnvironment(tools=[]) e1 = Environment() cl1 = e1.WhereIs('cl.exe') @@ -46,21 +47,21 @@ cl3 = e3.WhereIs('cl.exe') 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 84a39bd78..99683171b 100644 --- a/test/MSVC/PCH-source.py +++ b/test/MSVC/PCH-source.py @@ -41,7 +41,7 @@ env = Environment(tools=['msvc', 'mslink']) 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 d8a2f933e..f093a425d 100644 --- a/test/MSVC/TARGET_ARCH.py +++ b/test/MSVC/TARGET_ARCH.py @@ -38,7 +38,7 @@ test.write('SConstruct', """ 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.run(arguments=".") 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 @@ DefaultEnvironment(tools=[]) 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 @@ DefaultEnvironment(tools=[]) 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 addf00180..0e78fd5ae 100644 --- a/test/MSVC/batch-longlines.py +++ b/test/MSVC/batch-longlines.py @@ -45,7 +45,7 @@ DefaultEnvironment(tools=[]) 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 9fac820d9..9dbac5057 100644 --- a/test/MinGW/MinGWSharedLibrary.py +++ b/test/MinGW/MinGWSharedLibrary.py @@ -63,7 +63,7 @@ env.SharedLibrary('foobar', foobar_obj) # 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 5119c9751..27e075f39 100644 --- a/test/MinGW/WINDOWS_INSERT_DEF.py +++ b/test/MinGW/WINDOWS_INSERT_DEF.py @@ -55,7 +55,7 @@ test.write('SConstruct', """ 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 7859b6423..2c733aae7 100644 --- a/test/Removed/Old/warn-missing-sconscript.py +++ b/test/Removed/Old/warn-missing-sconscript.py @@ -59,7 +59,7 @@ Missing SConscript 'no_such_file' # 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 6dc5050d9..a7215e906 100644 --- a/test/TEX/LATEX2.py +++ b/test/TEX/LATEX2.py @@ -47,10 +47,12 @@ if latex: 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 41c5dc72c..de63ebfa3 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 = TestSCons.TestSCons() 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 @@ test1.latex 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 d695bdec1..f0e9467d5 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 = TestSCons.TestSCons() 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 @@ test1.latex 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 50edd28a0..30f353926 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 = TestSCons.TestSCons() 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 @@ test1.tex 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 9dbba133a..c41de6d19 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 = TestSCons.TestSCons() 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 @@ test1.tex /*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 9fb4b3e8a..31bec050a 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 @@ NCR = test.NCR # non-cached rebuild # 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 90357fcc6..4dc12e4e3 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 @@ if not latex: 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 f67e5692e..5d9f1b036 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 @@ if not latex: 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 66510c2e3..34d22b35f 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 @@ if not latex: 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 8e0cd2595..85c75fd39 100644 --- a/test/Variables/import.py +++ b/test/Variables/import.py @@ -37,6 +37,7 @@ workpath = test.workpath('') 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('subdir/SConscript') SConscript_contents = """\ Import("opts") -_ = DefaultEnvironment(tools=[]) env = Environment(tools=[]) opts.Update(env) print("VARIABLE = %s"%env.get('VARIABLE')) @@ -53,7 +53,7 @@ print("VARIABLE = %s"%env.get('VARIABLE')) 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 aef47deb2..b4914a892 100644 --- a/test/YACC/live-check-output-cleaned.py +++ b/test/YACC/live-check-output-cleaned.py @@ -42,7 +42,7 @@ test.write('SConstruct', """ 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 b79173c4a..09115fea1 100644 --- a/test/ZIP/ZIP.py +++ b/test/ZIP/ZIP.py @@ -35,12 +35,13 @@ test = TestSCons.TestSCons() 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 10e01d950..42579c2ac 100644 --- a/test/ZIP/ZIPROOT.py +++ b/test/ZIP/ZIPROOT.py @@ -37,10 +37,11 @@ test.subdir('sub1') 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 89049445d..1c9a2c042 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 06203fafa..a3075ebca 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']) 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.must_exist( ['ex1', 'po', 'bar.pot'] ) 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.subdir(['ex3', 'po']) 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.subdir(['ex4', 'po']) 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.subdir(['ex5', '0', '1', 'po']) 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 @@ test.write(['ex5', '0', '1', 'a.cpp'], """ gettext("Hello from ../a.cpp") """) # 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 8612d1a53..174d39c14 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 @@ env.Command( 'x.cpp', '', Touch('$TARGET') ) 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 95761e7de..541a645ec 100644 --- a/test/no-global-dependencies.py +++ b/test/no-global-dependencies.py @@ -48,11 +48,12 @@ opts.AddVariables( 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 @@ if env['view_all_dependencies']: SConscript(dirs='dir1') SConscript(dirs='dir2') -""" % locals()) +""") test.write('dir1/SConscript', """\ Import('env') @@ -70,13 +71,13 @@ Import('env') 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 @@ test.must_not_exist('build/dir1/x.cpp') # # 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 @@ test.must_not_exist('build/dir1/x.cpp') # # # 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 d19cfab29..680eae545 100644 --- a/test/sconsign/script/SConsignFile.py +++ b/test/sconsign/script/SConsignFile.py @@ -111,6 +111,7 @@ test.write( ['SConstruct'], f"""\ SConsignFile() +_ = DefaultEnvironment(tools=[]) env1 = Environment( PROGSUFFIX='.exe', OBJSUFFIX='.obj', @@ -155,14 +156,14 @@ test.write(['sub2', 'inc2.h'], r""" #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 @@ inc1.h: %(sig_re)s \d+ \d+ 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 @@ inc2.h: 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 @@ inc2.h: 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 @@ inc1.h: 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 @@ inc1.h: 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 @@ hello.obj: %(sig_re)s \d+ \d+ 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 @@ hello.obj: %(sig_re)s \d+ \d+ 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 31e13e9b5..014a01876 100644 --- a/testing/framework/TestCommonTests.py +++ b/testing/framework/TestCommonTests.py @@ -762,7 +762,7 @@ class must_contain_exactly_lines_TestCase(TestCommonTestCase): 'www' 'zzz' Extra output =================================================================== - """ % globals()) + """) run_env.run(program=sys.executable, stdin=script) stdout = run_env.stdout() @@ -848,7 +848,7 @@ class must_contain_exactly_lines_TestCase(TestCommonTestCase): 'www' 'zzz' Extra STDOUT =================================================================== - """ % globals()) + """) run_env.run(program=sys.executable, stdin=script) stdout = run_env.stdout() @@ -2234,10 +2234,14 @@ TypeError: forced TypeError 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 2b40a361d..e0b45377b 100644 --- a/testing/framework/TestSCons.py +++ b/testing/framework/TestSCons.py @@ -426,12 +426,12 @@ class TestSCons(TestCommon): 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'), -- 2.11.4.GIT