Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Support xctool tests running in parallel.
Browse files Browse the repository at this point in the history
  • Loading branch information
ExtremeMan committed Aug 23, 2015
1 parent 9f21c02 commit 5557108
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion reporters/text/TextReporter.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ - (void)increaseIndent

- (void)decreaseIndent
{
assert(_indent > 0);
NSAssert(_indent > 0, @"Indent should be increased before being decreased");
_indent--;
}

Expand Down
10 changes: 5 additions & 5 deletions xctool/xctool-tests/BuildTestsActionTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ - (void)testBuildTestsAction
@"OBJROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestProject-Library-frruszglismbfoceinskphldzhci/Build/Intermediates",
@"SYMROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestProject-Library-frruszglismbfoceinskphldzhci/Build/Products",
@"SHARED_PRECOMPS_DIR=/Users/nekto/Library/Developer/Xcode/DerivedData/TestProject-Library-frruszglismbfoceinskphldzhci/Build/Intermediates/PrecompiledHeaders",
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST/DerivedData", NSTemporaryDirectory()],
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST_%d/DerivedData", NSTemporaryDirectory(), [[NSProcessInfo processInfo] processIdentifier]],
@"build",
]));
assertThatInt(tool.exitStatus, equalToInt(0));
Expand Down Expand Up @@ -197,7 +197,7 @@ - (void)testBuildTestsActionWillBuildEverythingMarkedAsBuildForTest
@"OBJROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestWorkspace-Library-asazjpviwiufbaajaofbmyqmmghn/Build/Intermediates",
@"SYMROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestWorkspace-Library-asazjpviwiufbaajaofbmyqmmghn/Build/Products",
@"SHARED_PRECOMPS_DIR=/Users/nekto/Library/Developer/Xcode/DerivedData/TestWorkspace-Library-asazjpviwiufbaajaofbmyqmmghn/Build/Intermediates/PrecompiledHeaders",
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST/DerivedData", NSTemporaryDirectory()],
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST_%d/DerivedData", NSTemporaryDirectory(), [[NSProcessInfo processInfo] processIdentifier]],
@"build",
]));
assertThatInt(tool.exitStatus, equalToInt(0));
Expand Down Expand Up @@ -266,7 +266,7 @@ - (void)testBuildTestsCanBuildASingleTarget
@"OBJROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestWorkspace-Library-asazjpviwiufbaajaofbmyqmmghn/Build/Intermediates",
@"SYMROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestWorkspace-Library-asazjpviwiufbaajaofbmyqmmghn/Build/Products",
@"SHARED_PRECOMPS_DIR=/Users/nekto/Library/Developer/Xcode/DerivedData/TestWorkspace-Library-asazjpviwiufbaajaofbmyqmmghn/Build/Intermediates/PrecompiledHeaders",
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST/DerivedData", NSTemporaryDirectory()],
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST_%d/DerivedData", NSTemporaryDirectory(), [[NSProcessInfo processInfo] processIdentifier]],
@"build",
]));
assertThatInt(tool.exitStatus, equalToInt(0));
Expand Down Expand Up @@ -332,7 +332,7 @@ - (void)testSkipDependencies
@"OBJROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestWorkspace-Library-asazjpviwiufbaajaofbmyqmmghn/Build/Intermediates",
@"SYMROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestWorkspace-Library-asazjpviwiufbaajaofbmyqmmghn/Build/Products",
@"SHARED_PRECOMPS_DIR=/Users/nekto/Library/Developer/Xcode/DerivedData/TestWorkspace-Library-asazjpviwiufbaajaofbmyqmmghn/Build/Intermediates/PrecompiledHeaders",
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST/DerivedData", NSTemporaryDirectory()],
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST_%d/DerivedData", NSTemporaryDirectory(), [[NSProcessInfo processInfo] processIdentifier]],
@"build",
]));
assertThatInt(tool.exitStatus, equalToInt(0));
Expand Down Expand Up @@ -387,7 +387,7 @@ - (void)testConfigurationIsTakenFromScheme
@"OBJROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestProject-Library-frruszglismbfoceinskphldzhci/Build/Intermediates",
@"SYMROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestProject-Library-frruszglismbfoceinskphldzhci/Build/Products",
@"SHARED_PRECOMPS_DIR=/Users/nekto/Library/Developer/Xcode/DerivedData/TestProject-Library-frruszglismbfoceinskphldzhci/Build/Intermediates/PrecompiledHeaders",
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST/DerivedData", NSTemporaryDirectory()],
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST_%d/DerivedData", NSTemporaryDirectory(), [[NSProcessInfo processInfo] processIdentifier]],
@"build"
]));
}];
Expand Down
4 changes: 2 additions & 2 deletions xctool/xctool-tests/CleanActionTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ - (void)testCleanActionTriggersCleanForProjectAndSchemeAndTests
@"OBJROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestProject-Library-frruszglismbfoceinskphldzhci/Build/Intermediates",
@"SYMROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestProject-Library-frruszglismbfoceinskphldzhci/Build/Products",
@"SHARED_PRECOMPS_DIR=/Users/nekto/Library/Developer/Xcode/DerivedData/TestProject-Library-frruszglismbfoceinskphldzhci/Build/Intermediates/PrecompiledHeaders",
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST/DerivedData", NSTemporaryDirectory()],
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST_%d/DerivedData", NSTemporaryDirectory(), [[NSProcessInfo processInfo] processIdentifier]],
@"clean",
]));
}];
Expand Down Expand Up @@ -133,7 +133,7 @@ - (void)testConfigurationIsTakenFromScheme
@"OBJROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestProject-Library-frruszglismbfoceinskphldzhci/Build/Intermediates",
@"SYMROOT=/Users/nekto/Library/Developer/Xcode/DerivedData/TestProject-Library-frruszglismbfoceinskphldzhci/Build/Products",
@"SHARED_PRECOMPS_DIR=/Users/nekto/Library/Developer/Xcode/DerivedData/TestProject-Library-frruszglismbfoceinskphldzhci/Build/Intermediates/PrecompiledHeaders",
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST/DerivedData", NSTemporaryDirectory()],
[NSString stringWithFormat:@"-IDECustomDerivedDataLocation=%@xctool_temp_UNDERTEST_%d/DerivedData", NSTemporaryDirectory(), [[NSProcessInfo processInfo] processIdentifier]],
@"clean"
]));
}];
Expand Down
3 changes: 2 additions & 1 deletion xctool/xctool/Options.m
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ - (BOOL)validateReporterOptions:(NSString **)errorMessage
outputPath:@"-"];
[_reporters addObject:reporterTask];

