splitting runtime sim version from the os version

This commit is contained in:
Mauro Romito
2026-04-27 12:24:32 +02:00
committed by Mauro
parent 04202676aa
commit fa801b5791
3 changed files with 16 additions and 17 deletions
+2 -4
View File
@@ -5,14 +5,12 @@ struct PreviewTests: AsyncParsableCommand {
static let configuration = CommandConfiguration(commandName: "preview-tests", static let configuration = CommandConfiguration(commandName: "preview-tests",
abstract: "Runs the preview test CI workflow, with optional snapshot recording.") abstract: "Runs the preview test CI workflow, with optional snapshot recording.")
@Option(help: "iOS version for the simulator.")
var osVersion = "26.4"
@Flag(help: "Re-record snapshots for tests that fail or are missing a reference image.") @Flag(help: "Re-record snapshots for tests that fail or are missing a reference image.")
var record = false var record = false
private static let scheme = "PreviewTests" private static let scheme = "PreviewTests"
private static let device = "iPhone SE (3rd generation)" private static let device = "iPhone SE (3rd generation)"
private static let osVersion = "26.4.1"
private static let simulatorType = "com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation" private static let simulatorType = "com.apple.CoreSimulator.SimDeviceType.iPhone-SE-3rd-generation"
private static let testPlanPath = "PreviewTests/SupportingFiles/PreviewTests.xctestplan" private static let testPlanPath = "PreviewTests/SupportingFiles/PreviewTests.xctestplan"
@@ -27,7 +25,7 @@ struct PreviewTests: AsyncParsableCommand {
try await RunTests.parse([ try await RunTests.parse([
"--scheme", Self.scheme, "--scheme", Self.scheme,
"--device", Self.device, "--device", Self.device,
"--os-version", osVersion, "--os-version", Self.osVersion,
"--create-simulator-name", Self.device, "--create-simulator-name", Self.device,
"--create-simulator-type", Self.simulatorType "--create-simulator-type", Self.simulatorType
]).run() ]).run()
+8 -4
View File
@@ -21,7 +21,11 @@ struct RunTests: AsyncParsableCommand {
var device = "iPhone 17" var device = "iPhone 17"
@Option(help: "The iOS version to use for the simulator runtime (e.g. '26.4').") @Option(help: "The iOS version to use for the simulator runtime (e.g. '26.4').")
var osVersion = "26.4" var osVersion = "26.4.1"
var runtime: String {
osVersion.split(separator: ".").prefix(2).joined(separator: ".")
}
@Option(help: "Number of times to retry failed tests. Only the failing tests are re-run, not the entire suite.") @Option(help: "Number of times to retry failed tests. Only the failing tests are re-run, not the entire suite.")
var retries = 0 var retries = 0
@@ -48,7 +52,7 @@ struct RunTests: AsyncParsableCommand {
} }
private var simulatorRuntime: String { private var simulatorRuntime: String {
"com.apple.CoreSimulator.SimRuntime.iOS-\(osVersion.replacingOccurrences(of: ".", with: "-"))" "com.apple.CoreSimulator.SimRuntime.iOS-\(runtime.replacingOccurrences(of: ".", with: "-"))"
} }
func run() async throws { func run() async throws {
@@ -81,9 +85,9 @@ struct RunTests: AsyncParsableCommand {
private func createSimulatorIfNecessary(name: String, type: String) async throws { private func createSimulatorIfNecessary(name: String, type: String) async throws {
logger.info("Checking for simulator '\(name)'…") logger.info("Checking for simulator '\(name)'…")
guard let simulators = try await CI.run(.path("/bin/zsh"), ["-cu", "xcrun simctl list devices \"iOS \(osVersion)\" available"], guard let simulators = try await CI.run(.path("/bin/zsh"), ["-cu", "xcrun simctl list devices \"iOS \(runtime)\" available"],
output: .string(limit: 4096)).standardOutput else { output: .string(limit: 4096)).standardOutput else {
logger.info("No simulators found for iOS \(osVersion). Creating '\(name)'…") logger.info("No simulators found for iOS \(runtime). Creating '\(name)'…")
try await createSimulator(name: name, type: type) try await createSimulator(name: name, type: type)
return return
} }
+6 -9
View File
@@ -4,16 +4,13 @@ import Foundation
struct UnitTests: AsyncParsableCommand { struct UnitTests: AsyncParsableCommand {
static let configuration = CommandConfiguration(commandName: "unit-tests", static let configuration = CommandConfiguration(commandName: "unit-tests",
abstract: "Runs the unit test CI workflow: lint, unit tests, preview tests, and result collection.") abstract: "Runs the unit test CI workflow: lint, unit tests, preview tests, and result collection.")
@Option(help: "Device name for unit tests.")
var device = "iPhone 17"
@Option(help: "iOS version for the simulator.")
var osVersion = "26.4.1"
@Flag(help: "Skip preview tests") @Flag(help: "Skip preview tests")
var skipPreviews = false var skipPreviews = false
private static let osVersion = "26.4.1"
private static let device = "iPhone 17"
func run() async throws { func run() async throws {
try await CI.lint() try await CI.lint()
@@ -24,8 +21,8 @@ struct UnitTests: AsyncParsableCommand {
logger.info("\n🧪 Running unit tests…\n") logger.info("\n🧪 Running unit tests…\n")
try await RunTests.parse([ try await RunTests.parse([
"--scheme", "UnitTests", "--scheme", "UnitTests",
"--device", device, "--device", Self.device,
"--os-version", osVersion, "--os-version", Self.osVersion,
"--retries", "3" "--retries", "3"
]).run() ]).run()
} catch { } catch {