-
Notifications
You must be signed in to change notification settings - Fork 432
/
FBXCTestContext.m
64 lines (47 loc) · 1.66 KB
/
FBXCTestContext.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import "FBXCTestContext.h"
#import <XCTestBootstrap/XCTestBootstrap.h>
#import "FBXCTestSimulatorFetcher.h"
#import "FBXCTestCommandLine.h"
@interface FBXCTestContext ()
@property (nonatomic, strong, readwrite, nullable) FBXCTestSimulatorFetcher *simulatorFetcher;
@end
@implementation FBXCTestContext
#pragma mark Initializers
+ (instancetype)contextWithReporter:(nullable id<FBXCTestReporter, FBXCTestReporterWithFiles>)reporter logger:(nullable FBXCTestLogger *)logger
{
return [[FBXCTestContext alloc] initWithReporter:reporter logger:logger];
}
- (instancetype)initWithReporter:(nullable id<FBXCTestReporter,FBXCTestReporterWithFiles>)reporter logger:(nullable FBXCTestLogger *)logger
{
self = [super init];
if (!self) {
return nil;
}
_reporter = reporter;
_logger = logger;
return self;
}
#pragma mark Public
- (FBFuture<FBSimulator *> *)simulatorForCommandLine:(FBXCTestCommandLine *)commmandLine
{
if (!self.simulatorFetcher) {
NSError *error = nil;
FBXCTestSimulatorFetcher *fetcher = [FBXCTestSimulatorFetcher fetcherWithWorkingDirectory:commmandLine.configuration.workingDirectory logger:self.logger error:&error];
if (!fetcher) {
return [FBFuture futureWithError:error];
}
self.simulatorFetcher = fetcher;
}
return [self.simulatorFetcher fetchSimulatorForCommandLine:commmandLine];
}
- (FBFuture<NSNull *> *)finishedExecutionOnSimulator:(FBSimulator *)simulator
{
return [self.simulatorFetcher returnSimulator:simulator];
}
@end