Skip to content

Commit

Permalink
Simplified Constructor in FBAgentLaunchConfiguration
Browse files Browse the repository at this point in the history
Summary: About to change the constructor, so to make it easier moving to the same internal and external constructor. The static constructor is confusing as it is niil-returning (even though not declaring this) and takes no error out.

Reviewed By: c-ryan747

Differential Revision: D26688006

fbshipit-source-id: d23bdbdd76ccb7b439dd151ef3d756ecf32c9172
  • Loading branch information
lawrencelomax authored and facebook-github-bot committed Mar 1, 2021
1 parent 2a65a89 commit 1279ca3
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 21 deletions.
4 changes: 2 additions & 2 deletions FBControlCore/Configuration/FBAgentLaunchConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef NS_ENUM(NSUInteger, FBAgentLaunchMode) {
@interface FBAgentLaunchConfiguration : FBProcessLaunchConfiguration

/**
Creates and returns a new Configuration with the provided parameters
The designated initializer.
@param launchPath the path to the executable to launch.
@param arguments an array-of-strings of arguments to the process. Must not be nil.
Expand All @@ -35,7 +35,7 @@ typedef NS_ENUM(NSUInteger, FBAgentLaunchMode) {
@param mode the launch mode to use.
@return a new Configuration Object with the arguments applied.
*/
+ (instancetype)configurationWithLaunchPath:(NSString *)launchPath arguments:(NSArray<NSString *> *)arguments environment:(NSDictionary<NSString *, NSString *> *)environment output:(FBProcessOutputConfiguration *)output mode:(FBAgentLaunchMode)mode;
- (instancetype)initWithLaunchPath:(NSString *)launchPath arguments:(NSArray<NSString *> *)arguments environment:(NSDictionary<NSString *, NSString *> *)environment output:(FBProcessOutputConfiguration *)output mode:(FBAgentLaunchMode)mode;

/**
The Binary Path of the agent to Launch.
Expand Down
7 changes: 0 additions & 7 deletions FBControlCore/Configuration/FBAgentLaunchConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@

@implementation FBAgentLaunchConfiguration

+ (instancetype)configurationWithLaunchPath:(NSString *)launchPath arguments:(NSArray<NSString *> *)arguments environment:(NSDictionary<NSString *, NSString *> *)environment output:(FBProcessOutputConfiguration *)output mode:(FBAgentLaunchMode)mode
{
if (!launchPath || !arguments || !environment) {
return nil;
}
return [[self alloc] initWithLaunchPath:launchPath arguments:arguments environment:environment output:output mode:mode];
}
- (instancetype)initWithLaunchPath:(NSString *)launchPath arguments:(NSArray<NSString *> *)arguments environment:(NSDictionary<NSString *, NSString *> *)environment output:(FBProcessOutputConfiguration *)output mode:(FBAgentLaunchMode)mode
{
self = [super initWithArguments:arguments environment:environment output:output];
Expand Down
4 changes: 2 additions & 2 deletions FBSimulatorControl/Commands/FBSimulatorLaunchCtlCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ + (NSString *)extractServiceNameFromListLine:(NSString *)line processIdentifierO
- (FBFuture<NSString *> *)runWithArguments:(NSArray<NSString *> *)arguments
{
// Construct a Launch Configuration for launchctl we'll use the 'list' command.
FBAgentLaunchConfiguration *launchConfiguration = [FBAgentLaunchConfiguration
configurationWithLaunchPath:self.launchctlLaunchPath
FBAgentLaunchConfiguration *launchConfiguration = [[FBAgentLaunchConfiguration alloc]
initWithLaunchPath:self.launchctlLaunchPath
arguments:arguments
environment:@{}
output:FBProcessOutputConfiguration.outputToDevNull
Expand Down
4 changes: 2 additions & 2 deletions FBSimulatorControl/Commands/FBSimulatorLogCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ - (instancetype)initWithSimulator:(FBSimulator *)simulator
return [FBSimulatorError failFutureWithError:error];
}

FBAgentLaunchConfiguration *configuration = [FBAgentLaunchConfiguration
configurationWithLaunchPath:launchPath
FBAgentLaunchConfiguration *configuration = [[FBAgentLaunchConfiguration alloc]
initWithLaunchPath:launchPath
arguments:arguments
environment:@{}
output:output
Expand Down
4 changes: 2 additions & 2 deletions FBSimulatorControl/Management/FBSimulatorBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ + (NSString *)portNameForSimulator:(FBSimulator *)simulator
return [FBFuture futureWithError:error];
}

FBAgentLaunchConfiguration *config = [FBAgentLaunchConfiguration
configurationWithLaunchPath:bridgeLaunchPath
FBAgentLaunchConfiguration *config = [[FBAgentLaunchConfiguration alloc]
initWithLaunchPath:bridgeLaunchPath
arguments:@[portName]
environment:@{}
output:output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ - (NSString *)defaultsBinary
- (FBFuture<NSString *> *)performDefaultsCommandWithArguments:(NSArray<NSString *> *)arguments
{
// Make the Launch Config
FBAgentLaunchConfiguration *configuration = [FBAgentLaunchConfiguration
configurationWithLaunchPath:self.defaultsBinary
FBAgentLaunchConfiguration *configuration = [[FBAgentLaunchConfiguration alloc]
initWithLaunchPath:self.defaultsBinary
arguments:arguments
environment:@{}
output:FBProcessOutputConfiguration.outputToDevNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ - (instancetype)initWithSimulator:(FBSimulator *)simulator shims:(FBXCTestShimCo
return [FBFuture futureWithError:error];
}

FBAgentLaunchConfiguration *configuration = [FBAgentLaunchConfiguration
configurationWithLaunchPath:launchPath
FBAgentLaunchConfiguration *configuration = [[FBAgentLaunchConfiguration alloc]
initWithLaunchPath:launchPath
arguments:arguments
environment:environment
output:output
Expand Down
4 changes: 2 additions & 2 deletions FBSimulatorControlTests/Fixtures/FBSimulatorControlFixtures.m
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ - (FBApplicationLaunchConfiguration *)safariAppLaunchWithMode:(FBApplicationLaun

- (FBAgentLaunchConfiguration *)agentLaunch1
{
return [FBAgentLaunchConfiguration
configurationWithLaunchPath:[FBBinaryDescriptor binaryWithPath:NSProcessInfo.processInfo.arguments[0] error:nil].path
return [[FBAgentLaunchConfiguration alloc]
initWithLaunchPath:[FBBinaryDescriptor binaryWithPath:NSProcessInfo.processInfo.arguments[0] error:nil].path
arguments:@[@"BINGBONG"]
environment:@{@"FIB" : @"BLE"}
output:FBProcessOutputConfiguration.outputToDevNull
Expand Down

0 comments on commit 1279ca3

Please sign in to comment.