From d9192dbf0c4380043759262147e6e06b0caf590e Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Wed, 6 Jul 2022 15:34:59 +0300 Subject: [PATCH 1/4] Conditional C/C++ Preprocessor: Strip shell's backslashes from the computed include (-DFOO_H=\"foo.h\") --- CHANGES.txt | 3 +++ SCons/cpp.py | 3 +++ SCons/cppTests.py | 8 +++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index bea5838176..b516ff23de 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -207,6 +207,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: diff --git a/SCons/cpp.py b/SCons/cpp.py index 353aa70a51..144f49870f 100644 --- a/SCons/cpp.py +++ b/SCons/cpp.py @@ -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) diff --git a/SCons/cppTests.py b/SCons/cppTests.py index f20c302c16..f781e81b0a 100644 --- a/SCons/cppTests.py +++ b/SCons/cppTests.py @@ -55,6 +55,8 @@ #include XXX_FILE5 #include XXX_FILE6 + +#include SHELL_ESCAPED_H """ @@ -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""" @@ -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): @@ -546,6 +550,7 @@ class PreProcessorTestCase(cppAllTestCase): ('include', '<', 'file4-yes'), ('include', '"', 'file5-yes'), ('include', '<', 'file6-yes'), + ('include', '"', 'file-shell-computed-yes'), ] ifdef_expect = [ @@ -647,6 +652,7 @@ class DumbPreProcessorTestCase(cppAllTestCase): ('include', '<', 'file4-yes'), ('include', '"', 'file5-yes'), ('include', '<', 'file6-yes'), + ('include', '"', 'file-shell-computed-yes'), ] ifdef_expect = [ From 95a73c7d7978684073e942de6ee2e650d62aadf0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Jul 2022 20:46:32 +0000 Subject: [PATCH 2/4] Bump lxml from 4.7.1 to 4.9.1 Bumps [lxml](https://github.com/lxml/lxml) from 4.7.1 to 4.9.1. - [Release notes](https://github.com/lxml/lxml/releases) - [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt) - [Commits](https://github.com/lxml/lxml/compare/lxml-4.7.1...lxml-4.9.1) --- updated-dependencies: - dependency-name: lxml dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e05c610246..133b5bd911 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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 From cc23b57dd458985cadaed93c4b0da00f8f5eba88 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Fri, 8 Jul 2022 08:14:47 -0600 Subject: [PATCH 3/4] [Test] drop old exception msgs Minor maintenance to drop a regex group in a few tests (including in a test framework test) which allowed for two different exception messages: one belongs to very old Pythons which are no longer supported by SCons. Signed-off-by: Mats Wichmann --- test/Errors/Exception.py | 9 +++-- test/Errors/InternalError.py | 9 +++-- test/GetBuildFailures/serial.py | 9 +++-- test/exceptions.py | 48 +++++++++++-------------- test/option/debug-stacktrace.py | 52 ++++++---------------------- testing/framework/TestCommonTests.py | 2 +- 6 files changed, 45 insertions(+), 84 deletions(-) diff --git a/test/Errors/Exception.py b/test/Errors/Exception.py index c08a09ee12..cdd6a3c5ec 100644 --- a/test/Errors/Exception.py +++ b/test/Errors/Exception.py @@ -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 @@ -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 @@ -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+ diff --git a/test/Errors/InternalError.py b/test/Errors/InternalError.py index a70959730e..d37178e192 100644 --- a/test/Errors/InternalError.py +++ b/test/Errors/InternalError.py @@ -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 @@ -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 @@ -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 .+ diff --git a/test/GetBuildFailures/serial.py b/test/GetBuildFailures/serial.py index 4aecc12651..ab8fbb5946 100644 --- a/test/GetBuildFailures/serial.py +++ b/test/GetBuildFailures/serial.py @@ -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 @@ -20,7 +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. -# """ Verify that the GetBuildFailures() function returns a list of @@ -28,8 +29,6 @@ attributes we expect to be most commonly used. """ -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - import TestSCons import re @@ -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+ diff --git a/test/exceptions.py b/test/exceptions.py index 79d869c430..0f26b14c29 100644 --- a/test/exceptions.py +++ b/test/exceptions.py @@ -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 @@ -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 @@ -37,15 +36,15 @@ 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]+ )*( File ".+", line \d+, in \S+ @@ -56,10 +55,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. @@ -70,29 +67,28 @@ 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 @@ -100,7 +96,7 @@ def func(source = None, target = None, env = None): 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. @@ -117,11 +113,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: diff --git a/test/option/debug-stacktrace.py b/test/option/debug-stacktrace.py index 490fecfe01..f0f92c1131 100644 --- a/test/option/debug-stacktrace.py +++ b/test/option/debug-stacktrace.py @@ -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 @@ -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. @@ -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. @@ -73,25 +62,14 @@ 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. @@ -99,18 +77,10 @@ def kfile_scan(node, env, target): 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: diff --git a/testing/framework/TestCommonTests.py b/testing/framework/TestCommonTests.py index c8ea13095c..1f8db42144 100644 --- a/testing/framework/TestCommonTests.py +++ b/testing/framework/TestCommonTests.py @@ -1943,7 +1943,7 @@ def raise_exception(*args, **kw): expect_stderr = lstrip("""\ Exception trying to execute: \\[%s, '[^']*pass'\\] - Traceback \\((innermost|most recent call) last\\): + Traceback \\(most recent call last\\): File "", line \\d+, in (\\?|) File "[^"]+TestCommon.py", line \\d+, in run TestCmd.run\\(self, \\*\\*kw\\) From f5f093eff6abe57492f5e48978553d3f2998b046 Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Wed, 13 Jul 2022 07:54:41 -0600 Subject: [PATCH 4/4] Ajust test for 3.11+ enhanced error messages There were four tests failing because the regexes for expected stdout didn't match with the addition of pointers in exceptions showing where the error occurs. However, with 3.11.0b4, this has been backed off a bit: there are no arrow lines if the whole line would have been highlighted, since that adds no useful new information. As a result, only one test now failed, and the regex there is expanded to handle that case. This relates to, but does not close, issue #4162. Signed-off-by: Mats Wichmann --- test/exceptions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/exceptions.py b/test/exceptions.py index 0f26b14c29..842959abac 100644 --- a/test/exceptions.py +++ b/test/exceptions.py @@ -47,6 +47,7 @@ def func(source = None, target = None, env = None): Traceback \(most recent call last\): ( File ".+", line \d+, in \S+ [^\n]+ + [^\n]+ )*( File ".+", line \d+, in \S+ )*( File ".+", line \d+, in \S+ [^\n]+