if (![[[NSProcessInfo processInfo] environment][@"TRAVIS"] isEqualToString:@"true"]) {
if (![[[NSProcessInfo processInfo] environment][@"TRAVIS"] isEqualToString:@"true"] &&
!IsRunningUnderTest()) {
ReporterTask *userNotificationsReporterTask =
[[ReporterTask alloc] initWithReporterPath:[XCToolReportersPath() stringByAppendingPathComponent:@"user-notifications"]
outputPath:@"-"];
Expand Down
2 changes: 1 addition & 1 deletion xctool/xctool/SimulatorWrapper/SimulatorUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void StopAndRemoveLaunchdJob(NSString *job)
launch_data_t getJobsMessage = launch_data_new_string(LAUNCH_KEY_GETJOBS);
launch_data_t response = launch_msg(getJobsMessage);

assert(launch_data_get_type(response) == LAUNCH_DATA_DICTIONARY);
NSCAssert(launch_data_get_type(response) == LAUNCH_DATA_DICTIONARY, @"Response is of unexpected type: %d", launch_data_get_type(response));

NSMutableArray *jobs = [NSMutableArray array];

Expand Down
6 changes: 3 additions & 3 deletions xctool/xctool/XCToolUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
strcpy(tempPath, template);

int handle = mkstemp(tempPath);
assert(handle != -1);
NSCAssert(handle != -1, @"Failed to make temporary file name for template %s, error: %d", template, handle);
close(handle);

return [NSString stringWithFormat:@"%s", tempPath];
Expand Down Expand Up @@ -615,7 +615,7 @@ BOOL RunXcodebuildAndFeedEventsToReporters(NSArray *arguments,
// Let our names be consistent while under test - we don't want our tests
// to have to match against random values.
if (IsRunningUnderTest()) {
nameTemplate = @"xctool_temp_UNDERTEST";
nameTemplate = [NSString stringWithFormat:@"xctool_temp_UNDERTEST_%d", [[NSProcessInfo processInfo] processIdentifier]];
} else {
nameTemplate = @"xctool_temp_XXXXXX";
}
Expand Down Expand Up @@ -668,7 +668,7 @@ void PublishEventToReporters(NSArray *reporters, NSDictionary *event)
NSString *AbsolutePathFromRelative(NSString *path)
{
char absolutePath[PATH_MAX] = {0};
assert(realpath((const char *)[path UTF8String], absolutePath) != NULL);
NSCAssert(realpath((const char *)[path UTF8String], absolutePath) != NULL, @"Failed to resolve the path: %s", absolutePath);

return @(absolutePath);
}
Expand Down
14 changes: 7 additions & 7 deletions xctool/xctool/XcodeSubjectInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
static NSString *ProjectPathFromSchemePath(NSString *schemePath)
{
for (;;) {
assert(schemePath.length > 0);
NSCAssert(schemePath.length > 0, @"Scheme path length should be more then 0: %@", schemePath);

if ([schemePath hasSuffix:@".xcodeproj"] || [schemePath hasSuffix:@".xcworkspace"]) {
break;
Expand Down Expand Up @@ -81,7 +81,7 @@
static NSString *StandardizedContainerPath(NSString *container, NSString *basePath)
{
static NSString * const kContainerReference = @"container:";
assert([container hasPrefix:kContainerReference]);
NSCAssert([container hasPrefix:kContainerReference], @"Container has unexpected prefix: %@; expected: %@", container, kContainerReference);
NSString *containerPath = [container substringFromIndex:kContainerReference.length];
return StringByStandardizingPath([basePath stringByAppendingPathComponent:containerPath]);
}
Expand Down Expand Up @@ -679,7 +679,7 @@ + (NSArray *)testablesInSchemePath:(NSString *)schemePath basePath:(NSString *)b
[[[node attributeForName:@"skipped"] stringValue] isEqualToString:@"YES"] ? YES : NO;
NSArray *buildableReferences = [node nodesForXPath:@"BuildableReference" error:nil];

assert(buildableReferences.count == 1);
NSAssert(buildableReferences.count == 1, @"Number of buildable references should be 1: %@", buildableReferences);
NSXMLElement *buildableReference = buildableReferences[0];

NSString *referencedContainer = [[buildableReference attributeForName:@"ReferencedContainer"] stringValue];
Expand Down Expand Up @@ -749,7 +749,7 @@ + (NSArray *)buildablesInSchemePath:(NSString *)schemePath basePath:(NSString *)
for (NSXMLElement *node in buildActionEntryNodes) {
NSArray *buildableReferences = [node nodesForXPath:@"BuildableReference" error:nil];

assert(buildableReferences.count == 1);
NSAssert(buildableReferences.count == 1, @"Number of buildable references should be 1: %@", buildableReferences);
NSXMLElement *buildableReference = buildableReferences[0];

NSString *referencedContainer = [[buildableReference attributeForName:@"ReferencedContainer"] stringValue];
Expand Down Expand Up @@ -931,9 +931,9 @@ - (void)populateBuildActionPropertiesWithSchemePath:(NSString *)schemePath

- (void)loadSubjectInfo
{
assert(_subjectXcodeBuildArguments);
assert(_subjectScheme);
assert(_subjectWorkspace || _subjectProject);
NSAssert(_subjectXcodeBuildArguments, @"Subject xcode build arguments should be defined.");
NSAssert(_subjectScheme, @"Subject scheme should be defined.");
NSAssert(_subjectWorkspace || _subjectProject, @"Subject workspace or project should be defined.");

// First we need to know the OBJROOT and SYMROOT settings for the project we're testing.
NSDictionary *settings = [self buildSettingsForATarget];
Expand Down

0 comments on commit 5557108

Please sign in to comment.