Permalink
Browse files

Merge branch 'master' into approved-image-color

  • Loading branch information...
2 parents f21ae25 + 25dedb1 commit 108e162533c2ca32dae65b038d28485c4a4b68d1 @x2on x2on committed Jun 1, 2012
@@ -276,7 +276,20 @@ - (void)_notifyFinished {
// Log JUnit XML if environment variable is set
if (getenv("WRITE_JUNIT_XML")) {
NSError *error = nil;
- if (![testSuite writeJUnitXML:&error]) {
+
+ NSString *resultsDir;
+
+ char *resultsDirStr = getenv("JUNIT_XML_DIR");
+ if (resultsDirStr) {
+ resultsDir = [NSString stringWithUTF8String:resultsDirStr];
+ } else {
+ NSString *tmpDir = NSTemporaryDirectory();
+ resultsDir = [tmpDir stringByAppendingPathComponent:@"test-results"];
+ }
+
+ [self log:[NSString stringWithFormat:@"Writing JUnit XML to:%@.\n", resultsDir]];
+
+ if (![testSuite writeJUnitXMLToDirectory:resultsDir error:&error]) {
[self log:[NSString stringWithFormat:@"Error writing JUnit XML: %@\n", [error localizedDescription]]];
} else {
[self log:@"Wrote JUnit XML successfully.\n"];
@@ -111,7 +111,7 @@ extern NSString *GHUnitTest;
@interface GHTestSuite (JUnitXML)
-- (BOOL)writeJUnitXML:(NSError **)error;
+- (BOOL)writeJUnitXMLToDirectory:(NSString *)directory error:(NSError **)error;
@end
@@ -139,25 +139,22 @@ @implementation GHTestSuite (JUnitXML)
Override logic to write children individually, as we want each test group's
JUnit XML to be in its own file.
*/
-- (BOOL)writeJUnitXML:(NSError **)error {
+- (BOOL)writeJUnitXMLToDirectory:(NSString *)directory error:(NSError **)error {
NSParameterAssert(error);
BOOL allSuccess = YES;
NSFileManager *fileManager = [NSFileManager defaultManager];
- NSString *tmpDir = NSTemporaryDirectory();
- NSString *resultsDir = [tmpDir stringByAppendingPathComponent:@"test-results"];
-
- if (![fileManager fileExistsAtPath:resultsDir]) {
- if (![fileManager createDirectoryAtPath:resultsDir withIntermediateDirectories:YES attributes:nil error:error]) {
- NSLog (@"Error while creating results directory: %@", [*error localizedDescription]);
+ if (![fileManager fileExistsAtPath:directory]) {
+ if (![fileManager createDirectoryAtPath:directory withIntermediateDirectories:YES attributes:nil error:error]) {
+ NSLog(@"Error while creating results directory: %@", [*error localizedDescription]);
return NO;
}
}
for (id child in self.children) {
if ([child respondsToSelector:@selector(writeJUnitXMLAtPath:error:)]) {
- if (![child writeJUnitXMLAtPath:resultsDir error:error]) {
- NSLog (@"Error writing JUnit XML: %@", [*error localizedDescription]);
+ if (![child writeJUnitXMLAtPath:directory error:error]) {
+ NSLog(@"Error writing JUnit XML: %@", [*error localizedDescription]);
allSuccess = NO;
}
}
@@ -67,9 +67,13 @@ - (void)cancel {
#pragma mark -
- (void)receiveData:(NSData *)data afterDelay:(NSTimeInterval)delay {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
- [delegate_ connection:nil didReceiveData:data];
- });
+ if (delay < 0) {
+ [delegate_ connection:(NSURLConnection *)self didReceiveData:data];
+ } else {
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
+ [delegate_ connection:(NSURLConnection *)self didReceiveData:data];
+ });
+ }
}
- (NSData *)loadDataFromPath:(NSString *)path {
@@ -108,21 +112,33 @@ - (void)receiveHTTPResponseWithStatusCode:(int)statusCode headers:(NSDictionary
}
- (void)receiveResponse:(NSURLResponse *)response afterDelay:(NSTimeInterval)delay {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
+ if (delay < 0) {
[delegate_ connection:(NSURLConnection *)self didReceiveResponse:response];
- });
+ } else {
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
+ [delegate_ connection:(NSURLConnection *)self didReceiveResponse:response];
+ });
+ }
}
- (void)finishAfterDelay:(NSTimeInterval)delay {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
+ if (delay < 0) {
[delegate_ connectionDidFinishLoading:(NSURLConnection *)self];
- });
+ } else {
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
+ [delegate_ connectionDidFinishLoading:(NSURLConnection *)self];
+ });
+ }
}
- (void)failWithError:(NSError *)error afterDelay:(NSTimeInterval)delay {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
+ if (delay < 0) {
[delegate_ connection:(NSURLConnection *)self didFailWithError:error];
- });
+ } else {
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_current_queue(), ^{
+ [delegate_ connection:(NSURLConnection *)self didFailWithError:error];
+ });
+ }
}
@end
@@ -15,12 +15,12 @@ want to configure `Source Code Management`, and then under `Build Triggers` chec
- Under `Build`, enter the following command:
- make clean && WRITE_JUNIT_XML=YES make test
+ make clean && WRITE_JUNIT_XML=YES JUNIT_XML_DIR=tmp/test-results make test
- Under `Post-build Actions`, check `Publish JUnit test result report` and enter the following in `Test report XMLs`:
- build/test-results/*.xml
+ tmp/test-results/*.xml
That's all it takes. Check in a change that breaks one of your tests. Hudson should detect the change, run a build and test, and then report the failure. Fix the test, check in again, and you should see a successful build report.
@@ -63,4 +63,5 @@ The `TEST` environment variable can be used to run a single test or test case.
- `GHUNIT_AUTOEXIT`: Default NO; If YES, will exit upon test completion (no matter what). For command line MacOSX testing
- `GHUNIT_CLI`: Default NO; Specifies that the tests are being run from the command line. For command line MacOSX testing
- `WRITE_JUNIT_XML`: Default NO; Whether to write out JUnit XML output. For Jenkins CI integration
+- `JUNIT_XML_DIR`: Default to temporary directory. Specify to have files written to a different directory. For Jenkins CI integration.

0 comments on commit 108e162

Please sign in to comment.