diff options
Diffstat (limited to 'render-test/ios/iosTestRunner.mm')
-rw-r--r-- | render-test/ios/iosTestRunner.mm | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/render-test/ios/iosTestRunner.mm b/render-test/ios/iosTestRunner.mm index 3fe16c1d8e..c180deeb53 100644 --- a/render-test/ios/iosTestRunner.mm +++ b/render-test/ios/iosTestRunner.mm @@ -2,6 +2,8 @@ #include "ios_test_runner.hpp" +#import "SSZipArchive.h" + #include <string> @interface IosTestRunner () @@ -90,6 +92,51 @@ NSLog(@"Metric test result file '%@' doese not exit ", self.metricResultPath); self.testStatus = NO; } + + NSString *docDirectory = [path stringByAppendingPathComponent:@"/baselines"]; + fileFound = [fileManager fileExistsAtPath: docDirectory]; + if (!fileFound) { + NSLog(@"Metric path '%@' doese not exit ", docDirectory); + } + + BOOL needArchiving = NO; + BOOL isDir = NO; + NSArray *subpaths = [[NSArray alloc] init]; + NSString *exportPath = docDirectory; + if ([fileManager fileExistsAtPath:exportPath isDirectory: &isDir] && isDir){ + subpaths = [fileManager subpathsAtPath:exportPath]; + for(NSString *path in subpaths) + { + NSString *longPath = [exportPath stringByAppendingPathComponent:path]; + if([fileManager fileExistsAtPath:longPath isDirectory:&isDir] && !isDir) + { + needArchiving = YES; + break; + } + } + } + else { + NSLog(@"Failed to find the archive sub directory"); + } + + if (needArchiving) { + NSString *archivePath = [path stringByAppendingString:@"/metrics.zip"]; + BOOL success = [SSZipArchive createZipFileAtPath:archivePath + withContentsOfDirectory:exportPath + keepParentDirectory:NO + compressionLevel:-1 + password:nil + AES:YES + progressHandler:nil]; + + if (success) { + NSLog(@"Successfully archive all of the metrics into metrics.zip"); + self.metricPath = archivePath; + } + else { + NSLog(@"Failed to archive rebaselined metrics into metrics.zip"); + } + } } delete self.runner; @@ -99,14 +146,18 @@ } - (NSString*) getStyleResultPath { - return self.styleResultPath; + return self.styleResultPath; } - (NSString*) getMetricResultPath { - return self.metricResultPath; + return self.metricResultPath; +} + +- (NSString*) getMetricPath { + return self.metricPath; } - (BOOL) getTestStatus { - return self.testStatus; + return self.testStatus; } @end |