Skip to content

Commit 049d82a

Browse files
committed
Testing framework fixes
- Test framework now reports a FAIL if the subprocess call to run the test was aborted by the operating system (this is particularly for Windows when antivirus could reject running a compiled test binary). Previously these failures were not recorded in the fails list and so were easy to miss. - Test framework now uses a subdirectory named "scons" below the base temporary directory. This gives something invariant to tell antivirus software to ignore without having to exclude the tmpdir itself. - MSVS "live" tests of project files (e.g. test/MSVS/vs-14.3-exec.py) adjusted to look for the generated executable with an exe sufffix. This had recently started failing on the line:: test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n") as somehow "sub dir\foo" was created, and then "foo.exe" was not matched causing the binary not to execute and failing the test. Signed-off-by: Mats Wichmann <[email protected]>
1 parent 6364bcd commit 049d82a

File tree

7 files changed

+151
-132
lines changed

7 files changed

+151
-132
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
3232
ones in parent NodeInfoBase and can just be inherited.
3333
- Update manpage for Tools, and for TOOL, which also gets a minor
3434
tweak for how it's handled (should be more accurate in a few situations).
35+
- Test framework now uses a subdirectory named "scons" below the base
36+
temporary directory. This gives something invariant to tell antivirus
37+
software to ignore without having to exclude the tmpdir itself.
38+
- MSVS "live" tests of project files adjusted to look for the generated
39+
executable with an exe sufffix
3540

3641

3742
RELEASE 4.7.0 - Sun, 17 Mar 2024 17:22:20 -0700

RELEASE.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ FIXES
4848
IMPROVEMENTS
4949
------------
5050

51-
- List improvements that wouldn't be visible to the user in the
52-
documentation: performance improvements (describe the circumstances
53-
under which they would be observed), or major code cleanups
51+
- Make the testing framework a little more resilient: the temporary
52+
directory for tests now includes a component named "scons" which can
53+
be given to antivirus software to exclude; tests which are aborted
54+
before startup by the operating system now generate a proper FAILED
55+
message and are recorded in the fails list.
5456

5557
PACKAGING
5658
---------

test/MSVS/vs-14.0-exec.py

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python
22
#
3-
# __COPYRIGHT__
3+
# MIT License
4+
#
5+
# Copyright The SCons Foundation
46
#
57
# Permission is hereby granted, free of charge, to any person obtaining
68
# a copy of this software and associated documentation files (the
@@ -20,9 +22,6 @@
2022
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2123
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2224
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23-
#
24-
25-
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
2625

2726
"""
2827
Test that we can actually build a simple program using our generated
@@ -34,6 +33,7 @@
3433
import sys
3534

3635
import TestSConsMSVS
36+
from TestSConsMSVS import _obj, _exe
3737

3838
test = TestSConsMSVS.TestSConsMSVS()
3939

@@ -43,18 +43,16 @@
4343

4444
msvs_version = '14.0'
4545

46-
if not msvs_version in test.msvs_versions():
46+
if msvs_version not in test.msvs_versions():
4747
msg = "Visual Studio %s not installed; skipping test.\n" % msvs_version
4848
test.skip_test(msg)
4949

50-
51-
5250
# Let SCons figure out the Visual Studio environment variables for us and
5351
# print out a statement that we can exec to suck them into our external
5452
# environment so we can execute devenv and really try to build something.
5553

56-
test.run(arguments = '-n -q -Q -f -', stdin = """\
57-
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
54+
test.run(arguments='-n -q -Q -f -', stdin="""\
55+
env = Environment(tools=['msvc'], MSVS_VERSION='%(msvs_version)s')
5856
if env.WhereIs('cl'):
5957
print("os.environ.update(%%s)" %% repr(env['ENV']))
6058
""" % locals())
@@ -65,18 +63,18 @@
6563

6664
exec(test.stdout())
6765

68-
69-
7066
test.subdir('sub dir')
71-
7267
test.write(['sub dir', 'SConstruct'], """\
73-
env=Environment(MSVS_VERSION = '%(msvs_version)s')
74-
75-
env.MSVSProject(target = 'foo.vcxproj',
76-
srcs = ['foo.c'],
77-
buildtarget = 'foo.exe',
78-
variant = 'Release',
79-
DebugSettings = {'LocalDebuggerCommandArguments':'echo "<foo.c>" > output.txt'})
68+
DefaultEnvironment(tools=[])
69+
env = Environment(MSVS_VERSION='%(msvs_version)s')
70+
71+
env.MSVSProject(
72+
target='foo.vcxproj',
73+
srcs=['foo.c'],
74+
buildtarget='foo.exe',
75+
variant='Release',
76+
DebugSettings={'LocalDebuggerCommandArguments': 'echo "<foo.c>" > output.txt'},
77+
)
8078
env.Program('foo.c')
8179
""" % locals())
8280

