Skip to content

Commit

Permalink
Validate BPTestPlans
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Dittmer committed Sep 17, 2019
1 parent 3915e60 commit 95f0044
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions bp/src/BPConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,22 @@ typedef NS_OPTIONS(NSUInteger, BPOptionType) {
@implementation BPTestPlan

- (BOOL)isValid {
return YES;
return
self.arguments != nil &&
self.environment != nil &&
self.testBundlePath != nil &&
self.testHost != nil;
}

- (nonnull id)copyWithZone:(nullable NSZone *)zone {
return [[BPTestPlan alloc] init];
BPTestPlan *c = [[BPTestPlan alloc] init];
c.arguments = [self.arguments copy];
c.environment = [self.environment copy];
c.testBundlePath = [self.testBundlePath copy];
c.testHost = [self.testHost copy];
c.uiTargetAppPath = [self.uiTargetAppPath copy];

return c;
}

@end
Expand Down Expand Up @@ -511,6 +522,11 @@ - (BOOL)loadConfigFile:(NSString *)file withError:(NSError **)errPtr{
plan.environment = [planDictionary objectForKey:@"environment"];
plan.arguments = [planDictionary objectForKey:@"arguments"];

if (!plan.isValid) {
BP_SET_ERROR(errPtr, @"Invalid BPTestPlan configuration: %@", plan);
return NO;
}

[tests setObject:plan forKey:key];
}

Expand Down

0 comments on commit 95f0044

Please sign in to comment.