Skip to content

Commit

Permalink
Require a specific snapshotting device minor OS version when running …
Browse files Browse the repository at this point in the history
…PreviewTests
  • Loading branch information
stefanceriu committed Sep 11, 2024
1 parent 65bacfa commit 84a3ffc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 4 additions & 6 deletions PreviewTests/Sources/PreviewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import SwiftUI
class PreviewTests: XCTestCase {
private let deviceConfig: ViewImageConfig = .iPhoneX
private var simulatorDevice: String? = "iPhone14,6" // iPhone SE 3rd Generation
private var requiredOSVersion: Int? = 17
private var requiredOSVersion = (major: 17, minor: 5)
private let snapshotDevices = ["iPhone 15", "iPad"]

override func setUp() {
Expand Down Expand Up @@ -1084,11 +1084,9 @@ class PreviewTests: XCTestCase {
}
}

if let requiredOSVersion {
let osVersion = ProcessInfo().operatingSystemVersion
guard osVersion.majorVersion == requiredOSVersion else {
fatalError("Switch to iOS \(requiredOSVersion) for these tests.")
}
let osVersion = ProcessInfo().operatingSystemVersion
guard osVersion.majorVersion == requiredOSVersion.major, osVersion.minorVersion == requiredOSVersion.minor else {
fatalError("Switch to iOS \(requiredOSVersion) for these tests.")
}
}
}
Expand Down
10 changes: 4 additions & 6 deletions Tools/Sourcery/PreviewTests.stencil
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {{ import }}
class PreviewTests: XCTestCase {
private let deviceConfig: ViewImageConfig = .iPhoneX
private var simulatorDevice: String? = "iPhone14,6" // iPhone SE 3rd Generation
private var requiredOSVersion: Int? = 17
private var requiredOSVersion = (major: 17, minor: 5)
private let snapshotDevices = ["iPhone 15", "iPad"]


Expand Down Expand Up @@ -163,11 +163,9 @@ class PreviewTests: XCTestCase {
}
}

if let requiredOSVersion {
let osVersion = ProcessInfo().operatingSystemVersion
guard osVersion.majorVersion == requiredOSVersion else {
fatalError("Switch to iOS \(requiredOSVersion) for these tests.")
}
let osVersion = ProcessInfo().operatingSystemVersion
guard osVersion.majorVersion == requiredOSVersion.major, osVersion.minorVersion == requiredOSVersion.minor else {
fatalError("Switch to iOS \(requiredOSVersion) for these tests.")
}
}
}
Expand Down

0 comments on commit 84a3ffc

Please sign in to comment.