From ac5f7c732627e18ed5ebd8e9f08a510348180b73 Mon Sep 17 00:00:00 2001 From: Brian Gesiak Date: Mon, 15 Feb 2016 00:59:57 -0500 Subject: [PATCH] [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 https://github.com/apple/swift-corelibs-xctest/pull/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 https://github.com/apple/swift-corelibs-xctest/pull/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 https://github.com/apple/swift-corelibs-xctest/pull/46. --- utils/build-script-impl | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index 2b4e9ca76b12f..877414140683d 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -1746,11 +1746,17 @@ for deployment_target in "${HOST_TARGET}" "${CROSS_TOOLS_DEPLOYMENT_TARGETS[@]}" continue ;; xctest) - SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc" - SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)" - set -x - "${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" --build-dir="${build_dir}" --swift-build-dir="${SWIFT_BUILD_PATH}" --arch="${SWIFT_HOST_VARIANT_ARCH}" - { set +x; } 2>/dev/null + if [[ "$(uname -s)" == "Darwin" ]] ; then + set -x + xcodebuild -project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj -scheme SwiftXCTest SKIP_INSTALL=NO DEPLOYMENT_LOCATION=YES DSTROOT="${build_dir}" INSTALL_PATH="/" + { set +x; } 2>/dev/null + else + SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc" + SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)" + set -x + "${XCTEST_SOURCE_DIR}"/build_script.py --swiftc="${SWIFTC_BIN}" --build-dir="${build_dir}" --swift-build-dir="${SWIFT_BUILD_PATH}" --arch="${SWIFT_HOST_VARIANT_ARCH}" + { set +x; } 2>/dev/null + fi # XCTest builds itself and doesn't rely on cmake continue @@ -1991,7 +1997,21 @@ for deployment_target in "${STDLIB_DEPLOYMENT_TARGETS[@]}"; do if [[ "${SKIP_TEST_XCTEST}" ]]; then continue fi - # FIXME: We don't test xctest, yet... + echo "--- Running tests for ${product} ---" + if [[ "$(uname -s)" == "Darwin" ]] ; then + set -x + xcodebuild -project "${XCTEST_SOURCE_DIR}"/XCTest.xcodeproj -scheme SwiftXCTestFunctionalTests + { set +x; } 2>/dev/null + else + SWIFTC_BIN="$(build_directory_bin ${deployment_target} swift)/swiftc" + SWIFT_BUILD_PATH="$(build_directory ${deployment_target} swift)" + set -x + # FIXME: This re-builds swift-corelibs-xctest. Instead, 'build_script.py' should take + # a top-level 'test' command that only tests an already built XCTest. + "${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 + { set +x; } 2>/dev/null + fi + echo "--- Finished tests for ${product} ---" continue ;; foundation)