Skip to content

Commit

Permalink
Updated signpost code in tests to only run on macOS 10.14 and above
Browse files Browse the repository at this point in the history
  • Loading branch information
abbeycode committed Oct 15, 2020
1 parent b6f2e17 commit 6c49075
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions Tests/ExtractBufferedDataTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,34 @@ - (void)testExtractBufferedData_VeryLarge
{
os_log_t log = os_log_create("UnrarKit-testExtractBufferedData_VeryLarge", OS_LOG_CATEGORY_POINTS_OF_INTEREST);

os_signpost_id_t createTextFileID = os_signpost_id_generate(log);
os_signpost_interval_begin(log, createTextFileID, "Create Text File");
os_signpost_id_t createTextFileID;

if (@available(macOS 10.14, *)) {
createTextFileID = os_signpost_id_generate(log);
os_signpost_interval_begin(log, createTextFileID, "Create Text File");
}

NSURL *largeTextFile = [self randomTextFileOfLength:1000000]; // Increase for a more dramatic test
XCTAssertNotNil(largeTextFile, @"No large text file URL returned");
os_signpost_interval_end(log, createTextFileID, "Create Text File");

os_signpost_id_t archiveDataID = os_signpost_id_generate(log);
os_signpost_interval_begin(log, archiveDataID, "Archive Data");
if (@available(macOS 10.14, *)) {
XCTAssertNotNil(largeTextFile, @"No large text file URL returned");
os_signpost_interval_end(log, createTextFileID, "Create Text File");
}

os_signpost_id_t archiveDataID;

if (@available(macOS 10.14, *)) {
archiveDataID = os_signpost_id_generate(log);
os_signpost_interval_begin(log, archiveDataID, "Archive Data");
}

NSURL *archiveURL = [self archiveWithFiles:@[largeTextFile]];

XCTAssertNotNil(archiveURL, @"No archived large text file URL returned");
os_signpost_interval_end(log, archiveDataID, "Archive Data");

if (@available(macOS 10.14, *)) {
os_signpost_interval_end(log, archiveDataID, "Archive Data");
}

NSURL *deflatedFileURL = [self.tempDirectory URLByAppendingPathComponent:@"DeflatedTextFile.txt"];
BOOL createSuccess = [[NSFileManager defaultManager] createFileAtPath:deflatedFileURL.path
Expand All @@ -122,8 +139,12 @@ - (void)testExtractBufferedData_VeryLarge

URKArchive *archive = [[URKArchive alloc] initWithURL:archiveURL error:nil];

os_signpost_id_t extractDataID = os_signpost_id_generate(log);
os_signpost_interval_begin(log, extractDataID, "Extract Data");
os_signpost_id_t extractDataID;

if (@available(macOS 10.14, *)) {
extractDataID = os_signpost_id_generate(log);
os_signpost_interval_begin(log, extractDataID, "Extract Data");
}

NSError *error = nil;
BOOL success = [archive extractBufferedDataFromFile:largeTextFile.lastPathComponent
Expand All @@ -134,8 +155,10 @@ - (void)testExtractBufferedData_VeryLarge
[deflated writeData:dataChunk];
}];

os_signpost_interval_end(log, extractDataID, "Extract Data");

if (@available(macOS 10.14, *)) {
os_signpost_interval_end(log, extractDataID, "Extract Data");
}

XCTAssertTrue(success, @"Failed to read buffered data");
XCTAssertNil(error, @"Error reading buffered data");

Expand Down

0 comments on commit 6c49075

Please sign in to comment.