Skip to content

Commit

Permalink
Merge branch 'master' into jbrill-msvc-batchargs
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbrill committed Jul 18, 2022
2 parents e99127b + c910030 commit da2f846
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 86 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- Added MSVC_USE_SCRIPT_ARGS variable to pass arguments to MSVC_USE_SCRIPT.
- Added Configure.CheckMember() checker to check if struct/class has the specified member.

From Ivan Kravets, PlatformIO:
- Conditional C/C++ Preprocessor: Strip shell's backslashes from the computed include (-DFOO_H=\"foo.h\")

RELEASE 4.3.0 - Tue, 16 Nov 2021 18:12:46 -0700

From Jacob Cassagnol:
Expand Down
3 changes: 3 additions & 0 deletions SCons/cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,9 @@ def resolve_include(self, t):
while not s[0] in '<"':
try:
s = self.cpp_namespace[s]
# strip backslashes from the computed include (-DFOO_H=\"foo.h\")
for c in '<">':
s = s.replace(f"\\{c}", c)
except KeyError:
m = function_name.search(s)

Expand Down
8 changes: 7 additions & 1 deletion SCons/cppTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#include XXX_FILE5
#include XXX_FILE6
#include SHELL_ESCAPED_H
"""


Expand Down Expand Up @@ -441,7 +443,8 @@
class cppTestCase(unittest.TestCase):
def setUp(self):
self.cpp = self.cpp_class(current = ".",
cpppath = ['/usr/include'])
cpppath = ['/usr/include'],
dict={"SHELL_ESCAPED_H": '\\"file-shell-computed-yes\\"'})

def test_basic(self):
"""Test basic #include scanning"""
Expand Down Expand Up @@ -531,6 +534,7 @@ class cppAllTestCase(cppTestCase):
def setUp(self):
self.cpp = self.cpp_class(current = ".",
cpppath = ['/usr/include'],
dict={"SHELL_ESCAPED_H": '\\"file-shell-computed-yes\\"'},
all=1)

class PreProcessorTestCase(cppAllTestCase):
Expand All @@ -546,6 +550,7 @@ class PreProcessorTestCase(cppAllTestCase):
('include', '<', 'file4-yes'),
('include', '"', 'file5-yes'),
('include', '<', 'file6-yes'),
('include', '"', 'file-shell-computed-yes'),
]

ifdef_expect = [
Expand Down Expand Up @@ -647,6 +652,7 @@ class DumbPreProcessorTestCase(cppAllTestCase):
('include', '<', 'file4-yes'),
('include', '"', 'file5-yes'),
('include', '<', 'file6-yes'),
('include', '"', 'file-shell-computed-yes'),
]

ifdef_expect = [
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sphinx_rtd_theme
rst2pdf
# for now keep pinning "known working" lxml,
# it's been a troublesome component in the past.
lxml==4.7.1
lxml==4.9.1
rst2pdf
ninja

Expand Down
9 changes: 4 additions & 5 deletions test/Errors/Exception.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__"

import TestSCons

Expand Down Expand Up @@ -53,7 +52,7 @@ def exit(env, target, source):
# so make sure the proper variations are supported in the following
# regexp.
expect = r"""scons: \*\*\* \[exit.out\] Exception : exit
Traceback \((most recent call|innermost) last\):
Traceback \(most recent call last\):
( File ".+", line \d+, in \S+
[^\n]+
)*( File ".+", line \d+, in \S+
Expand Down
9 changes: 4 additions & 5 deletions test/Errors/InternalError.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__"

"""
Verify the exit status and error output if an SConstruct file
Expand All @@ -41,7 +40,7 @@
""")

test.run(stdout = "scons: Reading SConscript files ...\ninternal error\n",
stderr = r"""Traceback \((most recent call|innermost) last\):
stderr = r"""Traceback \(most recent call last\):
File ".+", line \d+, in .+
File ".+", line \d+, in .+
File ".+", line \d+, in .+
Expand Down
9 changes: 4 additions & 5 deletions test/GetBuildFailures/serial.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,16 +22,13 @@
# 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 the GetBuildFailures() function returns a list of
BuildError exceptions. Also verify printing the BuildError
attributes we expect to be most commonly used.
"""

__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

import TestSCons
import re

Expand Down Expand Up @@ -196,7 +195,7 @@ def print_build_failures():
scons: *** [f13] f13: My SConsEnvironmentError
scons: *** [f14] InternalError : My InternalError
""") + \
r"""Traceback \((most recent call|innermost) last\):
r"""Traceback \(most recent call last\):
( File ".+", line \d+, in \S+
[^\n]+
)*( File ".+", line \d+, in \S+
Expand Down
49 changes: 22 additions & 27 deletions test/exceptions.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__"

import re

Expand All @@ -37,17 +36,18 @@
test.write(SConstruct_path, """\
def func(source = None, target = None, env = None):
raise Exception("func exception")
B = Builder(action = func)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'foo.out', source = 'foo.in')
B = Builder(action=func)
env = Environment(BUILDERS={'B': B})
env.B(target='foo.out', source='foo.in')
""")

test.write('foo.in', "foo.in\n")

expected_stderr = r"""scons: \*\*\* \[foo.out\] Exception : func exception
Traceback \((most recent call|innermost) last\):
Traceback \(most recent call last\):
( File ".+", line \d+, in \S+
[^\n]+
[^\n]+
)*( File ".+", line \d+, in \S+
)*( File ".+", line \d+, in \S+
[^\n]+
Expand All @@ -56,10 +56,8 @@ def func(source = None, target = None, env = None):
Exception: func exception
""" % re.escape(SConstruct_path)

test.run(arguments = "foo.out", stderr = expected_stderr, status = 2)

test.run(arguments = "-j2 foo.out", stderr = expected_stderr, status = 2)

test.run(arguments="foo.out", stderr=expected_stderr, status=2)
test.run(arguments="-j2 foo.out", stderr=expected_stderr, status=2)

# Verify that exceptions caused by exit values of builder actions are
# correctly signalled, for both Serial and Parallel jobs.
Expand All @@ -70,37 +68,36 @@ def func(source = None, target = None, env = None):
""")

