gh-114099 - Add iOS testbed, plus Makefile target to invoke it. (gh-1… · adqm/cpython@b33980a · GitHub
Skip to content

Commit b33980a

Browse files
authored
pythongh-114099 - Add iOS testbed, plus Makefile target to invoke it. (pythongh-115930)
1 parent bc708c7 commit b33980a

21 files changed

Lines changed: 1195 additions & 126 deletions

File tree

.gitignore

Lines changed: 10 additions & 0 deletions

Makefile.pre.in

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,42 @@ testuniversal: all
19931993
$(RUNSHARED) /usr/libexec/oah/translate \
19941994
./$(BUILDPYTHON) -E -m test -j 0 -u all $(TESTOPTS)
19951995

1996+
# Run the test suite on the iOS simulator. Must be run on a macOS machine with
1997+
# a full Xcode install that has an iPhone SE (3rd edition) simulator available.
1998+
# This must be run *after* a `make install` has completed the build. The
1999+
# `--with-framework-name` argument *cannot* be used when configuring the build.
2000+
XCFOLDER=iOSTestbed.$(MULTIARCH).$(shell date +%s)
2001+
XCRESULT=$(XCFOLDER)/$(MULTIARCH).xcresult
2002+
.PHONY: testios
2003+
testios:
2004+
@if test "$(MACHDEP)" != "ios"; then \
2005+
echo "Cannot run the iOS testbed for a non-iOS build."; \
2006+
exit 1;\
2007+
fi
2008+
@if test "$(findstring -iphonesimulator,$(MULTIARCH))" != "-iphonesimulator"; then \
2009+
echo "Cannot run the iOS testbed for non-simulator builds."; \
2010+
exit 1;\
2011+
fi
2012+
@if test $(PYTHONFRAMEWORK) != "Python"; then \
2013+
echo "Cannot run the iOS testbed with a non-default framework name."; \
2014+
exit 1;\
2015+
fi
2016+
@if ! test -d $(PYTHONFRAMEWORKPREFIX); then \
2017+
echo "Cannot find a finalized iOS Python.framework. Have you run 'make install' to finalize the framework build?"; \
2018+
exit 1;\
2019+
fi
2020+
# Copy the testbed project into the build folder
2021+
cp -r $(srcdir)/iOS/testbed $(XCFOLDER)
2022+
# Copy the framework from the install location to the testbed project.
2023+
cp -r $(PYTHONFRAMEWORKPREFIX)/* $(XCFOLDER)/Python.xcframework/ios-arm64_x86_64-simulator
2024+
# Run the test suite for the Xcode project, targeting the iOS simulator.
2025+
# If the suite fails, extract and print the console output, then re-raise the failure
2026+
if ! xcodebuild test -project $(XCFOLDER)/iOSTestbed.xcodeproj -scheme "iOSTestbed" -destination "platform=iOS Simulator,name=iPhone SE (3rd Generation)" -resultBundlePath $(XCRESULT) ; then \
2027+
xcrun xcresulttool get --path $(XCRESULT) --id $$(xcrun xcresulttool get --path $(XCRESULT) --format json | $(PYTHON_FOR_BUILD) -c "import sys, json; result = json.load(sys.stdin); print(result['actions']['_values'][0]['actionResult']['logRef']['id']['_value'])"); \
2028+
echo ; \
2029+
exit 1; \
2030+
fi
2031+
19962032
# Like test, but using --slow-ci which enables all test resources and use
19972033
# longer timeout. Run an optional pybuildbot.identify script to include
19982034
# information about the build environment.
@@ -2712,7 +2748,7 @@ frameworkinstallextras:
27122748
# subdirectory. The install has put these folders in the same folder as
27132749
# Python.framework; Move the headers to their final framework-compatible home.
27142750
.PHONY: frameworkinstallmobileheaders
2715-
frameworkinstallmobileheaders:
2751+
frameworkinstallmobileheaders: frameworkinstallunversionedstructure inclinstall
27162752
if test -d $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers; then \
27172753
echo "Removing old framework headers"; \
27182754
rm -rf $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers; \
@@ -2847,6 +2883,10 @@ clean-retain-profile: pycremoval
28472883
-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
28482884
-rm -f Include/pydtrace_probes.h
28492885
-rm -f profile-gen-stamp
2886+
-rm -rf iOS/testbed/Python.xcframework/ios-*/bin
2887+
-rm -rf iOS/testbed/Python.xcframework/ios-*/lib
2888+
-rm -rf iOS/testbed/Python.xcframework/ios-*/include
2889+
-rm -rf iOS/testbed/Python.xcframework/ios-*/Python.framework
28502890

28512891
.PHONY: profile-removal
28522892
profile-removal:
@@ -2872,6 +2912,8 @@ clobber: clean
28722912
config.cache config.log pyconfig.h Modules/config.c
28732913
-rm -rf build platform
28742914
-rm -rf $(PYTHONFRAMEWORKDIR)
2915+
-rm -rf iOS/Frameworks
2916+
-rm -rf iOSTestbed.*
28752917
-rm -f python-config.py python-config
28762918
-rm -rf cross-build
28772919

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A testbed project was added to run the test suite on iOS.

Modules/_testexternalinspection.c

Lines changed: 7 additions & 4 deletions

configure

Lines changed: 98 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)