Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small cleanups pre 12.5 #495

Merged
merged 2 commits into from
Jun 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions bp/src/BPSimulator.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#import "BPConstants.h"
#import "BPCreateSimulatorHandler.h"
#import "BPSimulator.h"
#import "BPTestBundleConnection.h"
#import "BPTestDaemonConnection.h"
#import "BPTreeParser.h"
#import "BPUtils.h"
#import "BPWaitTimer.h"
Expand Down
1 change: 0 additions & 1 deletion bp/src/BPTestBundleConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
@end

@interface BPTestBundleConnection : NSObject
@property (nonatomic, strong) BPConfiguration *config;
@property (nonatomic, strong) BPExecutionContext *context;
@property (nonatomic, strong) BPSimulator *simulator;
@property (nonatomic, copy) void (^completionBlock)(NSError *, pid_t);
Expand Down
4 changes: 2 additions & 2 deletions bp/src/BPTestBundleConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ - (void)connect {
path = NSBundle.mainBundle.executablePath;
}
__block DTXRemoteInvocationReceipt *receipt = [remoteProxy
_IDE_initiateSessionWithIdentifier:self.config.sessionIdentifier
_IDE_initiateSessionWithIdentifier:self.context.config.sessionIdentifier
forClient:[self clientProcessUniqueIdentifier]
atPath:path
protocolVersion:@(BP_DAEMON_PROTOCOL_VERSION)];
Expand Down Expand Up @@ -282,7 +282,7 @@ - (void)stopVideoRecording:(BOOL)forced
- (id)_XCT_launchProcessWithPath:(NSString *)path bundleID:(NSString *)bundleID arguments:(NSArray *)arguments environmentVariables:(NSDictionary *)environment
{
NSMutableDictionary<NSString *, NSString *> *env = [[NSMutableDictionary alloc] init];
[env addEntriesFromDictionary:[SimulatorHelper appLaunchEnvironmentWithBundleID:bundleID device:nil config:_config]];
[env addEntriesFromDictionary:[SimulatorHelper appLaunchEnvironmentWithBundleID:bundleID device:nil config:_context.config]];
[env addEntriesFromDictionary:environment];
NSDictionary *options = @{
@"arguments": arguments,
Expand Down
2 changes: 1 addition & 1 deletion bp/src/BPTestDaemonConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
@interface BPTestDaemonConnection : NSObject
@property (nonatomic, assign) pid_t testRunnerPid;
@property (nonatomic, strong) BPSimulator *simulator;
- (instancetype)initWithDevice:(BPSimulator *)device andInterface:(id<XCTestManager_IDEInterface>)interface;
- (instancetype)initWithDevice:(BPSimulator *)device andInterface:(id<XCTestManager_IDEInterface>)interface andTestRunnerPID: (pid_t) pid;
- (void)connectWithTimeout:(NSTimeInterval)timeout;
@end
5 changes: 3 additions & 2 deletions bp/src/BPTestDaemonConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@ @interface BPTestDaemonConnection()<XCTestManager_IDEInterface>

@implementation BPTestDaemonConnection

- (instancetype)initWithDevice:(BPSimulator *)simulator andInterface:(id<XCTestManager_IDEInterface>)interface {
- (instancetype)initWithDevice:(BPSimulator *)simulator andInterface:(id<XCTestManager_IDEInterface>)interface andTestRunnerPID: (pid_t) pid {
self = [super init];
if (self) {
self.simulator = simulator;
self.interface = interface;
self.testRunnerPid = pid;
}
return self;
}

- (void)connectWithTimeout:(NSTimeInterval)timeout {
[self connect];
// Pool connection status till it passes.
// Poll connection status till it passes.
[BPUtils runWithTimeOut:timeout until:^BOOL{
return self.connected;
}];
Expand Down
23 changes: 6 additions & 17 deletions bp/src/BPXCTestFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,12 @@ + (instancetype)BPXCTestFileFromXCTestBundle:(NSString *)path
xcTestFile.testBundlePath = [path stringByDeletingLastPathComponent];

NSString *cmd = [NSString stringWithFormat:swiftNmCmdline, path];
FILE *p = popen([cmd UTF8String], "r");
if (!p) {
BP_SET_ERROR(errPtr, @"Failed to load test %@.\nERROR: %s\n", path, strerror(errno));
return nil;
}
char *line = NULL;
size_t len = 0;
ssize_t read;
NSString *output = [BPUtils runShell:cmd];
NSArray<NSString *>* testsArray = [output componentsSeparatedByString:@"\n"];
NSMutableDictionary *testClassesDict = [[NSMutableDictionary alloc] init];
NSMutableArray *allClasses = [[NSMutableArray alloc] init];
while ((read = getline(&line, &len, p)) != -1) {
NSString *testName = [[NSString stringWithUTF8String:line]
stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];

for (NSString *testName in testsArray) {
NSArray *parts = [testName componentsSeparatedByString:@"."];
if (parts.count != 3) {
continue;
Expand All @@ -77,14 +70,10 @@ + (instancetype)BPXCTestFileFromXCTestBundle:(NSString *)path
[testClass addTestCase:[[BPTestCase alloc] initWithName:trimmedTestName]];
}
}
if (pclose(p) == -1) {
BP_SET_ERROR(errPtr, @"Failed to execute command: %@.\nERROR: %s\n", cmd, strerror(errno));
return nil;
}

cmd = [NSString stringWithFormat:objcNmCmdline, path];
NSString *output = [BPUtils runShell:cmd];
NSArray *testsArray = [output componentsSeparatedByString:@"\n"];
output = [BPUtils runShell:cmd];
testsArray = [output componentsSeparatedByString:@"\n"];
for (NSString *line in testsArray) {
NSArray *parts = [line componentsSeparatedByString:@" "];
if (parts.count != 2) {
Expand Down
5 changes: 1 addition & 4 deletions bp/src/Bluepill.m
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,8 @@ - (void)connectTestBundleAndTestDaemonWithContext:(BPExecutionContext *)context
return;
}
BPTestBundleConnection *bConnection = [[BPTestBundleConnection alloc] initWithContext:context andInterface:self];
bConnection.simulator = context.runner;
bConnection.config = self.config;
BPTestDaemonConnection *dConnection = [[BPTestDaemonConnection alloc] initWithDevice:context.runner andInterface:nil andTestRunnerPID: context.pid];

BPTestDaemonConnection *dConnection = [[BPTestDaemonConnection alloc] initWithDevice:context.runner andInterface:nil];
dConnection.testRunnerPid = context.pid;
[dConnection connectWithTimeout:180];
[bConnection connectWithTimeout:180];
[bConnection startTestPlan];
Expand Down