Skip to content

Commit 04a83a0

Browse files
authored
Enable integration tests in self-hosted CI jobs (#3088)
These were initially added in #2592 but not enabled because of lack of necessary Xcode support from Swift CI. - Add ability to conditionally skip when self-hosted - Skip failing tests and add more details about reasons
1 parent 2522af5 commit 04a83a0

File tree

8 files changed

+53
-32
lines changed

8 files changed

+53
-32
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <stdio.h>
2+
13
int main(void) {
24
printf("Hello from cbar");
3-
}
5+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <stdio.h>
2+
13
int main(void) {
24
printf("Hello from cfoo");
3-
}
5+
}

IntegrationTests/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import class Foundation.ProcessInfo
1616

1717
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
1818
package.dependencies += [
19-
.package(url: "https://github.com/apple/swift-tools-support-core.git", .branch("master")),
19+
.package(url: "https://github.com/apple/swift-tools-support-core.git", .branch("main")),
2020
]
2121
} else {
2222
package.dependencies += [

IntegrationTests/Tests/IntegrationTests/BasicTests.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@ final class BasicTests: XCTestCase {
1717
XCTAssertMatch(try sh(swift, "--version").stdout, .contains("Swift version"))
1818
}
1919

20-
// Disabled because these packages don't use the latest runtime library which doesn't work with self-hosted builds.
21-
//
22-
// FIXME: We should to use XCTSkip to skip this test instead.
23-
func DISABLED_testExamplePackageDealer() throws {
20+
func testExamplePackageDealer() throws {
21+
try XCTSkipIf(isSelfHosted, "These packages don't use the latest runtime library, which doesn't work with self-hosted builds.")
22+
2423
try withTemporaryDirectory { dir in
2524
let dealerDir = dir.appending(component: "dealer")
2625
try sh("git", "clone", "https://github.com/apple/example-package-dealer", dealerDir)
@@ -120,8 +119,9 @@ final class BasicTests: XCTestCase {
120119
}
121120
}
122121

123-
// TODO: Check why this test is failing to test in Xcode and through the command line.
124-
func _testSwiftPackageInitLib() throws {
122+
func testSwiftPackageInitLib() throws {
123+
try XCTSkip("FIXME: swift-test invocations are timing out in Xcode and self-hosted CI")
124+
125125
try withTemporaryDirectory { dir in
126126
// Create a new package with an executable target.
127127
let projectDir = dir.appending(component: "Project")
@@ -203,6 +203,8 @@ final class BasicTests: XCTestCase {
203203
}
204204

205205
func testSwiftTest() throws {
206+
try XCTSkip("FIXME: swift-test invocations are timing out in Xcode and self-hosted CI")
207+
206208
try withTemporaryDirectory { dir in
207209
let toolDir = dir.appending(component: "swiftTest")
208210
try localFileSystem.createDirectory(toolDir)
@@ -234,6 +236,8 @@ final class BasicTests: XCTestCase {
234236
}
235237

236238
func testSwiftTestWithResources() throws {
239+
try XCTSkip("FIXME: swift-test invocations are timing out in Xcode and self-hosted CI")
240+
237241
try withTemporaryDirectory { dir in
238242
let toolDir = dir.appending(component: "swiftTestResources")
239243
try localFileSystem.createDirectory(toolDir)

IntegrationTests/Tests/IntegrationTests/Helpers.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ let toolchainPath: AbsolutePath = {
3535

3636
#if os(macOS)
3737
let swiftcPath = try! AbsolutePath(sh("xcrun", "--find", "swift").stdout.spm_chomp())
38-
let toolchainPath = swiftcPath.parentDirectory.parentDirectory.parentDirectory
39-
return toolchainPath
4038
#else
41-
fatalError("TOOLCHAIN_PATH environment variable required")
39+
let swiftcPath = try! AbsolutePath(sh("which", "swift").stdout.spm_chomp())
4240
#endif
41+
let toolchainPath = swiftcPath.parentDirectory.parentDirectory.parentDirectory
42+
return toolchainPath
4343
}()
4444

4545
let clang: AbsolutePath = {
@@ -89,7 +89,7 @@ let lldb: AbsolutePath = {
8989
return toolchainLLDBPath
9090
}
9191

92-
#if os(macOS)
92+
#if os(macOS)
9393
let lldbPath = try! AbsolutePath(sh("xcrun", "--find", "lldb").stdout.spm_chomp())
9494
return lldbPath
9595
#else
@@ -121,6 +121,10 @@ let swiftRun: AbsolutePath = {
121121
return swiftpmBinaryDirectory.appending(component: "swift-run")
122122
}()
123123

124+
let isSelfHosted: Bool = {
125+
return ProcessInfo.processInfo.environment["SWIFTCI_IS_SELF_HOSTED"] != nil
126+
}()
127+
124128
@discardableResult
125129
func sh(
126130
_ arguments: CustomStringConvertible...,
@@ -313,6 +317,6 @@ func binaryTargetsFixture(_ closure: (AbsolutePath) throws -> Void) throws {
313317
}
314318
}
315319

316-
func XCTSkip() throws {
317-
throw XCTSkip()
320+
func XCTSkip(_ message: String? = nil) throws {
321+
throw XCTSkip(message)
318322
}

IntegrationTests/Tests/IntegrationTests/SwiftPMTests.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,13 @@ import TSCBasic
1313
import TSCTestSupport
1414

1515
final class SwiftPMTests: XCTestCase {
16-
#if os(macOS)
17-
// FIXME: This is failing right now.
18-
func DISABLED_testBinaryTargets() throws {
16+
func testBinaryTargets() throws {
17+
try XCTSkip("FIXME: ld: warning: dylib (/../BinaryTargets.6YVYK4/TestBinary/.build/x86_64-apple-macosx/debug/SwiftFramework.framework/SwiftFramework) was built for newer macOS version (10.15) than being linked (10.10)")
18+
19+
#if !os(macOS)
20+
try XCTSkip("Test requires macOS")
21+
#endif
22+
1923
try binaryTargetsFixture { prefix in
2024
do {
2125
let (stdout, stderr) = try sh(swiftRun, "--package-path", prefix, "exe")
@@ -46,6 +50,10 @@ final class SwiftPMTests: XCTestCase {
4650
}
4751

4852
func testArchCustomization() throws {
53+
#if !os(macOS)
54+
try XCTSkip("Test requires macOS")
55+
#endif
56+
4957
try withTemporaryDirectory { tmpDir in
5058
let foo = tmpDir.appending(component: "foo")
5159
try localFileSystem.createDirectory(foo)
@@ -55,7 +63,7 @@ final class SwiftPMTests: XCTestCase {
5563
try localFileSystem.writeFileContents(foo.appending(RelativePath("Sources/foo/main.m"))) {
5664
$0 <<< "int main() {}"
5765
}
58-
let archs = ["x86_64", "x86_64h"]
66+
let archs = ["x86_64", "arm64"]
5967

6068
for arch in archs {
6169
try sh(swiftBuild, "--package-path", foo, "--arch", arch)
@@ -75,5 +83,4 @@ final class SwiftPMTests: XCTestCase {
7583
}
7684
}
7785
}
78-
#endif
7986
}

IntegrationTests/Tests/IntegrationTests/XCBuildTests.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import TSCTestSupport
1616
final class XCBuildTests: XCTestCase {
1717
func testExecutableProducts() throws {
1818
#if !os(macOS)
19-
try XCTSkip()
19+
try XCTSkip("Test requires macOS")
2020
#endif
2121

2222
fixture(name: "XCBuild/ExecutableProducts") { path in
@@ -117,7 +117,7 @@ final class XCBuildTests: XCTestCase {
117117

118118
func testTestProducts() throws {
119119
#if !os(macOS)
120-
try XCTSkip()
120+
try XCTSkip("Test requires macOS")
121121
#endif
122122

123123
fixture(name: "XCBuild/TestProducts") { path in
@@ -199,7 +199,7 @@ final class XCBuildTests: XCTestCase {
199199

200200
func testLibraryProductsAndTargets() throws {
201201
#if !os(macOS)
202-
try XCTSkip()
202+
try XCTSkip("Test requires macOS")
203203
#endif
204204

205205
fixture(name: "XCBuild/Libraries") { path in
@@ -272,8 +272,10 @@ final class XCBuildTests: XCTestCase {
272272
}
273273

274274
func testSystemTargets() throws {
275+
try XCTSkip("FIXME: ld: warning: ignoring file /../XCBuild_SystemTargets.b38QoO/Inputs/libsys.a, building for macOS-arm64 but attempting to link with file built for unknown-x86_64\n\nUndefined symbols for architecture arm64:\n \"_GetSystemLibName\", referenced from:\n _main in main.o\n\nld: symbol(s) not found for architecture arm64\n\nclang: error: linker command failed with exit code 1 (use -v to see invocation)\n\nBuild cancelled\n")
276+
275277
#if !os(macOS)
276-
try XCTSkip()
278+
try XCTSkip("Test requires macOS")
277279
#endif
278280

279281
fixture(name: "XCBuild/SystemTargets") { path in
@@ -298,17 +300,18 @@ final class XCBuildTests: XCTestCase {
298300
}
299301

300302
func testBinaryTargets() throws {
301-
//FIXME: This test randomly succeeds or fails, depending on the order the subtasks are executed in.
302-
try XCTSkip()
303+
try XCTSkip("FIXME: This test randomly succeeds or fails, depending on the order the subtasks are executed in.")
303304

304305
try binaryTargetsFixture { path in
305306
try sh(swiftBuild, "--package-path", path, "-c", "debug", "--build-system", "xcode", "--target", "exe")
306307
}
307308
}
308309

309310
func testSwiftTest() throws {
311+
try XCTSkip("FIXME: swift-test invocations are timing out in Xcode and self-hosted CI")
312+
310313
#if !os(macOS) || Xcode
311-
try XCTSkip()
314+
try XCTSkip("Test requires macOS")
312315
#endif
313316

314317
fixture(name: "XCBuild/TestProducts") { path in

Utilities/build-using-self

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ cd "${__dir}/.."
88
echo "Current directory is ${PWD}"
99

1010
CONFIGURATION=debug
11+
export SWIFTCI_IS_SELF_HOSTED=1
1112

1213
set -x
1314

@@ -16,9 +17,7 @@ swift package update
1617
swift build -c $CONFIGURATION
1718
swift test -c $CONFIGURATION --parallel --enable-test-discovery
1819

19-
# FIXME: Disabled until we get some version of Xcode 11.4 on Swift CI.
20-
#
2120
# Run the integration tests with just built SwiftPM.
22-
# export SWIFTPM_BIN_DIR=$(swift build -c $CONFIGURATION --show-bin-path)
23-
# cd IntegrationTests
24-
# $SWIFTPM_BIN_DIR/swift-test --parallel --enable-test-discovery
21+
export SWIFTPM_BIN_DIR=$(swift build -c $CONFIGURATION --show-bin-path)
22+
cd IntegrationTests
23+
$SWIFTPM_BIN_DIR/swift-test --parallel --enable-test-discovery

0 commit comments

Comments
 (0)