Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Fix failing tests for Python 3.11 on MacOS #4252

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion SCons/Variables/PathVariable.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,16 @@ def PathIsDirCreate(key, val, env) -> None:
except FileExistsError as exc:
msg = f'Path for variable {key!r} is a file, not a directory: {val}'
raise SCons.Errors.UserError(msg) from exc
except (PermissionError, OSError) as exc:
except PermissionError:
msg = f'Path for variable {key!r} could not be created: {val}'
raise SCons.Errors.UserError(msg) from exc
except OSError as e:
if e.errno == 30:
# errno == 30 is Read only file system
msg = f'Path for variable {key!r} could not be created: {val}'
raise SCons.Errors.UserError(msg) from exc
else:
raise e

@staticmethod
def PathIsFile(key, val, env) -> None:
Expand Down
16 changes: 15 additions & 1 deletion test/builderrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import os
import subprocess

import TestSCons
import TestCmd

_python_ = TestSCons._python_

Expand Down Expand Up @@ -118,7 +120,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', """
DefaultEnvironment(tools=[]) # test speedup
env=Environment()
Expand Down
7 changes: 3 additions & 4 deletions test/scons-time/run/option/verbose.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,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
Expand Down
5 changes: 4 additions & 1 deletion testing/framework/TestCmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@ def write(self, file, content, mode: str='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.
Expand All @@ -2116,6 +2116,9 @@ def write(self, file, content, mode: str='wb'):
f.write(content)
except TypeError as e:
f.write(bytes(content, 'utf-8'))
finally:
time.sleep(0.03)


# Local Variables:
# tab-width:4
Expand Down
20 changes: 18 additions & 2 deletions testing/framework/TestSCons_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',])

Expand Down Expand Up @@ -236,13 +237,28 @@ 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\\-', f'time\\-[^{sep}]*')
return x

if not IS_MACOS:
return x
else:
return "%s|%s" % (x, y)


def write_fake_scons_py(self) -> None:
self.subdir('scripts')
Expand Down
Loading