Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some minor test tweaking #4568

Merged
merged 2 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions bin/scons-time.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand All @@ -278,9 +280,6 @@ class SConsTimer:
name = 'scons-time'
name_spaces = ' ' * len(name)

def makedict(**kw):
return kw

default_settings = makedict(
chdir=None,
config_file=None,
Expand Down
4 changes: 2 additions & 2 deletions test/CacheDir/value_dependencies/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
4 changes: 2 additions & 2 deletions test/Configure/custom-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
""")

test.write('SConstruct', """\
DefaultEnvironment(tools=[])
DefaultEnvironment(tools=[])
def CheckCustom(test):
test.Message( 'Executing MyTest ... ' )
retCompileOK = test.TryCompile( '%(compileOK)s', '.c' )
Expand Down Expand Up @@ -164,7 +164,7 @@ def CheckEmptyDict(test):
conf.CheckDict()
conf.CheckEmptyDict()
env = conf.Finish()
""" % locals())
""")

test.run()

Expand Down
10 changes: 5 additions & 5 deletions test/Errors/preparation.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -49,14 +48,15 @@
test.subdir('install', 'work')

test.write(['work', 'SConstruct'], """\
_ = DefaultEnvironment(tools=[])
file_out = Command('file.out', 'file.in', Copy('$TARGET', '$SOURCE'))
Alias("install", file_out)

# Make a directory where we expect the File() to be. This causes an
# 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"
Expand Down
11 changes: 5 additions & 6 deletions test/GetBuildFailures/option-k.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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_
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions test/Java/JARCHDIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
${TARGET} or ${SOURCE} work.
"""


import TestSCons

test = TestSCons.TestSCons()
Expand Down Expand Up @@ -60,7 +59,7 @@
source_env.Jar('out/s.jar', 'in/s.class')

Default(bin, jar, inner)
""" % locals())
""")

test.subdir('in')

Expand Down
4 changes: 2 additions & 2 deletions test/Java/JARFLAGS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -60,7 +60,7 @@
jar cvf test.jar -C classes src.Example1\\.class
.*
adding: src.Example1\\.class.*
""" % locals())
""")


test.run(arguments = '.',
Expand Down
2 changes: 1 addition & 1 deletion test/Java/JAVACFLAGS.py
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/Java/JAVACLASSPATH.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
5 changes: 2 additions & 3 deletions test/Java/JAVAH.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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',
)

Expand Down
5 changes: 3 additions & 2 deletions test/Java/multi-step.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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',[]))
Expand Down Expand Up @@ -125,7 +126,7 @@
'buildout/javah/SConscript',
]
)
""" % locals())
""")

test.write(['src', 'HelloApplet', 'Hello.html'], """\
<HTML>
Expand Down
7 changes: 4 additions & 3 deletions test/Java/no-JARCHDIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -73,7 +74,7 @@
JARCHDIR = None)

jar = env.Jar('x.jar', env.Java(target = 'classes', source = 'src'))
""" % locals())
""")

test.run(arguments = '.')

Expand Down
15 changes: 8 additions & 7 deletions test/Java/swig-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -56,7 +57,7 @@

SConscript('#foo/SConscript')
SConscript('#java/SConscript')
""" % locals())
""")

test.write(['foo', 'SConscript'], """\
Import('env')
Expand All @@ -68,7 +69,7 @@
#include "foo.h"

int fooAdd(int a, int b) {
return a + b;
return a + b;
}
""")

Expand Down Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion test/LEX/no_lex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
3 changes: 2 additions & 1 deletion test/MSVC/MSVC_USE_SCRIPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 4 additions & 3 deletions test/MSVC/MSVC_USE_SETTINGS.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
test.skip_if_not_msvc()

test.write('SConstruct', """
_ = DefaultEnvironment(tools=[])
e1 = Environment()
cl1 = e1.WhereIs('cl.exe')

Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion test/MSVC/PCH-source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
""")
Expand Down
8 changes: 4 additions & 4 deletions test/MSVC/TARGET_ARCH.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=".")

Expand All @@ -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")
Expand All @@ -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()
Expand All @@ -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()
Expand Down
Loading
Loading