Skip to content

Commit 3b7d6bc

Browse files
authored
Merge pull request SCons#4503 from mwichmann/testing/win
Testing framework fixes
2 parents 5f07b5d + 1e32680 commit 3b7d6bc

File tree

10 files changed

+171
-130
lines changed

10 files changed

+171
-130
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
3636
ones in parent NodeInfoBase and can just be inherited.
3737
- Update manpage for Tools, and for TOOL, which also gets a minor
3838
tweak for how it's handled (should be more accurate in a few situations).
39+
- Test framework now uses a subdirectory named "scons" below the base
40+
temporary directory. This gives something invariant to tell antivirus
41+
to ignore without having to exclude tmpdir itself. Fixes #4509.
42+
- MSVS "live" tests of project files adjusted to look for the generated
43+
executable with an exe sufffix
3944
- Documentation build now properly passes through skipping the PDF
4045
(and EPUB) builds of manpage and user guide; this can also be done
4146
manually if directly calling doc/man/SConstruct and doc/user/SConstruct

RELEASE.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ 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.
5454

5555
PACKAGING
5656
---------

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)