|
2 | 2 | //
|
3 | 3 | // This source file is part of the Swift open source project
|
4 | 4 | //
|
5 |
| -// Copyright (c) 2024 Apple Inc. and the Swift project authors |
| 5 | +// Copyright (c) 2024-2025 Apple Inc. and the Swift project authors |
6 | 6 | // Licensed under Apache License v2.0 with Runtime Library Exception
|
7 | 7 | //
|
8 | 8 | // See http://swift.org/LICENSE.txt for license information
|
9 | 9 | // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
10 | 10 | //
|
11 | 11 | //===----------------------------------------------------------------------===//
|
| 12 | +import Foundation |
12 | 13 |
|
13 | 14 | import PackageModel
|
14 | 15 | import _InternalTestSupport
|
15 |
| -import XCTest |
| 16 | +import Testing |
16 | 17 |
|
17 | 18 | import var TSCBasic.localFileSystem
|
18 | 19 |
|
19 |
| -final class BuildSystemDelegateTests: XCTestCase { |
20 |
| - func testDoNotFilterLinkerDiagnostics() async throws { |
21 |
| - try XCTSkipIf(!UserToolchain.default.supportsSDKDependentTests(), "skipping because test environment doesn't support this test") |
22 |
| - try await fixtureXCTest(name: "Miscellaneous/DoNotFilterLinkerDiagnostics") { fixturePath in |
23 |
| - #if !os(macOS) |
24 |
| - // These linker diagnostics are only produced on macOS. |
25 |
| - try XCTSkipIf(true, "test is only supported on macOS") |
26 |
| - #endif |
27 |
| - let (fullLog, _) = try await executeSwiftBuild(fixturePath, buildSystem: .native) |
28 |
| - XCTAssertTrue(fullLog.contains("ld: warning: search path 'foobar' not found"), "log didn't contain expected linker diagnostics") |
| 20 | +@Suite( |
| 21 | + .tags( |
| 22 | + .TestSize.large, |
| 23 | + ) |
| 24 | +) |
| 25 | +struct BuildSystemDelegateTests { |
| 26 | + @Test( |
| 27 | + .requiresSDKDependentTestsSupport, |
| 28 | + .requireHostOS(.macOS), // These linker diagnostics are only produced on macOS. |
| 29 | + arguments: getBuildData(for: SupportedBuildSystemOnAllPlatforms), |
| 30 | + ) |
| 31 | + func doNotFilterLinkerDiagnostics( |
| 32 | + data: BuildData, |
| 33 | + ) async throws { |
| 34 | + try await fixture(name: "Miscellaneous/DoNotFilterLinkerDiagnostics") { fixturePath in |
| 35 | + let (stdout, stderr) = try await executeSwiftBuild( |
| 36 | + fixturePath, |
| 37 | + configuration: data.config, |
| 38 | + buildSystem: data.buildSystem, |
| 39 | + ) |
| 40 | + switch data.buildSystem { |
| 41 | + |
| 42 | + case .native: |
| 43 | + #expect( |
| 44 | + stdout.contains("ld: warning: search path 'foobar' not found"), |
| 45 | + "log didn't contain expected linker diagnostics. stderr: '\(stderr)')", |
| 46 | + ) |
| 47 | + case .swiftbuild: |
| 48 | + #expect( |
| 49 | + !stderr.contains("warning: search path 'foobar' not found"), |
| 50 | + "log didn't contain expected linker diagnostics. stdout: '\(stdout)')", |
| 51 | + ) |
| 52 | + #expect( |
| 53 | + !stdout.contains("warning: search path 'foobar' not found"), |
| 54 | + "log didn't contain expected linker diagnostics. stderr: '\(stderr)')", |
| 55 | + ) |
| 56 | + case .xcode: |
| 57 | + Issue.record("Test expectation has not be implemented") |
| 58 | + } |
29 | 59 | }
|
30 | 60 | }
|
31 | 61 |
|
32 |
| - func testFilterNonFatalCodesignMessages() async throws { |
33 |
| - try XCTSkipOnWindows(because: "https://github.com/swiftlang/swift-package-manager/issues/8540: Package fails to build when the test is being executed") |
34 |
| - |
35 |
| - try XCTSkipIf(!UserToolchain.default.supportsSDKDependentTests(), "skipping because test environment doesn't support this test") |
36 |
| - // Note: we can re-use the `TestableExe` fixture here since we just need an executable. |
37 |
| - #if os(Windows) |
38 |
| - let executableExt = ".exe" |
39 |
| - #else |
40 |
| - let executableExt = "" |
41 |
| - #endif |
42 |
| - try await fixtureXCTest(name: "Miscellaneous/TestableExe") { fixturePath in |
43 |
| - _ = try await executeSwiftBuild(fixturePath, buildSystem: .native) |
44 |
| - let execPath = fixturePath.appending(components: ".build", "debug", "TestableExe1\(executableExt)") |
45 |
| - XCTAssertTrue(localFileSystem.exists(execPath), "executable not found at '\(execPath)'") |
46 |
| - try localFileSystem.removeFileTree(execPath) |
47 |
| - let (fullLog, _) = try await executeSwiftBuild(fixturePath, buildSystem: .native) |
48 |
| - XCTAssertFalse(fullLog.contains("replacing existing signature"), "log contained non-fatal codesigning messages") |
| 62 | + @Test( |
| 63 | + .issue("https://github.com/swiftlang/swift-package-manager/issues/8540", relationship: .defect), // Package fails to build when the test is being executed" |
| 64 | + .requiresSDKDependentTestsSupport, |
| 65 | + arguments: getBuildData(for: SupportedBuildSystemOnAllPlatforms), |
| 66 | + ) |
| 67 | + func filterNonFatalCodesignMessages( |
| 68 | + data: BuildData, |
| 69 | + ) async throws { |
| 70 | + try await withKnownIssue { |
| 71 | + // Note: we can re-use the `TestableExe` fixture here since we just need an executable. |
| 72 | + try await fixture(name: "Miscellaneous/TestableExe") { fixturePath in |
| 73 | + _ = try await executeSwiftBuild( |
| 74 | + fixturePath, |
| 75 | + configuration: data.config, |
| 76 | + buildSystem: data.buildSystem, |
| 77 | + ) |
| 78 | + let execPath = try fixturePath.appending( |
| 79 | + components: data.buildSystem.binPath(for: data.config) + [executableName("TestableExe1")] |
| 80 | + ) |
| 81 | + expectFileExists(at: execPath) |
| 82 | + try localFileSystem.removeFileTree(execPath) |
| 83 | + let (stdout, stderr) = try await executeSwiftBuild( |
| 84 | + fixturePath, |
| 85 | + configuration: data.config, |
| 86 | + buildSystem: data.buildSystem, |
| 87 | + ) |
| 88 | + #expect(!stdout.contains("replacing existing signature"), "log contained non-fatal codesigning messages stderr: '\(stderr)'") |
| 89 | + #expect(!stderr.contains("replacing existing signature"), "log contained non-fatal codesigning messages. stdout: '\(stdout)'") |
| 90 | + } |
| 91 | + } when: { |
| 92 | + ProcessInfo.hostOperatingSystem == .windows |
49 | 93 | }
|
50 | 94 | }
|
51 | 95 | }
|
0 commit comments