-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vladislav Alekseev
committed
Nov 29, 2021
1 parent
8586f8e
commit 28ac5b6
Showing
52 changed files
with
369 additions
and
643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,91 @@ | ||
import Foundation | ||
|
||
public struct BuildArtifacts: Codable, Hashable, CustomStringConvertible { | ||
/// Location of app bundle | ||
public let appBundle: AppBundleLocation? | ||
|
||
/// Location of runner app build artifact (XCTRunner.app) | ||
public let runner: RunnerAppLocation? | ||
|
||
/// Location of xctest bundle with tests to run. Usually it is a part of Runner.app/Plugins. | ||
public let xcTestBundle: XcTestBundle | ||
|
||
/// Location of additional apps that can be launched diring tests. | ||
public let additionalApplicationBundles: [AdditionalAppBundleLocation] | ||
public enum BuildArtifacts: Codable, Hashable, CustomStringConvertible { | ||
case iosLogicTests( | ||
xcTestBundle: XcTestBundle | ||
) | ||
|
||
case iosApplicationTests( | ||
xcTestBundle: XcTestBundle, | ||
appBundle: AppBundleLocation | ||
) | ||
|
||
public init( | ||
appBundle: AppBundleLocation?, | ||
runner: RunnerAppLocation?, | ||
case iosUiTests( | ||
xcTestBundle: XcTestBundle, | ||
additionalApplicationBundles: [AdditionalAppBundleLocation]) | ||
{ | ||
self.appBundle = appBundle | ||
self.runner = runner | ||
self.xcTestBundle = xcTestBundle | ||
self.additionalApplicationBundles = additionalApplicationBundles | ||
appBundle: AppBundleLocation, | ||
runner: RunnerAppLocation, | ||
additionalApplicationBundles: [AdditionalAppBundleLocation] | ||
) | ||
|
||
public var xcTestBundle: XcTestBundle { | ||
switch self { | ||
case .iosLogicTests(let xcTestBundle): | ||
return xcTestBundle | ||
case .iosApplicationTests(let xcTestBundle, _): | ||
return xcTestBundle | ||
case .iosUiTests(let xcTestBundle, _, _, _): | ||
return xcTestBundle | ||
} | ||
} | ||
|
||
private enum CodingKeys: CodingKey { | ||
case xcTestBundle | ||
case appBundle | ||
case runner | ||
case xcTestBundle | ||
case additionalApplicationBundles | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
self.appBundle = try container.decodeIfPresent(AppBundleLocation.self, forKey: .appBundle) | ||
self.runner = try container.decodeIfPresent(RunnerAppLocation.self, forKey: .runner) | ||
self.xcTestBundle = try container.decode(XcTestBundle.self, forKey: .xcTestBundle) | ||
let xcTestBundle = try container.decode(XcTestBundle.self, forKey: .xcTestBundle) | ||
|
||
self.additionalApplicationBundles = try container.decodeIfPresent( | ||
[AdditionalAppBundleLocation].self, forKey: .additionalApplicationBundles | ||
) ?? [] | ||
if let runner = try container.decodeIfPresent(RunnerAppLocation.self, forKey: .runner) { | ||
let appBundle = try container.decode(AppBundleLocation.self, forKey: .appBundle) | ||
self = .iosUiTests( | ||
xcTestBundle: xcTestBundle, | ||
appBundle: appBundle, | ||
runner: runner, | ||
additionalApplicationBundles: try container.decodeIfPresent( | ||
[AdditionalAppBundleLocation].self, forKey: .additionalApplicationBundles | ||
) ?? [] | ||
) | ||
} else if let appBundle = try container.decodeIfPresent(AppBundleLocation.self, forKey: .appBundle) { | ||
self = .iosApplicationTests( | ||
xcTestBundle: xcTestBundle, | ||
appBundle: appBundle | ||
) | ||
} else { | ||
self = .iosLogicTests(xcTestBundle: xcTestBundle) | ||
} | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encode(xcTestBundle, forKey: .xcTestBundle) | ||
try container.encode(additionalApplicationBundles, forKey: .additionalApplicationBundles) | ||
|
||
if let appBundle = appBundle { | ||
switch self { | ||
case .iosLogicTests(let xcTestBundle): | ||
try container.encode(xcTestBundle, forKey: .xcTestBundle) | ||
|
||
case .iosApplicationTests(let xcTestBundle, let appBundle): | ||
try container.encode(xcTestBundle, forKey: .xcTestBundle) | ||
try container.encode(appBundle, forKey: .appBundle) | ||
} | ||
|
||
if let runner = runner { | ||
case .iosUiTests(let xcTestBundle, let appBundle, let runner, let additionalApplicationBundles): | ||
try container.encode(xcTestBundle, forKey: .xcTestBundle) | ||
try container.encode(appBundle, forKey: .appBundle) | ||
try container.encode(runner, forKey: .runner) | ||
try container.encode(additionalApplicationBundles, forKey: .additionalApplicationBundles) | ||
} | ||
} | ||
|
||
public var description: String { | ||
var result: [String] = [] | ||
if let appBundle = appBundle { | ||
result += ["appBundle: \(appBundle)"] | ||
} | ||
if let runner = runner { | ||
result += ["runner: \(runner)"] | ||
} | ||
result += ["xcTestBundle: \(xcTestBundle)"] | ||
if !additionalApplicationBundles.isEmpty { | ||
result += ["additionalApplicationBundles: \(additionalApplicationBundles)"] | ||
switch self { | ||
case .iosLogicTests(let xcTestBundle): | ||
return "iOS logic tests \(xcTestBundle)" | ||
case .iosApplicationTests(let xcTestBundle, let appBundle): | ||
return "iOS application tests \(xcTestBundle) \(appBundle)" | ||
case .iosUiTests(let xcTestBundle, let appBundle, let runner, let additionalApplicationBundles): | ||
return "iOS UI tests \(xcTestBundle) \(appBundle) \(runner) \(additionalApplicationBundles)" | ||
} | ||
return "<\(type(of: self)): " + result.joined(separator: " ") + ">" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.