Skip to content

Commit 06b3e3c

Browse files
committed
Allow make testios to work for all Apple Mobile platforms.
1 parent 7509ea1 commit 06b3e3c

4 files changed

Lines changed: 25 additions & 9 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Lib/test/data/*
7272
/_bootstrap_python
7373
/Makefile
7474
/Makefile.pre
75+
/AppleTestbed.*
7576
Platforms/Apple/iOS/Frameworks/*
7677
Platforms/Apple/iOS/Resources/Info.plist
7778
Platforms/Apple/testbed/Python*.xcframework/*/bin

‎Makefile.pre.in‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,30 +2298,31 @@ testuniversal: all
22982298
$(RUNSHARED) /usr/libexec/oah/translate \
22992299
./$(BUILDPYTHON) -E -m test -j 0 -u all $(TESTOPTS)
23002300

2301-
# Run the test suite on the iOS simulator. Must be run on a macOS machine with
2302-
# a full Xcode install that has an iPhone SE (3rd edition) simulator available.
2301+
# Run the test suite on an Apple Mobile (i.e., iOS/tvOS/watchOS/visionOS)
2302+
# device simulator. Must be run on a macOS machine with a full Xcode install
2303+
# that has an SE-class simulator available for the chosen platform.
23032304
# This must be run *after* a `make install` has completed the build. The
23042305
# testbed is configured for the framework name used to configure the build;
23052306
# that name is expected to be `Python`, optionally followed by uppercased ABI
23062307
# flags (e.g., `PythonT`).
2307-
XCFOLDER:=iOSTestbed.$(MULTIARCH).$(shell date +%s).$$PPID
2308+
XCFOLDER:=AppleTestbed.$(MULTIARCH).$(shell date +%s).$$PPID
23082309
.PHONY: testios
23092310
testios:
2310-
@if test "$(MACHDEP)" != "ios"; then \
2311-
echo "Cannot run the iOS testbed for a non-iOS build."; \
2311+
@if test "$(MACHDEP)" != "ios" -a "$(MACHDEP)" != "tvos" -a "$(MACHDEP)" != "visionos" -a "$(MACHDEP)" != "watchos" ; then \
2312+
echo "Cannot run the Apple mobile testbed for a $(MACHDEP) build."; \
23122313
exit 1;\
23132314
fi
2314-
@if test "$(findstring -iphonesimulator,$(MULTIARCH))" != "-iphonesimulator"; then \
2315-
echo "Cannot run the iOS testbed for non-simulator builds."; \
2315+
@if test "$(findstring simulator,$(MULTIARCH))" != "simulator"; then \
2316+
echo "Cannot run the Apple mobile testbed for non-simulator builds."; \
23162317
exit 1;\
23172318
fi
23182319
@if ! test -d $(PYTHONFRAMEWORKPREFIX); then \
2319-
echo "Cannot find a finalized iOS Python.framework. Have you run 'make install' to finalize the framework build?"; \
2320+
echo "Cannot find a finalized Python.framework. Have you run 'make install' to finalize the framework build?"; \
23202321
exit 1;\
23212322
fi
23222323

23232324
# Clone the testbed project into the XCFOLDER
2324-
$(PYTHON_FOR_BUILD) $(srcdir)/Platforms/Apple/testbed clone --framework $(PYTHONFRAMEWORKPREFIX) "$(XCFOLDER)"
2325+
$(PYTHON_FOR_BUILD) $(srcdir)/Platforms/Apple/testbed clone --platform $(MACHDEP) --framework $(PYTHONFRAMEWORKPREFIX) "$(XCFOLDER)"
23252326

23262327
# Run the testbed project
23272328
$(PYTHON_FOR_BUILD) "$(XCFOLDER)" run --verbose -- test -uall --single-process --rerun -W --pythoninfo

‎Platforms/Apple/__main__.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@
115115
}
116116

117117

118+
def platform_name(value):
119+
"""Return the canonical spelling for a platform name."""
120+
return {p.lower(): p for p in HOSTS.keys()}.get(value.lower(), value)
121+
122+
118123
def validate_abiflags(value: str) -> str:
119124
"""Validate an `--abiflags` value (for use as an argparse type)."""
120125
known = "".join(ABIFLAG_CONFIGURE_ARGS)
@@ -1054,6 +1059,7 @@ def parse_args() -> argparse.Namespace:
10541059
cmd.add_argument(
10551060
"platform",
10561061
choices=HOSTS.keys(),
1062+
type=platform_name,
10571063
help="The target platform to build",
10581064
)
10591065

‎Platforms/Apple/testbed/__main__.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,12 @@ def main():
489489
if (Path(__file__).parent / f"{platform}Testbed").is_dir()
490490
]
491491

492+
def platform_name(value):
493+
"""Return the canonical spelling for a platform name."""
494+
return {p.lower(): p for p in available_platforms}.get(
495+
value.lower(), value
496+
)
497+
492498
parser = argparse.ArgumentParser(
493499
description=(
494500
"Manages the process of testing an Apple Python project "
@@ -519,6 +525,7 @@ def main():
519525
dest="platform",
520526
choices=available_platforms,
521527
default=available_platforms[0],
528+
type=platform_name,
522529
help=f"The platform to target (default: {available_platforms[0]})",
523530
)
524531
clone.add_argument(
@@ -551,6 +558,7 @@ def main():
551558
dest="platform",
552559
choices=available_platforms,
553560
default=available_platforms[0],
561+
type=platform_name,
554562
help=f"The platform to target (default: {available_platforms[0]})",
555563
)
556564
run.add_argument(

0 commit comments

Comments
 (0)