Skip to content

Continue encoding value for deprecated property in runner plan snapshot to avoid decoding error in clients #1023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2025
Merged
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
25 changes: 24 additions & 1 deletion Sources/Testing/Running/Runner.Plan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension Runner {
public enum Action: Sendable {
/// A type describing options to apply to actions of case
/// ``Runner/Plan/Action/run(options:)`` when they are run.
public struct RunOptions: Sendable, Codable {
public struct RunOptions: Sendable {
/// Whether or not this step should be run in parallel with other tests.
///
/// By default, all steps in a runner plan are run in parallel if the
Expand Down Expand Up @@ -347,6 +347,29 @@ extension Runner.Plan {
}
}

extension Runner.Plan.Action.RunOptions: Codable {
private enum CodingKeys: CodingKey {
case isParallelizationEnabled
}

public init(from decoder: any Decoder) throws {
// No-op. This initializer cannot be synthesized since `CodingKeys` includes
// a case representing a non-stored property. See comment about the
// `isParallelizationEnabled` property in `encode(to:)`.
self.init()
}

public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)

// The `isParallelizationEnabled` property was removed after this type was
// first introduced. Its value was never actually used in a meaningful way
// by known clients, but its absence can cause decoding errors, so to avoid
// such problems, continue encoding a hardcoded value.
try container.encode(false, forKey: .isParallelizationEnabled)
}
}

#if !SWT_NO_SNAPSHOT_TYPES
// MARK: - Snapshotting

Expand Down