Emcee

Форк
0
/
AppleBuildArtifacts.swift 
91 строка · 3.4 Кб
1
import Foundation
2

3
public enum AppleBuildArtifacts: Codable, Hashable, CustomStringConvertible {
4
    case iosLogicTests(
5
        xcTestBundle: XcTestBundle
6
    )
7

8
    case iosApplicationTests(
9
        xcTestBundle: XcTestBundle,
10
        appBundle: AppBundleLocation
11
    )
12

13
    case iosUiTests(
14
        xcTestBundle: XcTestBundle,
15
        appBundle: AppBundleLocation,
16
        runner: RunnerAppLocation,
17
        additionalApplicationBundles: [AdditionalAppBundleLocation]
18
    )
19
    
20
    public var xcTestBundle: XcTestBundle {
21
        switch self {
22
        case .iosLogicTests(let xcTestBundle):
23
            return xcTestBundle
24
        case .iosApplicationTests(let xcTestBundle, _):
25
            return xcTestBundle
26
        case .iosUiTests(let xcTestBundle, _, _, _):
27
            return xcTestBundle
28
        }
29
    }
30

31
    private enum CodingKeys: CodingKey {
32
        case xcTestBundle
33
        case appBundle
34
        case runner
35
        case additionalApplicationBundles
36
    }
37

38
    public init(from decoder: Decoder) throws {
39
        let container = try decoder.container(keyedBy: CodingKeys.self)
40
        let xcTestBundle = try container.decode(XcTestBundle.self, forKey: .xcTestBundle)
41

42
        if let runner = try container.decodeIfPresent(RunnerAppLocation.self, forKey: .runner) {
43
            let appBundle = try container.decode(AppBundleLocation.self, forKey: .appBundle)
44
            self = .iosUiTests(
45
                xcTestBundle: xcTestBundle,
46
                appBundle: appBundle,
47
                runner: runner,
48
                additionalApplicationBundles: try container.decodeIfPresent(
49
                    [AdditionalAppBundleLocation].self, forKey: .additionalApplicationBundles
50
                ) ?? []
51
            )
52
        } else if let appBundle = try container.decodeIfPresent(AppBundleLocation.self, forKey: .appBundle) {
53
            self = .iosApplicationTests(
54
                xcTestBundle: xcTestBundle,
55
                appBundle: appBundle
56
            )
57
        } else {
58
            self = .iosLogicTests(xcTestBundle: xcTestBundle)
59
        }
60
    }
61

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

65
        switch self {
66
        case .iosLogicTests(let xcTestBundle):
67
            try container.encode(xcTestBundle, forKey: .xcTestBundle)
68

69
        case .iosApplicationTests(let xcTestBundle, let appBundle):
70
            try container.encode(xcTestBundle, forKey: .xcTestBundle)
71
            try container.encode(appBundle, forKey: .appBundle)
72

73
        case .iosUiTests(let xcTestBundle, let appBundle, let runner, let additionalApplicationBundles):
74
            try container.encode(xcTestBundle, forKey: .xcTestBundle)
75
            try container.encode(appBundle, forKey: .appBundle)
76
            try container.encode(runner, forKey: .runner)
77
            try container.encode(additionalApplicationBundles, forKey: .additionalApplicationBundles)
78
        }
79
    }
80
    
81
    public var description: String {
82
        switch self {
83
        case .iosLogicTests(let xcTestBundle):
84
            return "iOS logic tests \(xcTestBundle)"
85
        case .iosApplicationTests(let xcTestBundle, let appBundle):
86
            return "iOS application tests \(xcTestBundle) \(appBundle)"
87
        case .iosUiTests(let xcTestBundle, let appBundle, let runner, let additionalApplicationBundles):
88
            return "iOS UI tests \(xcTestBundle) \(appBundle) \(runner) \(additionalApplicationBundles)"
89
        }
90
    }
91
}
92

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.