From be053d369e068dd7cb6ab1274484b339c2082516 Mon Sep 17 00:00:00 2001 From: Abrar Ahmed Date: Tue, 22 Oct 2024 06:50:19 -0700 Subject: [PATCH] Update methods used when listing tests Summary: The methods "writeData:" and "closeFile" have been deprecated, replaced with "writeData:error:" and "closeAndReturnError:" respectively. This may be impacting the listing issues people have been having, which is really due to reading an empty JSON file that should contain the list of tests for a target. Differential Revision: D64705885 fbshipit-source-id: d898f64df61f3797a30410f302aaa7af5d86f266 --- Shims/Shimulator/TestReporterShim/XCTestReporterShim.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Shims/Shimulator/TestReporterShim/XCTestReporterShim.m b/Shims/Shimulator/TestReporterShim/XCTestReporterShim.m index 9c549927f..5d18d2f85 100644 --- a/Shims/Shimulator/TestReporterShim/XCTestReporterShim.m +++ b/Shims/Shimulator/TestReporterShim/XCTestReporterShim.m @@ -629,11 +629,13 @@ static void listBundle(NSString *testBundlePath, NSString *outputFile) }]; NSError *error = nil; NSData *output = [NSJSONSerialization dataWithJSONObject:testsToReport options:0 error:&error]; - NSCAssert(output, @"Failed to generate list test JSON", error); - [fileHandle writeData:output]; + NSCAssert(output, @"Failed to generate test list JSON", error); + bool fileWrittenSuccessfully = [fileHandle writeData:output error:&error]; + NSCAssert(fileWrittenSuccessfully, @"Failed to write test list to file", error); // Close the file so the other end knows this is the end of the input. - [fileHandle closeFile]; + bool fileClosedSuccessfully = [fileHandle closeAndReturnError:&error]; + NSCAssert(fileClosedSuccessfully, @"Failed to close file with test list", error); exit(TestShimExitCodeSuccess); }