Skip to content

Commit

Permalink
Merge pull request #4503 from mwichmann/testing/win
Browse files Browse the repository at this point in the history
Testing framework fixes
  • Loading branch information
bdbaddog authored May 4, 2024
2 parents 5f07b5d + 1e32680 commit 3b7d6bc
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 130 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
ones in parent NodeInfoBase and can just be inherited.
- Update manpage for Tools, and for TOOL, which also gets a minor
tweak for how it's handled (should be more accurate in a few situations).
- Test framework now uses a subdirectory named "scons" below the base
temporary directory. This gives something invariant to tell antivirus
to ignore without having to exclude tmpdir itself. Fixes #4509.
- MSVS "live" tests of project files adjusted to look for the generated
executable with an exe sufffix
- Documentation build now properly passes through skipping the PDF
(and EPUB) builds of manpage and user guide; this can also be done
manually if directly calling doc/man/SConstruct and doc/user/SConstruct
Expand Down
6 changes: 3 additions & 3 deletions RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ FIXES
IMPROVEMENTS
------------

- List improvements that wouldn't be visible to the user in the
documentation: performance improvements (describe the circumstances
under which they would be observed), or major code cleanups
- Make the testing framework a little more resilient: the temporary
directory for tests now includes a component named "scons" which can
be given to antivirus software to exclude.

PACKAGING
---------
Expand Down
53 changes: 26 additions & 27 deletions test/MSVS/vs-14.0-exec.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__"

"""
Test that we can actually build a simple program using our generated
Expand All @@ -34,6 +33,7 @@
import sys

import TestSConsMSVS
from TestSConsMSVS import _obj, _exe

test = TestSConsMSVS.TestSConsMSVS()

Expand All @@ -43,18 +43,16 @@

msvs_version = '14.0'

if not msvs_version in test.msvs_versions():
if msvs_version not in test.msvs_versions():
msg = "Visual Studio %s not installed; skipping test.\n" % msvs_version
test.skip_test(msg)



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

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

exec(test.stdout())



test.subdir('sub dir')

test.write(['sub dir', 'SConstruct'], """\
env=Environment(MSVS_VERSION = '%(msvs_version)s')
env.MSVSProject(target = 'foo.vcxproj',
srcs = ['foo.c'],
buildtarget = 'foo.exe',
variant = 'Release',
DebugSettings = {'LocalDebuggerCommandArguments':'echo "<foo.c>" > output.txt'})
DefaultEnvironment(tools=[])
env = Environment(MSVS_VERSION='%(msvs_version)s')
env.MSVSProject(
target='foo.vcxproj',
srcs=['foo.c'],
buildtarget='foo.exe',
variant='Release',
DebugSettings={'LocalDebuggerCommandArguments': 'echo "<foo.c>" > output.txt'},
)
env.Program('foo.c')
""" % locals())

Expand All @@ -92,22 +90,23 @@

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

test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.unlink_files('sub dir', ['foo' + _exe, 'foo' + _obj, '.sconsign.dblite'])
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))

import SCons.Platform.win32
system_dll_path = os.path.join( SCons.Platform.win32.get_system_root(), 'System32' )

system_dll_path = os.path.join(SCons.Platform.win32.get_system_root(), 'System32')
os.environ['PATH'] = os.environ['PATH'] + os.pathsep + system_dll_path

test.run(chdir='sub dir',
program=[test.get_msvs_executable(msvs_version)],
arguments=['foo.sln', '/build', 'Release'])
test.run(
chdir='sub dir',
program=[test.get_msvs_executable(msvs_version)],
arguments=['foo.sln', '/build', 'Release'],
)

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


test.pass_test()

# Local Variables:
Expand Down
52 changes: 26 additions & 26 deletions test/MSVS/vs-14.1-exec.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,20 +22,18 @@
# 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 we can actually build a simple program using our generated
Visual Studio 14.1 project (.vcxproj) and solution (.sln) files
Visual Studio 14.0 project (.vcxproj) and solution (.sln) files
using Visual Studio 14.1 (Professional edition).
"""

import os
import sys

import TestSConsMSVS
from TestSConsMSVS import _obj, _exe

test = TestSConsMSVS.TestSConsMSVS()

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



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

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

exec(test.stdout())



test.subdir('sub dir')

