Skip to content

Commit

Permalink
Validating the numSims configuration and adjusting it when needed (#335)
Browse files Browse the repository at this point in the history
Two minor fixes:
1. Fewer simulators can be used if the number of bundles is less than the number of simulators.
2. There cannot be fewer than one simulator. Throw an error in case of a bad configuration.
  • Loading branch information
Ravi Kumar Mandala authored and ob committed Jun 12, 2019
1 parent 3b1ddc9 commit d58bad0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bluepill/src/BPRunner.m
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,18 @@ - (int)runWithBPXCTestFiles:(NSArray<BPXCTestFile *> *)xcTestFiles {
}
if (bundles.count < numSims) {
[BPUtils printInfo:WARNING
withString:@"Lowering number of parallel simulators from %lu to %lu because there aren't enough tests.",
withString:@"Lowering number of parallel simulators from %lu to %lu because there aren't enough test bundles.",
numSims, bundles.count];
numSims = bundles.count;
}
if (self.config.cloneSimulator) {
self.testHostForSimUDID = [bpSimulator createSimulatorAndInstallAppWithBundles:xcTestFiles];
if ([self.testHostForSimUDID count] == 0) {
return 1;
}
}
[BPUtils printInfo:INFO withString:@"Running with %lu parallel simulator%s.",
(unsigned long)numSims, (numSims > 1) ? "s" : ""];
[BPUtils printInfo:INFO withString:@"Running with %lu %s.",
(unsigned long)numSims, (numSims > 1) ? "parallel simulators" : "simulator"];
NSArray *copyBundles = [NSMutableArray arrayWithArray:bundles];
for (int i = 1; i < [self.config.repeatTestsCount integerValue]; i++) {
[bundles addObjectsFromArray:copyBundles];
Expand Down
4 changes: 4 additions & 0 deletions bp/src/BPConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,10 @@ - (BOOL)loadConfigFile:(NSString *)file withError:(NSError **)errPtr{
}
}
}
if (self.numSims.integerValue < 1) {
BP_SET_ERROR(errPtr, @"Number of simulators set to %lu but there cannot be fewer than one simulator.", self.numSims.integerValue);
return NO;
}
// Pull out two keys that are undocumented but needed for supporting xctest
self.commandLineArguments = [configDict objectForKey:@"commandLineArguments"];
self.environmentVariables = [configDict objectForKey:@"environmentVariables"];
Expand Down

0 comments on commit d58bad0

Please sign in to comment.