Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/package_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ on:
default: true
cxx_interop_swift_versions:
type: string
description: "Swift version list (JSON array) for the Cxx interop check. Empty uses the newest release version in linux_swift_versions."
description: "Swift version list (JSON array) for the Cxx interop check. Empty uses linux_swift_versions."
default: ""

# ----- Version lists (JSON arrays) -----
Expand Down
19 changes: 3 additions & 16 deletions .github/workflows/scripts/matrix/generate-matrix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,10 @@ extension Configuration {
return self.macOSVersions
}

/// The Swift versions the Cxx interop check runs.
///
/// The check is supplementary rather than a full compatibility check, so it runs on the
/// newest release in the Linux list unless a caller names more.
/// The Swift versions the Cxx interop check runs: those the Linux tests run, unless a caller
/// names others.
var cxxInteropSwiftVersions: [String] {
if self.cxxInteropVersions.isEmpty {
return [SwiftVersion.newestRelease(in: self.linuxVersions, releases: self.releases)]
}
return self.cxxInteropVersions
self.cxxInteropVersions.isEmpty ? self.linuxVersions : self.cxxInteropVersions
}

/// The timeout an entry on this platform carries, or nil to leave the executor's own.
Expand Down Expand Up @@ -1634,14 +1629,6 @@ struct SwiftVersion: Comparable {
}
return version
}

/// The newest release a version list holds, falling back to its last entry when the list is
/// all nightlies.
static func newestRelease(in versions: [String], releases: SwiftReleases) -> String {
let released = versions.filter { !VersionLabel($0).isNightly }
let newest = released.max { releases.ordered($0) < releases.ordered($1) }
return newest ?? versions.last ?? ""
}
}

/// The oldest toolchain the package builds on. A version below it cannot resolve the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,19 +460,23 @@ struct EmptiedByTheMinimumTests {
#expect(!raised.entries.isEmpty)
}

@Test("The default Cxx-interop version is filtered like any other")
func defaultedVersionIsChecked() throws {
// The check names no version: it defaults to the newest release in the Linux
// list, which a newer manifest puts below the minimum. This is what a caller
// bumping swift-tools-version ahead of the released toolchains hits, and the
// Linux and Windows nightlies survive to keep the matrix non-empty.
@Test("The Cxx interop check follows the Linux list and is filtered like it")
func cxxInteropFollowsTheLinuxList() throws {
// The check names no versions, so it runs on each version the Linux tests run, and a
// manifest that needs a newer toolchain removes the same ones from both.
let generated = try Generator.run(
["ENABLE_CXX_INTEROP": "true", "ENABLE_LINUX": "true", "ENABLE_WINDOWS": "true"],
manifests: ["Package.swift": Generator.manifest(toolsVersion: "6.5")]
[
"ENABLE_CXX_INTEROP": "true",
"ENABLE_LINUX": "true",
"LINUX_SWIFT_VERSIONS": #"["6.1","6.2","nightly-main"]"#,
],
manifests: ["Package.swift": Generator.manifest(toolsVersion: "6.2")]
)
#expect(generated.exitCode == 0, "\(generated.standardError)")
#expect(
generated.names.filter { $0.hasPrefix("Cxx interop") }
== ["Cxx interop Swift 6.2", "Cxx interop Swift nightly-main"]
)
#expect(generated.exitCode != 0)
#expect(generated.standardError.contains("enable_cxx_interop"), "\(generated.standardError)")
#expect(generated.standardError.contains("current"), "\(generated.standardError)")
}

@Test(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ struct EntryPointDefaultTests {
"Android SDK Swift current NDK r30",
"Android SDK Swift nightly-release NDK r30",
"Android SDK Swift nightly-main NDK r30",
"Cxx interop Swift current-2",
"Cxx interop Swift current-1",
"Cxx interop Swift current",
"Cxx interop Swift nightly-release",
"Cxx interop Swift nightly-main",
]
),
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,14 @@ struct SDKTests {

@Suite("Cxx interop")
struct SupplementaryCheckTests {
@Test("Cxx interop defaults to one version and can enter a subdirectory")
@Test("Cxx interop defaults to the Linux versions and can enter a subdirectory")
func cxxInteropScope() throws {
let generated = try Generator.run([
"ENABLE_CXX_INTEROP": "true",
"LINUX_SWIFT_VERSIONS": #"["6.2","6.3"]"#,
"LINUX_SETUP_COMMAND": "cd sub",
])
#expect(generated.count == 1)
#expect(generated.entries.first?.swiftBuild?.swiftVersion == "6.3")
#expect(generated.entries.compactMap { $0.swiftBuild?.swiftVersion } == ["6.2", "6.3"])
// check-cxx-interop.sh reads the manifest in the working directory.
#expect(generated.entries.first?.setupCommand == "cd sub")
#expect(generated.entries.first?.command == "${SCRIPTS_ROOT}/check-cxx-interop.sh")
Expand Down
Loading