diff --git a/.github/workflows/package_test.yml b/.github/workflows/package_test.yml index a47605be..1bde8535 100644 --- a/.github/workflows/package_test.yml +++ b/.github/workflows/package_test.yml @@ -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) ----- diff --git a/.github/workflows/scripts/matrix/generate-matrix.swift b/.github/workflows/scripts/matrix/generate-matrix.swift index d21a5526..04268be4 100644 --- a/.github/workflows/scripts/matrix/generate-matrix.swift +++ b/.github/workflows/scripts/matrix/generate-matrix.swift @@ -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. @@ -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 diff --git a/tests/MatrixGeneratorValidator/Tests/MatrixGeneratorTests/CoreTests.swift b/tests/MatrixGeneratorValidator/Tests/MatrixGeneratorTests/CoreTests.swift index b9eb4bd3..0879bc57 100644 --- a/tests/MatrixGeneratorValidator/Tests/MatrixGeneratorTests/CoreTests.swift +++ b/tests/MatrixGeneratorValidator/Tests/MatrixGeneratorTests/CoreTests.swift @@ -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( diff --git a/tests/MatrixGeneratorValidator/Tests/MatrixGeneratorTests/EntryPointTests.swift b/tests/MatrixGeneratorValidator/Tests/MatrixGeneratorTests/EntryPointTests.swift index f271f295..89637e51 100644 --- a/tests/MatrixGeneratorValidator/Tests/MatrixGeneratorTests/EntryPointTests.swift +++ b/tests/MatrixGeneratorValidator/Tests/MatrixGeneratorTests/EntryPointTests.swift @@ -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", ] ), ( diff --git a/tests/MatrixGeneratorValidator/Tests/MatrixGeneratorTests/JobGroupTests.swift b/tests/MatrixGeneratorValidator/Tests/MatrixGeneratorTests/JobGroupTests.swift index ef3eb51e..b25f478c 100644 --- a/tests/MatrixGeneratorValidator/Tests/MatrixGeneratorTests/JobGroupTests.swift +++ b/tests/MatrixGeneratorValidator/Tests/MatrixGeneratorTests/JobGroupTests.swift @@ -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")