test.write(['sub dir', 'SConstruct'], """\
env=Environment(MSVS_VERSION = '%(msvs_version)s')
env.MSVSProject(target = 'foo.vcxproj',
srcs = ['foo.c'],
buildtarget = 'foo.exe',
variant = 'Release',
DebugSettings = {'LocalDebuggerCommandArguments':'echo "<foo.c>" > output.txt'})
DefaultEnvironment(tools=[])
env = Environment(MSVS_VERSION='%(msvs_version)s')
env.MSVSProject(
target='foo.vcxproj',
srcs=['foo.c'],
buildtarget='foo.exe',
variant='Release',
DebugSettings={'LocalDebuggerCommandArguments': 'echo "<foo.c>" > output.txt'},
)
env.Program('foo.c')
""" % locals())

Expand All @@ -92,19 +90,21 @@

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

test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.unlink_files('sub dir', ['foo' + _exe, 'foo' + _obj, '.sconsign.dblite'])
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))

import SCons.Platform.win32
system_dll_path = os.path.join( SCons.Platform.win32.get_system_root(), 'System32' )

system_dll_path = os.path.join(SCons.Platform.win32.get_system_root(), 'System32')
os.environ['PATH'] = os.environ['PATH'] + os.pathsep + system_dll_path

test.run(chdir='sub dir',
program=[test.get_msvs_executable(msvs_version)],
arguments=['foo.sln', '/build', 'Release'])
test.run(
chdir='sub dir',
program=[test.get_msvs_executable(msvs_version)],
arguments=['foo.sln', '/build', 'Release'],
)

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

test.pass_test()
Expand Down
55 changes: 27 additions & 28 deletions test/MSVS/vs-14.2-exec.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__"

"""
Test that we can actually build a simple program using our generated
Expand All @@ -34,6 +33,7 @@
import sys

import TestSConsMSVS
from TestSConsMSVS import _obj, _exe

test = TestSConsMSVS.TestSConsMSVS()

Expand All @@ -43,40 +43,38 @@

msvs_version = '14.2'

if not msvs_version in test.msvs_versions():
if msvs_version not in test.msvs_versions():
msg = "Visual Studio %s not installed; skipping test.\n" % msvs_version
test.skip_test(msg)



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

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

if(test.stdout() == ""):
if test.stdout() == "":
msg = "Visual Studio %s missing cl.exe; skipping test.\n" % msvs_version
test.skip_test(msg)

exec(test.stdout())



test.subdir('sub dir')

test.write(['sub dir', 'SConstruct'], """\
env=Environment(MSVS_VERSION = '%(msvs_version)s')
env.MSVSProject(target = 'foo.vcxproj',
srcs = ['foo.c'],
buildtarget = 'foo.exe',
variant = 'Release',
DebugSettings = {'LocalDebuggerCommandArguments':'echo "<foo.c>" > output.txt'})
DefaultEnvironment(tools=[])
env = Environment(MSVS_VERSION='%(msvs_version)s')
env.MSVSProject(
target='foo.vcxproj',
srcs=['foo.c'],
buildtarget='foo.exe',
variant='Release',
DebugSettings={'LocalDebuggerCommandArguments': 'echo "<foo.c>" > output.txt'},
)
env.Program('foo.c')
""" % locals())

Expand All @@ -92,22 +90,23 @@

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

test.unlink_files('sub dir', ['foo.exe', 'foo.obj', '.sconsign.dblite'])

test.unlink_files('sub dir', ['foo' + _exe, 'foo' + _obj, '.sconsign.dblite'])
test.vcproj_sys_path(test.workpath('sub dir', 'foo.vcxproj'))

import SCons.Platform.win32
system_dll_path = os.path.join( SCons.Platform.win32.get_system_root(), 'System32' )

system_dll_path = os.path.join(SCons.Platform.win32.get_system_root(), 'System32')
os.environ['PATH'] = os.environ['PATH'] + os.pathsep + system_dll_path

test.run(chdir='sub dir',
program=[test.get_msvs_executable(msvs_version)],
arguments=['foo.sln', '/build', 'Release'])
test.run(
chdir='sub dir',
program=[test.get_msvs_executable(msvs_version)],
arguments=['foo.sln', '/build', 'Release'],
)

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


test.pass_test()

# Local Variables:
Expand Down
Loading

0 comments on commit 3b7d6bc

Please sign in to comment.