Skip to content

Commit a17c05b

Browse files
committed
[build-script] Build XCTest's Foundation dependency
As of swiftlang/swift-corelibs-xctest#43, swift-corelibs-xctest is dependent upon swift-corelibs-foundation. As such, it must be built after Foundation, and its build script must be passed a reference to the Foundation build directory. Update the build script in order to get XCTest building after the changes in swiftlang/swift-corelibs-xctest#43. In addition, this change also allows XCTest to be tested via `utils/build-script --xctest --test`. This has been possible since swiftlang/swift-corelibs-xctest#46.
1 parent f1ad829 commit a17c05b

File tree

2 files changed

+51
-20
lines changed

2 files changed

+51
-20
lines changed

utils/build-script

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ from __future__ import print_function
1414
import argparse
1515
import multiprocessing
1616
import os
17+
import platform
1718
import shutil
1819
import sys
1920
import textwrap
@@ -566,6 +567,12 @@ the number of parallel build jobs to use""",
566567
if (args.lldb_build_variant is not None or args.lldb_assertions is not None):
567568
args.build_lldb = True
568569

570+
# If XCTest is to be built on systems other than OS X, its dependency
571+
# Foundation must also be built. This isn't necessary on OS X, since
572+
# Foundation is built via xcodebuild.
573+
if platform.system() != 'Darwin' and args.build_xctest:
574+
args.build_foundation = True
575+
569576
# Set the default build variant.
570577
if args.build_variant is None:
571578
args.build_variant = "Debug"

utils/build-script-impl

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -921,12 +921,14 @@ fi
921921
if [[ ! "${SKIP_BUILD_SWIFTPM}" ]] ; then
922922
PRODUCTS=("${PRODUCTS[@]}" swiftpm)
923923
fi
924-
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
925-
PRODUCTS=("${PRODUCTS[@]}" xctest)
926-
fi
924+
# XCTest has a dependency upon Foundation. It must be added to the list of
925+
# products *after* Foundation.
927926
if [[ ! "${SKIP_BUILD_FOUNDATION}" ]] ; then
928927
PRODUCTS=("${PRODUCTS[@]}" foundation)
929928
fi
929+
if [[ ! "${SKIP_BUILD_XCTEST}" ]] ; then
930+
PRODUCTS=("${PRODUCTS[@]}" xctest)
931+
fi
930932
if [[ ! "${SKIP_BUILD_LIBDISPATCH}" ]] ; then
931933
PRODUCTS=("${PRODUCTS[@]}" libdispatch)
932934
fi
@@ -1796,16 +1798,6 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
17961798
# swiftpm installs itself with a bootstrap method. No further cmake building is performed.
17971799
continue
17981800
;;
1799-
xctest)
1800-
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
1801-
SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)"
1802-
set -x
1803-
"${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" --build-dir="${build_dir}" --swift-build-dir="${SWIFT_BUILD_PATH}"
1804-
{ set +x; } 2>/dev/null
1805-
1806-
# XCTest builds itself and doesn't rely on cmake
1807-
continue
1808-
;;
18091801
foundation)
18101802
# the configuration script requires knowing about XCTest's location for building and running the tests
18111803
XCTEST_BUILD_DIR=$(build_directory ${deployment_target} xctest)
@@ -1831,6 +1823,23 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
18311823
# Foundation builds itself and doesn't use cmake
18321824
continue
18331825
;;
1826+
xctest)
1827+
if [[ "$(uname -s)" == "Darwin" ]] ; then
1828+
set -x
1829+
xcodebuild -project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj -scheme SwiftXCTest SKIP_INSTALL=NO DEPLOYMENT_LOCATION=YES DSTROOT="${build_dir}" INSTALL_PATH="/"
1830+
{ set +x; } 2>/dev/null
1831+
else
1832+
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
1833+
SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)"
1834+
FOUNDATION_BUILD_DIR="$(build_directory ${deployment_target} foundation)"/Foundation
1835+
set -x
1836+
"${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" --build-dir="${build_dir}" --swift-build-dir="${SWIFT_BUILD_PATH}" --foundation-build-dir="${FOUNDATION_BUILD_DIR}"
1837+
{ set +x; } 2>/dev/null
1838+
fi
1839+
1840+
# XCTest builds itself and doesn't rely on cmake
1841+
continue
1842+
;;
18341843
libdispatch)
18351844
LIBDISPATCH_BUILD_DIR=$(build_directory ${deployment_target} ${product})
18361845

@@ -2017,13 +2026,6 @@ for deployment_target in "${STDLIB_DEPLOYMENT_TARGETS[@]}"; do
20172026
# As swiftpm tests itself, we break early here.
20182027
continue
20192028
;;
2020-
xctest)
2021-
if [[ "${SKIP_TEST_XCTEST}" ]]; then
2022-
continue
2023-
fi
2024-
# FIXME: We don't test xctest, yet...
2025-
continue
2026-
;;
20272029
foundation)
20282030
if [[ "${SKIP_TEST_FOUNDATION}" ]]; then
20292031
continue
@@ -2040,6 +2042,28 @@ for deployment_target in "${STDLIB_DEPLOYMENT_TARGETS[@]}"; do
20402042
echo "--- Finished tests for ${product} ---"
20412043
continue
20422044
;;
2045+
xctest)
2046+
if [[ "${SKIP_TEST_XCTEST}" ]]; then
2047+
continue
2048+
fi
2049+
echo "--- Running tests for ${product} ---"
2050+
if [[ "$(uname -s)" == "Darwin" ]] ; then
2051+
set -x
2052+
xcodebuild -project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj -scheme SwiftXCTestFunctionalTests
2053+
{ set +x; } 2>/dev/null
2054+
else
2055+
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
2056+
SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)"
2057+
FOUNDATION_BUILD_PATH="$(build_directory ${deployment_target} foundation)"/Foundation
2058+
set -x
2059+
# FIXME: This re-builds swift-corelibs-xctest. Instead, 'build_script.py' should take
2060+
# a top-level 'test' command that only tests an already built XCTest.
2061+
"${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" --build-dir="${build_dir}" --swift-build-dir="${SWIFT_BUILD_PATH}" --foundation-build-dir="${FOUNDATION_BUILD_PATH}" --test
2062+
{ set +x; } 2>/dev/null
2063+
fi
2064+
echo "--- Finished tests for ${product} ---"
2065+
continue
2066+
;;
20432067
libdispatch)
20442068
if [[ "${SKIP_TEST_LIBDISPATCH}" ]]; then
20452069
continue

0 commit comments

Comments
 (0)