From 58c322ac780157f71136ad5ab296f46351e4dbfa Mon Sep 17 00:00:00 2001 From: William Deegan Date: Wed, 26 Oct 2022 11:20:54 -0700 Subject: [PATCH 1/4] Fix PathIsDirCreate() for python 3.11 on MacOS Catalina(at least) --- SCons/Variables/PathVariable.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/SCons/Variables/PathVariable.py b/SCons/Variables/PathVariable.py index a5bf6c59f2..f7ffa6aed5 100644 --- a/SCons/Variables/PathVariable.py +++ b/SCons/Variables/PathVariable.py @@ -109,6 +109,13 @@ def PathIsDirCreate(key, val, env) -> None: except PermissionError: m = 'Path for option %s could not be created: %s' raise SCons.Errors.UserError(m % (key, val)) + except OSError as e: + if e.errno == 30: + # errno == 30 is Read only file system + m = 'Path for option %s could not be created: %s' + raise SCons.Errors.UserError(m % (key, val)) + else: + raise e @staticmethod def PathIsFile(key, val, env) -> None: From bda703f8303aedbacb71537d944b53ceaaf75c54 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 28 Oct 2022 16:41:37 -0700 Subject: [PATCH 2/4] fix test/builderrors.py to properly fail with too long commandline by querying getconf ARG_MAX to find out actual limit and create arg longer than that, left default at previous lenght which was hardcoded --- test/builderrors.py | 22 +++++++++++++++++++--- testing/framework/TestCmd.py | 5 ++++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/test/builderrors.py b/test/builderrors.py index 635f448b4d..97958ef513 100644 --- a/test/builderrors.py +++ b/test/builderrors.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 @@ -21,11 +23,13 @@ # 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 os +import subprocess import TestSCons +import TestCmd _python_ = TestSCons._python_ @@ -114,7 +118,19 @@ # Test ETOOLONG (arg list too long). This is not in exitvalmap, # but that shouldn't cause a scons traceback. -long_cmd = 'xyz ' + "foobarxyz" * 100000 +# For Posix systems should use: getconf ARG_MAX to find max line length and ensure the +# command line generated is longer than that to force failure. +if TestCmd.IS_MACOS: + max_length = subprocess.check_output(['getconf', 'ARG_MAX']) + max_length = int(max_length) +else: + # Previous value + max_length = 900004 + +arg_1 = 'foobarxyz' +arg_mult = (max_length // len(arg_1)) + 1 + +long_cmd = 'xyz ' + "foobarxyz" * arg_mult test.write('SConstruct', """ env=Environment() env.Command(target='longcmd.out', source=[], action='echo %s') diff --git a/testing/framework/TestCmd.py b/testing/framework/TestCmd.py index 812314db9a..e21b9b0657 100644 --- a/testing/framework/TestCmd.py +++ b/testing/framework/TestCmd.py @@ -2069,7 +2069,7 @@ def write(self, file, content, mode='wb'): The file is created under the temporary working directory. Any subdirectories in the path must already exist. The write is converted to the required type rather than failing - if there is a str/bytes mistmatch. + if there is a str/bytes mismatch. :param file: name of file to write to. If a list, treated as components of a path and concatenated into a path. @@ -2087,6 +2087,9 @@ def write(self, file, content, mode='wb'): f.write(content) except TypeError as e: f.write(bytes(content, 'utf-8')) + finally: + time.sleep(0.03) + # Local Variables: # tab-width:4 From cb7d1b510684c08884b1822a112112158dcc8fbc Mon Sep 17 00:00:00 2001 From: William Deegan Date: Fri, 28 Oct 2022 17:05:49 -0700 Subject: [PATCH 3/4] Fix test/scons-time/run/option/verbose.py for macOS. For some reason this test is not consistently getting the path from tempdir or the realpath() of that, so create a regex with both (only for macOS) --- test/scons-time/run/option/verbose.py | 7 +++---- testing/framework/TestSCons_time.py | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/test/scons-time/run/option/verbose.py b/test/scons-time/run/option/verbose.py index bf8d48f627..80d61e19f2 100644 --- a/test/scons-time/run/option/verbose.py +++ b/test/scons-time/run/option/verbose.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,13 +22,10 @@ # 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 run -v and --verbose options display command output. """ -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import sys import re diff --git a/testing/framework/TestSCons_time.py b/testing/framework/TestSCons_time.py index e647fe2c21..6294f3702b 100644 --- a/testing/framework/TestSCons_time.py +++ b/testing/framework/TestSCons_time.py @@ -42,6 +42,7 @@ from TestCommon import __all__ # some of the scons_time tests may need regex-based matching: from TestSCons import search_re, search_re_in_list +from TestCmd import IS_MACOS __all__.extend(['TestSCons_time',]) @@ -238,13 +239,27 @@ def tempdir_re(self, *args): except AttributeError: pass else: - tempdir = realpath(tempdir) + tempdir_r = realpath(tempdir) + + # On MacOS for some reason tests are not consistently getting the realpath + # So create an regex with realpath and the path we get from tempdir + if not IS_MACOS: + tempdir = tempdir_r + else: + args_r = (tempdir_r, 'scons-time-',) + args + y = os.path.join(*args_r) + y = re.escape(y) + y = y.replace('time\\-', 'time\\-[^%s]*' % sep) args = (tempdir, 'scons-time-',) + args x = os.path.join(*args) x = re.escape(x) x = x.replace('time\\-', 'time\\-[^%s]*' % sep) - return x + + if not IS_MACOS: + return x + else: + return "%s|%s"%(x,y) def write_fake_scons_py(self): self.subdir('scripts') From 4c263c2d5c1e452d6f54e9d26fce15aacc3d2ed2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sat, 29 Oct 2022 18:28:19 -0700 Subject: [PATCH 4/4] [ci skip] Fix sider complaint --- testing/framework/TestSCons_time.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/framework/TestSCons_time.py b/testing/framework/TestSCons_time.py index 6294f3702b..2fdbd1a20d 100644 --- a/testing/framework/TestSCons_time.py +++ b/testing/framework/TestSCons_time.py @@ -259,7 +259,7 @@ def tempdir_re(self, *args): if not IS_MACOS: return x else: - return "%s|%s"%(x,y) + return "%s|%s" % (x, y) def write_fake_scons_py(self): self.subdir('scripts')