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

Remove script path in PlatformTests #4381

Merged
merged 1 commit into from
Jul 21, 2023
Merged
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
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
- Cleaned up dblite module (checker warnings, etc.).
- Some cleanup in the FortranCommon tool.
- Changed the message about scons -H to clarify it shows built-in options.
- Fix platform unit test on Windows for Py 3.12+. Fixes #4376.

From Jonathon Reinhart:
- Fix another instance of `int main()` in CheckLib() causing failures
Expand Down
25 changes: 17 additions & 8 deletions SCons/Platform/PlatformTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# TODO: issue #4376: since Python 3.12, CPython's posixpath.py does a test
# import of 'posix', expecting it to fail on win32. However, if
# SCons/Platform is in sys.path, it will find our posix module instead.
# This happens in this unittest, since it's the script path. Remove
# it before the stdlib imports. Better way to handle this problem?
import sys
if 'Platform' in sys.path[0]:
platpath = sys.path.pop(0)
# pylint: disable=wrong-import-position
import collections
import unittest
import os
Expand All @@ -30,6 +39,7 @@
import SCons.Platform
import SCons.Environment
import SCons.Action
# pylint: enable=wrong-import-position


class Environment(collections.UserDict):
Expand Down Expand Up @@ -130,7 +140,7 @@ def test_Platform(self) -> None:

env = Environment()
SCons.Platform.Platform()(env)
assert env != {}, env
assert env, env

def test_win32_no_arch_shell_variables(self) -> None:
"""
Expand All @@ -143,9 +153,9 @@ def test_win32_no_arch_shell_variables(self) -> None:
PA_6432 = os.environ.get('PROCESSOR_ARCHITEW6432')
PA = os.environ.get('PROCESSOR_ARCHITECTURE')
if PA_6432:
del(os.environ['PROCESSOR_ARCHITEW6432'])
del os.environ['PROCESSOR_ARCHITEW6432']
if PA:
del(os.environ['PROCESSOR_ARCHITECTURE'])
del os.environ['PROCESSOR_ARCHITECTURE']

p = SCons.Platform.win32.get_architecture()

Expand Down Expand Up @@ -301,17 +311,16 @@ def __init__(self) -> None:

class PlatformEscapeTestCase(unittest.TestCase):
def test_posix_escape(self) -> None:
""" Check that paths with parens are escaped properly
"""
import SCons.Platform.posix
"""Check that paths with parens are escaped properly."""
from SCons.Platform.posix import escape # pylint: disable=import-outside-toplevel

test_string = "/my (really) great code/main.cpp"
output = SCons.Platform.posix.escape(test_string)
output = escape(test_string)

# We expect the escape function to wrap the string
# in quotes, but not escape any internal characters
# in the test_string. (Parens doesn't require shell
# escaping if their quoted)
# escaping if they are quoted)
assert output[1:-1] == test_string


Expand Down