Skip to content

Commit 99e7ae4

Browse files
committed
[3.11] pythongh-114099 - Add iOS testbed, plus Makefile target to invoke it. (pythongh-115930)
1 parent 91e262a commit 99e7ae4

File tree

20 files changed

+1188
-122
lines changed

20 files changed

+1188
-122
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,17 @@ Lib/test/data/*
6565
/_bootstrap_python
6666
/Makefile
6767
/Makefile.pre
68+
iOSTestbed.*
69+
iOS/Frameworks/
6870
iOS/Resources/Info.plist
71+
iOS/testbed/build
72+
iOS/testbed/Python.xcframework/ios-*/bin
73+
iOS/testbed/Python.xcframework/ios-*/include
74+
iOS/testbed/Python.xcframework/ios-*/lib
75+
iOS/testbed/Python.xcframework/ios-*/Python.framework
76+
iOS/testbed/iOSTestbed.xcodeproj/project.xcworkspace
77+
iOS/testbed/iOSTestbed.xcodeproj/xcuserdata
78+
iOS/testbed/iOSTestbed.xcodeproj/xcshareddata
6979
Mac/Makefile
7080
Mac/PythonLauncher/Info.plist
7181
Mac/PythonLauncher/Makefile

Makefile.pre.in

+43-1
Original file line numberDiff line numberDiff line change
@@ -1729,6 +1729,42 @@ testuniversal: all
17291729
$(RUNSHARED) /usr/libexec/oah/translate \
17301730
./$(BUILDPYTHON) -E -m test -j 0 -u all $(TESTOPTS)
17311731

1732+
# Run the test suite on the iOS simulator. Must be run on a macOS machine with
1733+
# a full Xcode install that has an iPhone SE (3rd edition) simulator available.
1734+
# This must be run *after* a `make install` has completed the build. The
1735+
# `--with-framework-name` argument *cannot* be used when configuring the build.
1736+
XCFOLDER=iOSTestbed.$(MULTIARCH).$(shell date +%s)
1737+
XCRESULT=$(XCFOLDER)/$(MULTIARCH).xcresult
1738+
.PHONY: testios
1739+
testios:
1740+
@if test "$(MACHDEP)" != "ios"; then \
1741+
echo "Cannot run the iOS testbed for a non-iOS build."; \
1742+
exit 1;\
1743+
fi
1744+
@if test "$(findstring -iphonesimulator,$(MULTIARCH))" != "-iphonesimulator"; then \
1745+
echo "Cannot run the iOS testbed for non-simulator builds."; \
1746+
exit 1;\
1747+
fi
1748+
@if test $(PYTHONFRAMEWORK) != "Python"; then \
1749+
echo "Cannot run the iOS testbed with a non-default framework name."; \
1750+
exit 1;\
1751+
fi
1752+
@if ! test -d $(PYTHONFRAMEWORKPREFIX); then \
1753+
echo "Cannot find a finalized iOS Python.framework. Have you run 'make install' to finalize the framework build?"; \
1754+
exit 1;\
1755+
fi
1756+
# Copy the testbed project into the build folder
1757+
cp -r $(srcdir)/iOS/testbed $(XCFOLDER)
1758+
# Copy the framework from the install location to the testbed project.
1759+
cp -r $(PYTHONFRAMEWORKPREFIX)/* $(XCFOLDER)/Python.xcframework/ios-arm64_x86_64-simulator
1760+
# Run the test suite for the Xcode project, targeting the iOS simulator.
1761+
# If the suite fails, extract and print the console output, then re-raise the failure
1762+
if ! xcodebuild test -project $(XCFOLDER)/iOSTestbed.xcodeproj -scheme "iOSTestbed" -destination "platform=iOS Simulator,name=iPhone SE (3rd Generation)" -resultBundlePath $(XCRESULT) ; then \
1763+
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'])"); \
1764+
echo ; \
1765+
exit 1; \
1766+
fi
1767+
17321768
# Like testall, but with only one pass and without multiple processes.
17331769
# Run an optional script to include information about the build environment.
17341770
buildbottest: all
@@ -2419,7 +2455,7 @@ frameworkinstallextras:
24192455
# subdirectory. The install has put these folders in the same folder as
24202456
# Python.framework; Move the headers to their final framework-compatible home.
24212457
.PHONY: frameworkinstallmobileheaders
2422-
frameworkinstallmobileheaders:
2458+
frameworkinstallmobileheaders: frameworkinstallunversionedstructure inclinstall
24232459
if test -d $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers; then \
24242460
echo "Removing old framework headers"; \
24252461
rm -rf $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers; \
@@ -2531,6 +2567,10 @@ clean-retain-profile: pycremoval
25312567
-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
25322568
-rm -f Include/pydtrace_probes.h
25332569
-rm -f profile-gen-stamp
2570+
-rm -rf iOS/testbed/Python.xcframework/ios-*/bin
2571+
-rm -rf iOS/testbed/Python.xcframework/ios-*/lib
2572+
-rm -rf iOS/testbed/Python.xcframework/ios-*/include
2573+
-rm -rf iOS/testbed/Python.xcframework/ios-*/Python.framework
25342574

25352575
profile-removal:
25362576
find . -name '*.gc??' -exec rm -f {} ';'
@@ -2552,6 +2592,8 @@ clobber: clean
25522592
config.cache config.log pyconfig.h Modules/config.c
25532593
-rm -rf build platform
25542594
-rm -rf $(PYTHONFRAMEWORKDIR)
2595+
-rm -rf iOS/Frameworks
2596+
-rm -rf iOSTestbed.*
25552597
-rm -f python-config.py python-config
25562598

25572599
# Make things extra clean, before making a distribution:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
A testbed project was added to run the test suite on iOS.

configure

+98-52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)