test.write(SConstruct_path, """
Fail = Builder(action = r'%(_python_)s myfail.py $TARGETS $SOURCE')
env = Environment(BUILDERS = { 'Fail' : Fail })
env.Fail(target = 'out.f1', source = 'in.f1')
Fail = Builder(action=r'%(_python_)s myfail.py $TARGETS $SOURCE')
env = Environment(BUILDERS={'Fail': Fail})
env.Fail(target='out.f1', source='in.f1')
""" % locals())

test.write('in.f1', "in.f1\n")

expected_stderr = "scons: \\*\\*\\* \\[out.f1\\] Error 1\n"

test.run(arguments = '.', status = 2, stderr = expected_stderr)
test.run(arguments = '-j2 .', status = 2, stderr = expected_stderr)

test.run(arguments='.', status=2, stderr=expected_stderr)
test.run(arguments='-j2 .', status=2, stderr=expected_stderr)

# Verify that all exceptions from simultaneous tasks are reported,
# even if the exception is raised during the Task.prepare()
# [Node.prepare()]

test.write(SConstruct_path, """
Fail = Builder(action = r'%(_python_)s myfail.py $TARGETS $SOURCE')
env = Environment(BUILDERS = { 'Fail' : Fail })
env.Fail(target = 'out.f1', source = 'in.f1')
env.Fail(target = 'out.f2', source = 'in.f2')
env.Fail(target = 'out.f3', source = 'in.f3')
Fail = Builder(action=r'%(_python_)s myfail.py $TARGETS $SOURCE')
env = Environment(BUILDERS={'Fail': Fail})
env.Fail(target='out.f1', source='in.f1')
env.Fail(target='out.f2', source='in.f2')
env.Fail(target='out.f3', source='in.f3')
""" % locals())

# in.f2 is not created to cause a Task.prepare exception
test.write('in.f1', 'in.f1\n')
test.write('in.f3', 'in.f3\n')

# In Serial task mode, get the first exception and stop
test.run(arguments = '.', status = 2, stderr = expected_stderr)
test.run(arguments='.', status=2, stderr=expected_stderr)

# In Parallel task mode, we will get all three exceptions.

Expand All @@ -117,11 +114,9 @@ def func(source = None, target = None, env = None):
# walk of '.' and are already considered up-to-date when we kick off the
# "simultaneous" builds of the output (target) files.

test.run(arguments = '-j7 -k .', status = 2, stderr = None)

test.run(arguments='-j7 -k .', status=2, stderr=None)
test.must_contain_all_lines(test.stderr(), expected_stderr_list)


test.pass_test()

# Local Variables:
Expand Down
52 changes: 11 additions & 41 deletions test/option/debug-stacktrace.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 the --debug=stacktrace option.
Expand All @@ -34,37 +33,27 @@

test.write('SConstruct', """\
DefaultEnvironment(tools=[])
def kfile_scan(node, env, target):
raise Exception("kfile_scan error")
kscan = Scanner(name = 'kfile',
function = kfile_scan,
skeys = ['.k'])
kscan = Scanner(name='kfile', function=kfile_scan, skeys=['.k'])
env = Environment(tools=[])
env.Append(SCANNERS = [kscan])
env.Command('foo', 'foo.k', Copy('$TARGET', '$SOURCE'))
""")

test.write('foo.k', "foo.k\n")

test.run(status = 2, stderr = "scons: *** [foo] Exception : kfile_scan error\n")

test.run(arguments = "--debug=stacktrace",
status = 2,
stderr = None)

test.run(arguments="--debug=stacktrace", status=2, stderr=None)
lines = [
"scons: *** [foo] Exception : kfile_scan error",
"scons: internal stack trace:",
'raise Exception("kfile_scan error")',
]

test.must_contain_all_lines(test.stderr(), lines)



# Test that --debug=stacktrace works for UserError exceptions,
# which are handled by different code than other exceptions.

Expand All @@ -73,44 +62,25 @@ def kfile_scan(node, env, target):
raise SCons.Errors.UserError("explicit UserError!")
""")

test.run(arguments = '--debug=stacktrace',
status = 2,
stderr = None)

test.run(arguments='--debug=stacktrace', status=2, stderr=None)
user_error_lines = [
'UserError: explicit UserError!',
'scons: *** explicit UserError!',
]

# The "(most recent call last)" message is used by more recent Python
# versions than the "(innermost last)" message, so that's the one
# we report if neither matches.
traceback_lines = [
"Traceback (most recent call last)",
"Traceback (innermost last)",
]

traceback_lines = ["Traceback (most recent call last)",]
test.must_contain_all_lines(test.stderr(), user_error_lines)
test.must_contain_any_line(test.stderr(), traceback_lines)
test.must_contain_all_lines(test.stderr(), traceback_lines)

# Test that full path names to SConscript files show up in stack traces.

test.write('SConstruct', """\
1/0
""")

test.run(arguments = '--debug=stacktrace',
status = 2,
stderr = None)

lines = [
' File "%s", line 1:' % test.workpath('SConstruct'),
]

test.run(arguments='--debug=stacktrace', status=2, stderr=None)
lines = [' File "%s", line 1:' % test.workpath('SConstruct'),]
test.must_contain_all_lines(test.stderr(), lines)



test.pass_test()

# Local Variables:
Expand Down
Loading

0 comments on commit da2f846

Please sign in to comment.