@@ -92,22 +90,23 @@
9290

9391
test.run(chdir='sub dir', arguments='.')
9492

95-
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])
96-
93+
test.unlink_files('sub dir', ['foo' + _exe, 'foo' + _obj, '.sconsign.dblite'])
9794
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
9895

9996
import SCons.Platform.win32
100-
system_dll_path = os.path.join( SCons.Platform.win32.get_system_root(), 'System32' )
97+
98+
system_dll_path = os.path.join(SCons.Platform.win32.get_system_root(), 'System32')
10199
os.environ['PATH'] = os.environ['PATH'] + os.pathsep + system_dll_path
102100

103-
test.run(chdir='sub dir',
104-
program=[test.get_msvs_executable(msvs_version)],
105-
arguments=['foo.sln', '/build', 'Release'])
101+
test.run(
102+
chdir='sub dir',
103+
program=[test.get_msvs_executable(msvs_version)],
104+
arguments=['foo.sln', '/build', 'Release'],
105+
)
106106

107-
test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n")
107+
test.run(program=test.workpath('sub dir', 'foo' + _exe), stdout="foo.c\n")
108108
test.validate_msvs_file(test.workpath('sub dir', 'foo.vcxproj.user'))
109109

110-
111110
test.pass_test()
112111

113112
# Local Variables:

test/MSVS/vs-14.1-exec.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python
22
#
3-
# __COPYRIGHT__
3+
# MIT License
4+
#
5+
# Copyright The SCons Foundation
46
#
57
# Permission is hereby granted, free of charge, to any person obtaining
68
# a copy of this software and associated documentation files (the
@@ -20,20 +22,18 @@
2022
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2123
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2224
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23-
#
24-
25-
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
2625

2726
"""
2827
Test that we can actually build a simple program using our generated
29-
Visual Studio 14.1 project (.vcxproj) and solution (.sln) files
28+
Visual Studio 14.0 project (.vcxproj) and solution (.sln) files
3029
using Visual Studio 14.1 (Professional edition).
3130
"""
3231

3332
import os
3433
import sys
3534

3635
import TestSConsMSVS
36+
from TestSConsMSVS import _obj, _exe
3737

3838
test = TestSConsMSVS.TestSConsMSVS()
3939

@@ -47,14 +47,12 @@
4747
msg = "Visual Studio %s not installed; skipping test.\n" % msvs_version
4848
test.skip_test(msg)
4949

50-
51-
5250
# Let SCons figure out the Visual Studio environment variables for us and
5351
# print out a statement that we can exec to suck them into our external
5452
# environment so we can execute devenv and really try to build something.
5553

