Skip to content

Commit ac5f7c7

Browse files
committed
[build-script] Build & test XCTest (on OS X, too)
Allow swift-corelibs-xctest to be built and tested on Linux and OS X, via `utils/build-script --xctest --test`. On OS X, XCTest is built via `xcodebuild`, which has been possible since swiftlang/swift-corelibs-xctest#47. It's tested via the "SwiftXCTestFunctionalTests" Xcode target. Keep in mind that `xcodebuild` must be configured on the host machine to use a Swift toolchain that can build XCTest--as of swiftlang/swift-corelibs-xctest#48, that would be `swift-DEVELOPMENT-SNAPSHOT-2016-02-08` or later. On Linux, XCTest is built and tested via the project's `build_script.py`, which has been possible since swiftlang/swift-corelibs-xctest#46.
1 parent 5625117 commit ac5f7c7

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

utils/build-script-impl

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,11 +1746,17 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}"
17461746
continue
17471747
;;
17481748
xctest)
1749-
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
1750-
SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)"
1751-
set -x
1752-
"${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" --build-dir="${build_dir}" --swift-build-dir="${SWIFT_BUILD_PATH}" --arch="${SWIFT_HOST_VARIANT_ARCH}"
1753-
{ set +x; } 2>/dev/null
1749+
if [[ "$(uname -s)" == "Darwin" ]] ; then
1750+
set -x
1751+
xcodebuild -project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj -scheme SwiftXCTest SKIP_INSTALL=NO DEPLOYMENT_LOCATION=YES DSTROOT="${build_dir}" INSTALL_PATH="/"
1752+
{ set +x; } 2>/dev/null
1753+
else
1754+
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
1755+
SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)"
1756+
set -x
1757+
"${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" --build-dir="${build_dir}" --swift-build-dir="${SWIFT_BUILD_PATH}" --arch="${SWIFT_HOST_VARIANT_ARCH}"
1758+
{ set +x; } 2>/dev/null
1759+
fi
17541760

17551761
# XCTest builds itself and doesn't rely on cmake
17561762
continue
@@ -1991,7 +1997,21 @@ for deployment_target in "${STDLIB_DEPLOYMENT_TARGETS[@]}"; do
19911997
if [[ "${SKIP_TEST_XCTEST}" ]]; then
19921998
continue
19931999
fi
1994-
# FIXME: We don't test xctest, yet...
2000+
echo "--- Running tests for ${product} ---"
2001+
if [[ "$(uname -s)" == "Darwin" ]] ; then
2002+
set -x
2003+
xcodebuild -project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj -scheme SwiftXCTestFunctionalTests
2004+
{ set +x; } 2>/dev/null
2005+
else
2006+
SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc"
2007+
SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)"
2008+
set -x
2009+
# FIXME: This re-builds swift-corelibs-xctest. Instead, 'build_script.py' should take
2010+
# a top-level 'test' command that only tests an already built XCTest.
2011+
"${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" --build-dir="${build_dir}" --swift-build-dir="${SWIFT_BUILD_PATH}" --arch="${SWIFT_HOST_VARIANT_ARCH}" --test
2012+
{ set +x; } 2>/dev/null
2013+
fi
2014+
echo "--- Finished tests for ${product} ---"
19952015
continue
19962016
;;
19972017
foundation)

0 commit comments

Comments
 (0)