Skip to content

Commit

Permalink
Add parameters to include or exclude XcTestFile
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelslemos committed Jan 27, 2020
1 parent be43821 commit de17646
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
30 changes: 29 additions & 1 deletion bluepill/src/BPPacker.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,35 @@ @implementation BPPacker
NSArray *testCasesToRun = config.testCasesToRun;
NSArray *noSplit = config.noSplit;
NSUInteger numBundles = [config.numSims integerValue];
NSArray *sortedXCTestFiles = [xcTestFiles sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {

NSMutableArray *filteredXcTestFiles = [NSMutableArray new];

for (BPXCTestFile *xcFile in xcTestFiles) {
if (config.xcTestFileToRun) {
for(NSString *includedTestFile in config.xcTestFileToRun) {
if ([[xcFile name] isEqualToString:includedTestFile]) {
[filteredXcTestFiles addObject:xcFile];
break;
}
}
} else {
[filteredXcTestFiles addObject:xcFile];
}
}

if (config.xcTestFileToSkip) {
for (BPXCTestFile *xcFile in [NSArray arrayWithArray:filteredXcTestFiles]) {
for(NSString *excludedXcTestFile in config.xcTestFileToSkip) {
if ([[xcFile name] isEqualToString:excludedXcTestFile]) {
[filteredXcTestFiles removeObject:xcFile];
break;
}
}
}
}


NSArray *sortedXCTestFiles = [filteredXcTestFiles sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) {
NSUInteger numTests1 = [(BPXCTestFile *)obj1 numTests];
NSUInteger numTests2 = [(BPXCTestFile *)obj2 numTests];
return numTests2 - numTests1;
Expand Down
2 changes: 2 additions & 0 deletions bp/src/BPConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ typedef NS_ENUM(NSInteger, BPProgram) {
@property (nonatomic, strong) NSNumber *failureTolerance;
@property (nonatomic) BOOL onlyRetryFailed;
@property (nonatomic, strong) NSArray *testCasesToSkip;
@property (nonatomic, strong) NSArray *xcTestFileToSkip;
@property (nonatomic, strong) NSArray *testCasesToRun;
@property (nonatomic, strong) NSArray *xcTestFileToRun;
@property (nonatomic, strong) NSArray *allTestCases;
@property (nonatomic, strong) NSString *configOutputFile;
@property (nonatomic, strong) NSString *outputDirectory;
Expand Down
4 changes: 4 additions & 0 deletions bp/src/BPConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ typedef NS_OPTIONS(NSUInteger, BPOptionType) {
"A .GlobalPreferences.plist simulator preferences file to be copied to any newly created simulators before booting"},
{363, "script-file", BP_MASTER | BP_SLAVE, NO, NO, required_argument, NULL, BP_VALUE | BP_PATH, "scriptFilePath",
"A script that will be called after the simulator is booted, but before tests are run. Can be used to do any setup (e.g. installing certs). The environment will contain $BP_DEVICE_ID with the ID of the simulator and $BP_DEVICE_PATH with its full path. Exit with zero for success and non-zero for failure."},
{364, "exclude-xctest-file", BP_MASTER | BP_SLAVE, NO, NO, required_argument, NULL, BP_LIST, "xcTestFileToSkip",
"Exclude a xctestfile in the set of tests to run (takes priority over `include`)."},
{365, "include-xctest-file", BP_MASTER | BP_SLAVE, NO, NO, required_argument, NULL, BP_LIST, "xcTestFileToRun",
"Include a xctestfile in the set of tests to run (unless specified in `exclude`)."},

{0, 0, 0, 0, 0, 0, 0}
};
Expand Down

0 comments on commit de17646

Please sign in to comment.