56-
test.run(arguments = '-n -q -Q -f -', stdin = """\
57-
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
54+
test.run(arguments='-n -q -Q -f -', stdin="""\
55+
env = Environment(tools=['msvc'], MSVS_VERSION='%(msvs_version)s')
5856
if env.WhereIs('cl'):
5957
print("os.environ.update(%%s)" %% repr(env['ENV']))
6058
""" % locals())
@@ -65,18 +63,18 @@
6563

6664
exec(test.stdout())
6765

68-
69-
7066
test.subdir('sub dir')
71-
7267
test.write(['sub dir', 'SConstruct'], """\
73-
env=Environment(MSVS_VERSION = '%(msvs_version)s')
74-
75-
env.MSVSProject(target = 'foo.vcxproj',
76-
srcs = ['foo.c'],
77-
buildtarget = 'foo.exe',
78-
variant = 'Release',
79-
DebugSettings = {'LocalDebuggerCommandArguments':'echo "<foo.c>" > output.txt'})
68+
DefaultEnvironment(tools=[])
69+
env = Environment(MSVS_VERSION='%(msvs_version)s')
70+
71+
env.MSVSProject(
72+
target='foo.vcxproj',
73+
srcs=['foo.c'],
74+
buildtarget='foo.exe',
75+
variant='Release',
76+
DebugSettings={'LocalDebuggerCommandArguments': 'echo "<foo.c>" > output.txt'},
77+
)
8078
env.Program('foo.c')
8179
""" % locals())
8280

@@ -92,19 +90,21 @@
9290

9391
test.run(chdir='sub dir', arguments='.')
9492

95-
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])
96-
93+
test.unlink_files('sub dir', ['foo' + _exe, 'foo' + _obj, '.sconsign.dblite'])
9794
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
9895

9996
import SCons.Platform.win32
100-
system_dll_path = os.path.join( SCons.Platform.win32.get_system_root(), 'System32' )
97+
98+
system_dll_path = os.path.join(SCons.Platform.win32.get_system_root(), 'System32')
10199
os.environ['PATH'] = os.environ['PATH'] + os.pathsep + system_dll_path
102100

103-
test.run(chdir='sub dir',
104-
program=[test.get_msvs_executable(msvs_version)],
105-
arguments=['foo.sln', '/build', 'Release'])
101+
test.run(
102+
chdir='sub dir',
103+
program=[test.get_msvs_executable(msvs_version)],
104+
arguments=['foo.sln', '/build', 'Release'],
105+
)
106106

107-
test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n")
107+
test.run(program=test.workpath('sub dir', 'foo' + _exe), stdout="foo.c\n")
108108
test.validate_msvs_file(test.workpath('sub dir', 'foo.vcxproj.user'))
109109

110110
test.pass_test()

test/MSVS/vs-14.2-exec.py

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env python
22
#
3-
# __COPYRIGHT__
3+
# MIT License
4+
#
5+
# Copyright The SCons Foundation
46
#
57
# Permission is hereby granted, free of charge, to any person obtaining
68
# a copy of this software and associated documentation files (the
@@ -20,9 +22,6 @@
2022
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2123
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
2224
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23-
#
24-
25-
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
2625

2726
"""
2827
Test that we can actually build a simple program using our generated
@@ -34,6 +33,7 @@
3433
import sys
3534

3635
import TestSConsMSVS
36+
from TestSConsMSVS import _obj, _exe
3737

3838
test = TestSConsMSVS.TestSConsMSVS()
3939

@@ -43,40 +43,38 @@
4343

4444
msvs_version = '14.2'
4545

46-
if not msvs_version in test.msvs_versions():
46+
if msvs_version not in test.msvs_versions():
4747
msg = "Visual Studio %s not installed; skipping test.\n" % msvs_version
4848
test.skip_test(msg)
4949

50-
51-
5250
# Let SCons figure out the Visual Studio environment variables for us and
5351
# print out a statement that we can exec to suck them into our external
5452
# environment so we can execute devenv and really try to build something.
5553

56-
test.run(arguments = '-n -q -Q -f -', stdin = """\
57-
env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s')
54+
test.run(arguments='-n -q -Q -f -', stdin="""\
55+
env = Environment(tools=['msvc'], MSVS_VERSION='%(msvs_version)s')
5856
if env.WhereIs('cl'):
5957
print("os.environ.update(%%s)" %% repr(env['ENV']))
6058
""" % locals())
6159

62-
if(test.stdout() == ""):
60+
if test.stdout() == "":
6361
msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
6462
test.skip_test(msg)
6563

6664
exec(test.stdout())
6765

68-
69-
7066
test.subdir('sub dir')
71-
7267
test.write(['sub dir', 'SConstruct'], """\
73-
env=Environment(MSVS_VERSION = '%(msvs_version)s')
74-
75-
env.MSVSProject(target = 'foo.vcxproj',
76-
srcs = ['foo.c'],
77-
buildtarget = 'foo.exe',
78-
variant = 'Release',
79-
DebugSettings = {'LocalDebuggerCommandArguments':'echo "<foo.c>" > output.txt'})
68+
DefaultEnvironment(tools=[])
69+
env = Environment(MSVS_VERSION='%(msvs_version)s')
70+
71+
env.MSVSProject(
72+
target='foo.vcxproj',
73+
srcs=['foo.c'],
74+
buildtarget='foo.exe',
75+
variant='Release',
76+
DebugSettings={'LocalDebuggerCommandArguments': 'echo "<foo.c>" > output.txt'},
77+
)
8078
env.Program('foo.c')
8179
""" % locals())
8280

@@ -92,22 +90,23 @@
9290

9391
test.run(chdir='sub dir', arguments='.')
9492

95-
test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])
96-
93+
test.unlink_files('sub dir', ['foo' + _exe, 'foo' + _obj, '.sconsign.dblite'])
9794
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))
9895

9996
import SCons.Platform.win32
100-
system_dll_path = os.path.join( SCons.Platform.win32.get_system_root(), 'System32' )
97+
98+
system_dll_path = os.path.join(SCons.Platform.win32.get_system_root(), 'System32')
10199
os.environ['PATH'] = os.environ['PATH'] + os.pathsep + system_dll_path
102100

103-
test.run(chdir='sub dir',
104-
program=[test.get_msvs_executable(msvs_version)],
105-
arguments=['foo.sln', '/build', 'Release'])
101+
test.run(
102+
chdir='sub dir',
103+
program=[test.get_msvs_executable(msvs_version)],
104+
arguments=['foo.sln', '/build', 'Release'],
105+
)
106106

107-
test.run(program=test.workpath('sub dir', 'foo'), stdout="foo.c\n")
107+
test.run(program=test.workpath('sub dir', 'foo' + _exe), stdout="foo.c\n")
108108
test.validate_msvs_file(test.workpath('sub dir', 'foo.vcxproj.user'))
109109

110-
111110
test.pass_test()
112111

113112
# Local Variables:

0 commit comments

Comments
 (0)