Skip to content

Commit

Permalink
Changed to waitForExpectationsWithTimeout:handler
Browse files Browse the repository at this point in the history
  • Loading branch information
tnek committed Oct 1, 2021
1 parent 9e4467a commit 78c9061
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Testing/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ santa_unit_test(
"//Source/santad/testdata:binaryrules_testdata",
],
srcs = [
"SNTBenchmarkTest.m"
"SNTExecTest.m"
],
deps = [],
minimum_os_version = "10.15",
Expand Down
11 changes: 7 additions & 4 deletions Testing/integration/SNTExecTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ - (void)checkExecution:(NSString *)path shouldExec:(BOOL)shouldExec {
XCTestExpectation *expectation =
[self expectationWithDescription:@"Wait for test binary to execute"];

__block NSTask *task = [[NSTask alloc] init];
dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{
NSTask *task = [[NSTask alloc] init];
task.launchPath = path;
[task launch];
while ([task isRunning])
usleep(100000); // 0.1s
[task waitUntilExit];
status = [task terminationStatus];
[expectation fulfill];
});

[self waitForExpectations:@[ expectation ] timeout:20.0];
[self waitForExpectationsWithTimeout:20.0
handler:^(NSError *error) {
XCTAssertFalse([task isRunning], @"Test timed out: %@", error);
[task terminate];
}];

BOOL didExec = (status == 0);
XCTAssertEqual(didExec, shouldExec);
Expand Down

0 comments on commit 78c9061

Please sign in to comment.