Skip to content

Commit 4482258

Browse files
committed
[3.12] pythongh-114099 - Add iOS testbed, plus Makefile target to invoke it. (pythongh-115930)
1 parent 9ff4ec5 commit 4482258

File tree

20 files changed

+1188
-122
lines changed

20 files changed

+1188
-122
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,17 @@ Lib/test/data/*
6969
/_bootstrap_python
7070
/Makefile
7171
/Makefile.pre
72+
iOSTestbed.*
73+
iOS/Frameworks/
7274
iOS/Resources/Info.plist
75+
iOS/testbed/build
76+
iOS/testbed/Python.xcframework/ios-*/bin
77+
iOS/testbed/Python.xcframework/ios-*/include
78+
iOS/testbed/Python.xcframework/ios-*/lib
79+
iOS/testbed/Python.xcframework/ios-*/Python.framework
80+
iOS/testbed/iOSTestbed.xcodeproj/project.xcworkspace
81+
iOS/testbed/iOSTestbed.xcodeproj/xcuserdata
82+
iOS/testbed/iOSTestbed.xcodeproj/xcshareddata
7383
Mac/Makefile
7484
Mac/PythonLauncher/Info.plist
7585
Mac/PythonLauncher/Makefile

Makefile.pre.in

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

1876+
# Run the test suite on the iOS simulator. Must be run on a macOS machine with
1877+
# a full Xcode install that has an iPhone SE (3rd edition) simulator available.
1878+
# This must be run *after* a `make install` has completed the build. The
1879+
# `--with-framework-name` argument *cannot* be used when configuring the build.
1880+
XCFOLDER=iOSTestbed.$(MULTIARCH).$(shell date +%s)
1881+
XCRESULT=$(XCFOLDER)/$(MULTIARCH).xcresult
1882+
.PHONY: testios
1883+
testios:
1884+
@if test "$(MACHDEP)" != "ios"; then \
1885+
echo "Cannot run the iOS testbed for a non-iOS build."; \
1886+
exit 1;\
1887+
fi
1888+
@if test "$(findstring -iphonesimulator,$(MULTIARCH))" != "-iphonesimulator"; then \
1889+
echo "Cannot run the iOS testbed for non-simulator builds."; \
1890+
exit 1;\
1891+
fi
1892+
@if test $(PYTHONFRAMEWORK) != "Python"; then \
1893+
echo "Cannot run the iOS testbed with a non-default framework name."; \
1894+
exit 1;\
1895+
fi
1896+
@if ! test -d $(PYTHONFRAMEWORKPREFIX); then \
1897+
echo "Cannot find a finalized iOS Python.framework. Have you run 'make install' to finalize the framework build?"; \
1898+
exit 1;\
1899+
fi
1900+
# Copy the testbed project into the build folder
1901+
cp -r $(srcdir)/iOS/testbed $(XCFOLDER)
1902+
# Copy the framework from the install location to the testbed project.
1903+
cp -r $(PYTHONFRAMEWORKPREFIX)/* $(XCFOLDER)/Python.xcframework/ios-arm64_x86_64-simulator
1904+
# Run the test suite for the Xcode project, targeting the iOS simulator.
1905+
# If the suite fails, extract and print the console output, then re-raise the failure
1906+
if ! xcodebuild test -project $(XCFOLDER)/iOSTestbed.xcodeproj -scheme "iOSTestbed" -destination "platform=iOS Simulator,name=iPhone SE (3rd Generation)" -resultBundlePath $(XCRESULT) ; then \
1907+
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'])"); \
1908+
echo ; \
1909+
exit 1; \
1910+
fi
1911+
18761912
# Like testall, but with only one pass and without multiple processes.
18771913
# Run an optional script to include information about the build environment.
18781914
.PHONY: buildbottest
@@ -2612,7 +2648,7 @@ frameworkinstallextras:
26122648
# subdirectory. The install has put these folders in the same folder as
26132649
# Python.framework; Move the headers to their final framework-compatible home.
26142650
.PHONY: frameworkinstallmobileheaders
2615-
frameworkinstallmobileheaders:
2651+
frameworkinstallmobileheaders: frameworkinstallunversionedstructure inclinstall
26162652
if test -d $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers; then \
26172653
echo "Removing old framework headers"; \
26182654
rm -rf $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers; \
@@ -2730,6 +2766,10 @@ clean-retain-profile: pycremoval
27302766
-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
27312767
-rm -f Include/pydtrace_probes.h
27322768
-rm -f profile-gen-stamp
2769+
-rm -rf iOS/testbed/Python.xcframework/ios-*/bin
2770+
-rm -rf iOS/testbed/Python.xcframework/ios-*/lib
2771+
-rm -rf iOS/testbed/Python.xcframework/ios-*/include
2772+
-rm -rf iOS/testbed/Python.xcframework/ios-*/Python.framework
27332773

27342774
.PHONY: profile-removal
27352775
profile-removal:
@@ -2755,6 +2795,8 @@ clobber: clean
27552795
config.cache config.log pyconfig.h Modules/config.c
27562796
-rm -rf build platform
27572797
-rm -rf $(PYTHONFRAMEWORKDIR)
2798+
-rm -rf iOS/Frameworks
2799+
-rm -rf iOSTestbed.*
27582800
-rm -f python-config.py python-config
27592801

27602802
# Make things extra clean, before making a distribution:
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.

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)