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
21 changes: 11 additions & 10 deletions .github/workflows/package_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,13 @@ on:
linux_version_overrides:
type: string
description: >-
Per-Linux-version overrides (JSON/YAML object). A string value adds arguments, which reach
every Linux job group; an object with `arguments` and/or `command` can also replace the
command for that version. Replacing needs a single command configured for the groups that
run it, and the Cxx interop check refuses it, since its command is the check itself.
The key `default` sets the arguments for every version whose own key does not name
some, and arguments written alone are the same as `default`.
Per-Linux-version overrides (JSON/YAML object) for the Linux tests. A string value adds
arguments; an object with `arguments` and/or `command` can also replace the command for
that version, which needs linux_command holding a single command. The SDK builds and the
Cxx interop check do not read it: the SDK builds have inputs of their own, and swift_flags
and swift_nightly_flags reach all of them. The key `default` sets the arguments for every
version whose own key does not name some, and arguments written alone are the same as
`default`.
default: "{}"
windows_version_overrides:
type: string
Expand All @@ -263,25 +264,25 @@ on:
type: string
description: >-
Per-version overrides (JSON/YAML object) for the Static Linux SDK build, in the form
linux_version_overrides takes, including `default`. Empty uses linux_version_overrides.
linux_version_overrides takes, including `default`.
default: ""
wasm_sdk_version_overrides:
type: string
description: >-
Per-version overrides (JSON/YAML object) for the Wasm SDK build, in the form
linux_version_overrides takes, including `default`. Empty uses linux_version_overrides.
linux_version_overrides takes, including `default`.
default: ""
embedded_wasm_sdk_version_overrides:
type: string
description: >-
Per-version overrides (JSON/YAML object) for the Embedded Wasm SDK build, in the form
linux_version_overrides takes, including `default`. Empty uses linux_version_overrides.
linux_version_overrides takes, including `default`.
default: ""
android_sdk_version_overrides:
type: string
description: >-
Per-version overrides (JSON/YAML object) for the Android SDK build, in the form
linux_version_overrides takes, including `default`. Empty uses linux_version_overrides. The Android build
linux_version_overrides takes, including `default`. The Android build
takes the command from an override but not its arguments.
default: ""

Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/scripts/matrix/generate-matrix.swift
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,12 @@ extension Generator {
// The runner expands SCRIPTS_ROOT, so that reference stays literal here.
commandSource: .fixed,
commands: "${SCRIPTS_ROOT}/check-cxx-interop.sh",
overrides: self.configuration.linuxOverrides,
namePrefix: "Cxx interop Swift"
),
platform: .linux,
minimum: self.minimum,
releases: self.configuration.releases,
flags: self.configuration.flags(with: self.configuration.linuxOverrides),
flags: self.configuration.flags(),
setupCommand: self.configuration.enteringPackage(after: self.configuration.linuxSetupCommand),
environment: self.configuration.linuxEnvironment,
runners: [self.configuration.primaryLinuxRunner],
Expand Down Expand Up @@ -466,8 +465,7 @@ extension Generator {
/// fetches a toolchain matched to the SDK, and job-runner-linux.sh refuses an entry
/// carrying both an sdk and a container.
private func sdkJobs(_ build: SDKBuild) -> SwiftBuildJobs {
// A build with no overrides of its own takes the Linux ones.
let overrides = build.overrides.isEmpty ? self.configuration.linuxOverrides : build.overrides
let overrides = build.overrides
var jobs = SwiftBuildJobs(
settings: JobGroupSettings(
enableInput: build.enableInput,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,71 +423,65 @@ struct CommandClassificationTests {
@Suite("A per-version command override and the command axis")
struct VersionOverrideCommandTests {
@Test(
"The override reaches every group that runs the caller's own command",
"Each group that runs the caller's own command takes the override from its own input",
arguments: [
("ENABLE_LINUX", "LINUX_SWIFT_VERSIONS", "Linux Swift 6.3"),
("ENABLE_LINUX_STATIC_SDK_BUILD", "LINUX_STATIC_SDK_VERSIONS", "Static Linux SDK Swift 6.3"),
("ENABLE_WASM_SDK_BUILD", "WASM_SDK_VERSIONS", "Wasm SDK Swift 6.3"),
("ENABLE_LINUX", "LINUX_SWIFT_VERSIONS", "LINUX_VERSION_OVERRIDES", "Linux Swift 6.3"),
(
"ENABLE_LINUX_STATIC_SDK_BUILD", "LINUX_STATIC_SDK_VERSIONS",
"LINUX_STATIC_SDK_VERSION_OVERRIDES", "Static Linux SDK Swift 6.3"
),
(
"ENABLE_WASM_SDK_BUILD", "WASM_SDK_VERSIONS", "WASM_SDK_VERSION_OVERRIDES",
"Wasm SDK Swift 6.3"
),
(
"ENABLE_EMBEDDED_WASM_SDK_BUILD", "EMBEDDED_WASM_SDK_VERSIONS",
"Embedded Wasm SDK Swift 6.3"
"EMBEDDED_WASM_SDK_VERSION_OVERRIDES", "Embedded Wasm SDK Swift 6.3"
),
(
"ENABLE_ANDROID_SDK_BUILD", "ANDROID_SDK_VERSIONS", "ANDROID_SDK_VERSION_OVERRIDES",
"Android SDK Swift 6.3 NDK r27d"
),
("ENABLE_ANDROID_SDK_BUILD", "ANDROID_SDK_VERSIONS", "Android SDK Swift 6.3 NDK r27d"),
]
)
func overrideReplacesTheCallersCommand(
enableKey: String,
versionsKey: String,
overridesKey: String,
expectedName: String
) throws {
// Every one of these honored `arguments:` already. A group reading the base
// command instead ran what the caller replaced, and still passed.
var environment = [
"ANDROID_NDK_VERSIONS": #"["r27d"]"#,
"LINUX_SWIFT_VERSIONS": #"["6.3"]"#,
"LINUX_VERSION_OVERRIDES": #"{"6.3": {"command": "swift test --filter Foo"}}"#,
]
environment[enableKey] = "true"
environment[versionsKey] = #"["6.3"]"#
environment[overridesKey] = #"{"6.3": {"command": "swift test --filter Foo"}}"#

let generated = try Generator.run(environment)
#expect(generated.exitCode == 0, "\(generated.standardError)")
#expect(generated.entry(named: expectedName)?.command == "swift test --filter Foo")
}

@Test("The override fails on a group whose command is the check itself")
func overrideFailsWhereTheCommandIsTheGroup() throws {
// Honoring it would leave a job named for a check it no longer runs; dropping
// it silently is how a caller believes a command reached a job it did not.
let generated = try Generator.run([
"ENABLE_CXX_INTEROP": "true",
"LINUX_SWIFT_VERSIONS": #"["6.3"]"#,
"LINUX_VERSION_OVERRIDES": #"{"6.3": {"command": "swift test --filter Foo"}}"#,
])
#expect(generated.exitCode != 0)
#expect(generated.count == 0)
#expect(generated.standardError.contains("Cxx interop Swift"), "\(generated.standardError)")
#expect(generated.standardError.contains("linux_version_overrides"))
}

@Test("Arguments still reach a group whose command is the check itself")
func argumentsStillReachEveryGroup() throws {
// Only `command:` is refused. A string override, which is the common case,
// carries arguments and has to go on working.
@Test("The Cxx interop check takes no Linux overrides")
func cxxInteropTakesNoLinuxOverrides() throws {
// The overrides are for the Linux tests. A flag meant for them, such as warnings as errors,
// must not reach a check the caller never asked to carry it.
let generated = try Generator.run([
"ENABLE_LINUX": "true",
"ENABLE_CXX_INTEROP": "true",
"LINUX_SWIFT_VERSIONS": #"["6.3"]"#,
"LINUX_VERSION_OVERRIDES": #"{"6.3": "-Xswiftc -warnings-as-errors"}"#,
])
#expect(generated.exitCode == 0, "\(generated.standardError)")
#expect(generated.count == 1)
for entry in generated.entries {
#expect(entry.commandArguments == ["-Xswiftc", "-warnings-as-errors"], "\(entry.name)")
}
#expect(
generated.entry(named: "Cxx interop Swift 6.3")?.command
== "${SCRIPTS_ROOT}/check-cxx-interop.sh"
generated.entry(named: "Linux Swift 6.3")?.commandArguments == ["-Xswiftc", "-warnings-as-errors"]
)
let cxx = try #require(generated.entry(named: "Cxx interop Swift 6.3"))
#expect(cxx.commandArguments == [])
#expect(cxx.command == "${SCRIPTS_ROOT}/check-cxx-interop.sh")
}

@Test("A version that group does not run is not its business")
Expand All @@ -512,11 +506,11 @@ struct VersionOverrideCommandTests {
"The override fails when more than one command is configured",
arguments: [
(
"LINUX_COMMAND", "linux_command",
"LINUX_COMMAND", "linux_command", "LINUX_VERSION_OVERRIDES",
["ENABLE_LINUX": "true", "LINUX_SWIFT_VERSIONS": #"["6.3"]"#]
),
(
"LINUX_STATIC_SDK_COMMAND", "linux_static_sdk_command",
"LINUX_STATIC_SDK_COMMAND", "linux_static_sdk_command", "LINUX_STATIC_SDK_VERSION_OVERRIDES",
[
"ENABLE_LINUX_STATIC_SDK_BUILD": "true", "LINUX_STATIC_SDK_VERSIONS": #"["6.3"]"#,
"LINUX_SWIFT_VERSIONS": #"["6.3"]"#,
Expand All @@ -527,6 +521,7 @@ struct VersionOverrideCommandTests {
func overrideNeedsOneCommandToReplace(
key: String,
reported: String,
overridesKey: String,
enables: [String: String]
) throws {
// An override keyed on the version alone says nothing about which label it
Expand All @@ -535,7 +530,7 @@ struct VersionOverrideCommandTests {
// which is the one to change.
var environment = enables
environment[key] = "test: swift test\nbuild: swift build"
environment["LINUX_VERSION_OVERRIDES"] = #"{"6.3": {"command": "swift build"}}"#
environment[overridesKey] = #"{"6.3": {"command": "swift build"}}"#
let generated = try Generator.run(environment)
#expect(generated.exitCode != 0)
#expect(generated.count == 0)
Expand Down Expand Up @@ -570,7 +565,7 @@ struct VersionOverrideCommandTests {
"LINUX_SWIFT_VERSIONS": #"["6.3"]"#,
"LINUX_STATIC_SDK_VERSIONS": #"["6.2"]"#,
"LINUX_COMMAND": "test: swift test\nrelease: swift build -c release",
"LINUX_VERSION_OVERRIDES": #"{"6.2": {"command": "swift build --static-swift-stdlib"}}"#,
"LINUX_STATIC_SDK_VERSION_OVERRIDES": #"{"6.2": {"command": "swift build --static-swift-stdlib"}}"#,
])
#expect(generated.exitCode == 0, "\(generated.standardError)")
#expect(
Expand All @@ -581,7 +576,7 @@ struct VersionOverrideCommandTests {
#expect(generated.names.contains("release Linux Swift 6.3"))
}

@Test("An SDK build's own overrides win over the Linux ones, and an absent set falls back")
@Test("An SDK build takes only its own overrides, never the Linux ones")
func sdkBuildTakesItsOwnOverrides() throws {
let generated = try Generator.run([
"ENABLE_LINUX": "false",
Expand All @@ -598,7 +593,7 @@ struct VersionOverrideCommandTests {
#expect(wasm.command == "swift build --target Core")
#expect(wasm.commandArguments?.contains("-warnings-as-errors") != true)
let staticLinux = try #require(generated.entry(named: "Static Linux SDK Swift 6.3"))
#expect(staticLinux.commandArguments == ["-Xswiftc", "-warnings-as-errors"])
#expect(staticLinux.commandArguments == [])
}

@Test("An SDK build's overrides naming a version it does not run fail the run")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,31 +529,19 @@ struct InvariantTests {
#expect(generated.standardError.contains("nightly-next"))
}

@Test("A Linux override key may name a version from any enabled Linux list")
func overrideKeysValidatedAgainstEveryLinuxList() throws {
// The Cxx-interop and SDK lists are independent of the test sweep, and every
// one of them draws its arguments from linux_version_overrides. Checking the
// sweep alone rejects a key naming a version only the Cxx interop check runs.
@Test("A Linux override key must name a version the Linux tests run")
func overrideKeysAreValidatedAgainstTheLinuxTests() throws {
// The Cxx interop check and the SDK builds take no Linux overrides, so a key naming only a
// version they run reaches nothing; accepting it would drop the arguments and still pass.
let generated = try Generator.run([
"ENABLE_LINUX": "true",
"ENABLE_CXX_INTEROP": "true",
"LINUX_SWIFT_VERSIONS": #"["6.3"]"#,
"CXX_INTEROP_SWIFT_VERSIONS": #"["6.2","6.3"]"#,
"LINUX_VERSION_OVERRIDES": #"{"6.2":"-Xswiftc -DX"}"#,
])
#expect(generated.exitCode == 0)
#expect(generated.entry(named: "Cxx interop Swift 6.2")?.commandArguments == ["-Xswiftc", "-DX"])
#expect(generated.entry(named: "Linux Swift 6.3")?.commandArguments == [])

// A key naming no enabled list is still rejected.
let bogus = try Generator.run([
"ENABLE_LINUX": "true",
"ENABLE_CXX_INTEROP": "true",
"LINUX_SWIFT_VERSIONS": #"["6.3"]"#,
"CXX_INTEROP_SWIFT_VERSIONS": #"["6.3"]"#,
"LINUX_VERSION_OVERRIDES": #"{"6.2":"-Xswiftc -DX"}"#,
])
#expect(bogus.exitCode != 0)
#expect(generated.exitCode != 0)
#expect(generated.standardError.contains("6.2"), "\(generated.standardError)")
}

@Test(
Expand Down
Loading