Skip to content

Commit 65e5721

Browse files
MaxDesiatovbnbarham
authored andcommitted
Gate 6.0 dependent tests with a 6.0 compiler check
1 parent be0dc1e commit 65e5721

File tree

12 files changed

+115
-36
lines changed

12 files changed

+115
-36
lines changed

Fixtures/Miscellaneous/Plugins/DependentPlugins/Package.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ let package = Package(
1010
targets: [
1111
.executableTarget(name: "MyExecutable"),
1212
.executableTarget(name: "MyExecutable2"),
13-
13+
1414
.plugin(
1515
name: "MyPlugin",
1616
capability: .buildTool(),
1717
dependencies: [
1818
"MyExecutable"
1919
]
2020
),
21-
21+
2222
.plugin(
2323
name: "MyPlugin2",
2424
capability: .buildTool(),
@@ -34,5 +34,6 @@ let package = Package(
3434
"MyPlugin2",
3535
]
3636
),
37-
]
37+
],
38+
swiftLanguageVersions: [.v5]
3839
)

IntegrationTests/Tests/IntegrationTests/BasicTests.swift

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final class BasicTests: XCTestCase {
1919

2020
func testExamplePackageDealer() throws {
2121
try XCTSkipIf(isSelfHosted, "These packages don't use the latest runtime library, which doesn't work with self-hosted builds.")
22+
try skipUnlessAtLeastSwift6()
2223

2324
try withTemporaryDirectory { tempDir in
2425
let packagePath = tempDir.appending(component: "dealer")
@@ -93,9 +94,7 @@ final class BasicTests: XCTestCase {
9394
}
9495

9596
func testSwiftPackageInitExec() throws {
96-
#if swift(<5.5)
97-
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
98-
#endif
97+
try skipUnlessAtLeastSwift6()
9998

10099
try withTemporaryDirectory { tempDir in
101100
// Create a new package with an executable target.
@@ -122,9 +121,7 @@ final class BasicTests: XCTestCase {
122121
}
123122

124123
func testSwiftPackageInitExecTests() throws {
125-
#if swift(<5.5)
126-
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
127-
#endif
124+
try skipUnlessAtLeastSwift6()
128125

129126
try XCTSkip("FIXME: swift-test invocations are timing out in Xcode and self-hosted CI")
130127

@@ -149,6 +146,8 @@ final class BasicTests: XCTestCase {
149146
}
150147

151148
func testSwiftPackageInitLib() throws {
149+
try skipUnlessAtLeastSwift6()
150+
152151
try withTemporaryDirectory { tempDir in
153152
// Create a new package with an executable target.
154153
let packagePath = tempDir.appending(component: "Project")
@@ -167,6 +166,8 @@ final class BasicTests: XCTestCase {
167166
}
168167

169168
func testSwiftPackageLibsTests() throws {
169+
try skipUnlessAtLeastSwift6()
170+
170171
try XCTSkip("FIXME: swift-test invocations are timing out in Xcode and self-hosted CI")
171172

172173
try withTemporaryDirectory { tempDir in
@@ -225,9 +226,7 @@ final class BasicTests: XCTestCase {
225226
}
226227

227228
func testSwiftRun() throws {
228-
#if swift(<5.5)
229-
try XCTSkipIf(true, "skipping because host compiler doesn't support '-entry-point-function-name'")
230-
#endif
229+
try skipUnlessAtLeastSwift6()
231230

232231
try withTemporaryDirectory { tempDir in
233232
let packagePath = tempDir.appending(component: "secho")
@@ -256,6 +255,8 @@ final class BasicTests: XCTestCase {
256255
}
257256

258257
func testSwiftTest() throws {
258+
try skipUnlessAtLeastSwift6()
259+
259260
try XCTSkip("FIXME: swift-test invocations are timing out in Xcode and self-hosted CI")
260261

261262
try withTemporaryDirectory { tempDir in
@@ -377,3 +378,9 @@ private extension Character {
377378
}
378379
}
379380
}
381+
382+
private func skipUnlessAtLeastSwift6() throws {
383+
#if compiler(<6.0)
384+
try XCTSkipIf(true, "Skipping because test requires at least Swift 6.0")
385+
#endif
386+
}

IntegrationTests/Tests/IntegrationTests/SwiftPMTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ final class SwiftPMTests: XCTestCase {
5353
#if !os(macOS)
5454
try XCTSkip("Test requires macOS")
5555
#endif
56+
#if swift(<6.0)
57+
try XCTSkipIf(true, "Skipping because test requires at least Swift 6.0")
58+
#endif
5659

5760
try withTemporaryDirectory { tmpDir in
5861
let packagePath = tmpDir.appending(component: "foo")
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift open source project
4+
//
5+
// Copyright (c) 2024 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
import Basics
14+
import PackageModel
15+
import XCTest
16+
17+
import class TSCBasic.Process
18+
import struct TSCBasic.StringError
19+
20+
extension Toolchain {
21+
package func skipUnlessAtLeastSwift6(
22+
file: StaticString = #file,
23+
line: UInt = #line
24+
) async throws {
25+
#if compiler(<6.0)
26+
try XCTSkipIf(true, "Skipping because test requires at least Swift 6.0")
27+
#endif
28+
}
29+
}

Tests/BuildTests/BuildSystemDelegateTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import XCTest
1717
import var TSCBasic.localFileSystem
1818

1919
final class BuildSystemDelegateTests: XCTestCase {
20-
func testDoNotFilterLinkerDiagnostics() throws {
20+
func testDoNotFilterLinkerDiagnostics() async throws {
21+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
2122
try XCTSkipIf(!UserToolchain.default.supportsSDKDependentTests(), "skipping because test environment doesn't support this test")
2223
try fixture(name: "Miscellaneous/DoNotFilterLinkerDiagnostics") { fixturePath in
2324
#if !os(macOS)

Tests/FunctionalTests/PluginTests.swift

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ class PluginTests: XCTestCase {
177177
}
178178
}
179179

180-
func testBuildToolWithoutOutputs() throws {
180+
func testBuildToolWithoutOutputs() async throws {
181+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
182+
181183
// Only run the test if the environment in which we're running actually supports Swift concurrency (which the plugin APIs require).
182184
try XCTSkipIf(!UserToolchain.default.supportsSwiftConcurrency(), "skipping because test environment doesn't support concurrency")
183185

@@ -1158,7 +1160,9 @@ class PluginTests: XCTestCase {
11581160
}
11591161
}
11601162

1161-
func testURLBasedPluginAPI() throws {
1163+
func testURLBasedPluginAPI() async throws {
1164+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
1165+
11621166
// Only run the test if the environment in which we're running actually supports Swift concurrency (which the plugin APIs require).
11631167
try XCTSkipIf(!UserToolchain.default.supportsSwiftConcurrency(), "skipping because test environment doesn't support concurrency")
11641168

@@ -1168,7 +1172,9 @@ class PluginTests: XCTestCase {
11681172
}
11691173
}
11701174

1171-
func testDependentPlugins() throws {
1175+
func testDependentPlugins() async throws {
1176+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
1177+
11721178
try XCTSkipIf(!UserToolchain.default.supportsSwiftConcurrency(), "skipping because test environment doesn't support concurrency")
11731179

11741180
try fixture(name: "Miscellaneous/Plugins/DependentPlugins") { fixturePath in

Tests/FunctionalTests/ResourcesTests.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
import Basics
14+
import PackageModel
1415
import SPMTestSupport
1516
import XCTest
1617

@@ -126,7 +127,9 @@ class ResourcesTests: XCTestCase {
126127
}
127128
}
128129

129-
func testResourcesOutsideOfTargetCanBeIncluded() throws {
130+
func testResourcesOutsideOfTargetCanBeIncluded() async throws {
131+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
132+
130133
try testWithTemporaryDirectory { tmpPath in
131134
let packageDir = tmpPath.appending(components: "MyPackage")
132135

Tests/PackageLoadingTests/ManifestLoaderCacheTests.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift open source project
44
//
5-
// Copyright (c) 2020-2023 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2020-2024 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -22,7 +22,10 @@ import func TSCTestSupport.withCustomEnv
2222

2323
@available(macOS 13, iOS 16, tvOS 16, watchOS 9, *)
2424
final class ManifestLoaderCacheTests: XCTestCase {
25+
2526
func testDBCaching() async throws {
27+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
28+
2629
try await testWithTemporaryDirectory { path in
2730
let fileSystem = localFileSystem
2831
let observability = ObservabilitySystem.makeForTesting()
@@ -117,6 +120,8 @@ final class ManifestLoaderCacheTests: XCTestCase {
117120
}
118121

119122
func testInMemoryCaching() async throws {
123+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
124+
120125
let fileSystem = InMemoryFileSystem()
121126
let observability = ObservabilitySystem.makeForTesting()
122127

@@ -206,6 +211,8 @@ final class ManifestLoaderCacheTests: XCTestCase {
206211
}
207212

208213
func testContentBasedCaching() async throws {
214+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
215+
209216
try await testWithTemporaryDirectory { path in
210217
let manifest = """
211218
import PackageDescription
@@ -265,6 +272,8 @@ final class ManifestLoaderCacheTests: XCTestCase {
265272
}
266273

267274
func testCacheInvalidationOnEnv() async throws {
275+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
276+
268277
try await testWithTemporaryDirectory { path in
269278
let fileSystem = InMemoryFileSystem()
270279
let observability = ObservabilitySystem.makeForTesting()
@@ -330,6 +339,8 @@ final class ManifestLoaderCacheTests: XCTestCase {
330339
}
331340

332341
func testCacheDoNotInvalidationExpectedEnv() async throws {
342+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
343+
333344
try await testWithTemporaryDirectory { path in
334345
let fileSystem = InMemoryFileSystem()
335346
let observability = ObservabilitySystem.makeForTesting()
@@ -415,6 +426,8 @@ final class ManifestLoaderCacheTests: XCTestCase {
415426
}
416427

417428
func testInMemoryCacheHappyCase() async throws {
429+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
430+
418431
let content = """
419432
import PackageDescription
420433
let package = Package(

Tests/PackageLoadingTests/PD_6_0_LoadingTests.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift open source project
44
//
5-
// Copyright (c) 2023 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2023-2024 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -16,12 +16,14 @@ import SourceControl
1616
import SPMTestSupport
1717
import XCTest
1818

19-
class PackageDescription6_0LoadingTests: PackageDescriptionLoadingTests {
19+
final class PackageDescription6_0LoadingTests: PackageDescriptionLoadingTests {
2020
override var toolsVersion: ToolsVersion {
2121
.v6_0
2222
}
2323

2424
func testPackageContextGitStatus() async throws {
25+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
26+
2527
let content = """
2628
import PackageDescription
2729
let package = Package(name: "\\(Context.gitInformation?.hasUncommittedChanges == true)")
@@ -34,6 +36,8 @@ class PackageDescription6_0LoadingTests: PackageDescriptionLoadingTests {
3436
}
3537

3638
func testPackageContextGitTag() async throws {
39+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
40+
3741
let content = """
3842
import PackageDescription
3943
let package = Package(name: "\\(Context.gitInformation?.currentTag ?? "")")
@@ -46,6 +50,8 @@ class PackageDescription6_0LoadingTests: PackageDescriptionLoadingTests {
4650
}
4751

4852
func testPackageContextGitCommit() async throws {
53+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
54+
4955
let content = """
5056
import PackageDescription
5157
let package = Package(name: "\\(Context.gitInformation?.currentCommit ?? "")")

Tests/WorkspaceTests/InitTests.swift

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift open source project
44
//
5-
// Copyright (c) 2014-2023 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014-2024 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -16,7 +16,7 @@ import PackageModel
1616
import Workspace
1717
import XCTest
1818

19-
class InitTests: XCTestCase {
19+
final class InitTests: XCTestCase {
2020

2121
// MARK: TSCBasic package creation for each package type.
2222

@@ -53,8 +53,10 @@ class InitTests: XCTestCase {
5353
XCTAssertMatch(manifestContents, .contains(packageWithNameOnly(named: name)))
5454
}
5555
}
56-
57-
func testInitPackageExecutable() throws {
56+
57+
func testInitPackageExecutable() async throws {
58+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
59+
5860
try testWithTemporaryDirectory { tmpPath in
5961
let fs = localFileSystem
6062
let path = tmpPath.appending("Foo")
@@ -98,7 +100,9 @@ class InitTests: XCTestCase {
98100
}
99101
}
100102

101-
func testInitPackageLibraryWithXCTestOnly() throws {
103+
func testInitPackageLibraryWithXCTestOnly() async throws {
104+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
105+
102106
try testWithTemporaryDirectory { tmpPath in
103107
let fs = localFileSystem
104108
let path = tmpPath.appending("Foo")
@@ -148,7 +152,7 @@ class InitTests: XCTestCase {
148152
XCTAssertFileExists(path.appending(components: ".build", triple.platformBuildPathComponent, "debug", "Modules", "Foo.swiftmodule"))
149153
}
150154
}
151-
155+
152156
func testInitPackageLibraryWithSwiftTestingOnly() throws {
153157
try testWithTemporaryDirectory { tmpPath in
154158
let fs = localFileSystem
@@ -235,7 +239,9 @@ class InitTests: XCTestCase {
235239
}
236240
}
237241

238-
func testInitPackageLibraryWithNoTests() throws {
242+
func testInitPackageLibraryWithNoTests() async throws {
243+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
244+
239245
try testWithTemporaryDirectory { tmpPath in
240246
let fs = localFileSystem
241247
let path = tmpPath.appending("Foo")
@@ -339,8 +345,9 @@ class InitTests: XCTestCase {
339345
}
340346

341347
// MARK: Special case testing
342-
343-
func testInitPackageNonc99Directory() throws {
348+
349+
func testInitPackageNonc99Directory() async throws {
350+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
344351
try withTemporaryDirectory(removeTreeOnDeinit: true) { tempDirPath in
345352
XCTAssertDirectoryExists(tempDirPath)
346353

@@ -367,7 +374,9 @@ class InitTests: XCTestCase {
367374
}
368375
}
369376

370-
func testNonC99NameExecutablePackage() throws {
377+
func testNonC99NameExecutablePackage() async throws {
378+
try await UserToolchain.default.skipUnlessAtLeastSwift6()
379+
371380
try withTemporaryDirectory(removeTreeOnDeinit: true) { tempDirPath in
372381
XCTAssertDirectoryExists(tempDirPath)
373382

0 commit comments

Comments
 (0)