Skip to content

Commit

Permalink
Add logging to debug failed listing due to invalid format
Browse files Browse the repository at this point in the history
Summary: Many tests are failing due to the error "Failed to list tests". Logs include the error "The data couldn’t be read because it isn’t in the correct format." This diff adds logs to see when a test should be added to the listing, and if the listing fails, what the description of the data that should contain the test listing entails.

Reviewed By: lawrencelomax

Differential Revision: D64563764

fbshipit-source-id: e2d75d9935730b205a8d73371ac04c692d832ed9
Abrar Ahmed authored and facebook-github-bot committed Oct 18, 2024
1 parent f2e4cea commit 7385ce7
Showing 2 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions Shims/Shimulator/TestReporterShim/XCTestReporterShim.m
Original file line number Diff line number Diff line change
@@ -614,6 +614,7 @@ static void listBundle(NSString *testBundlePath, NSString *outputFile)
NSString *testKey = nil;
parseXCTestCase(testCase, &className, &methodName, &testKey);
NSString *legacyTestName = [NSString stringWithFormat:@"%@/%@", className, methodName];
NSLog(@"Found test: %@", legacyTestName);
[testsToReport addObject:@{
kReporter_ListTest_LegacyTestNameKey: legacyTestName,
kReporter_ListTest_ClassNameKey: className,
15 changes: 8 additions & 7 deletions XCTestBootstrap/Strategies/FBListTestStrategy.m
Original file line number Diff line number Diff line change
@@ -38,10 +38,10 @@ - (instancetype)initWithStrategy:(FBListTestStrategy *)strategy reporter:(id<FBX
if (!self) {
return nil;
}

_strategy = strategy;
_reporter = reporter;

return self;
}

@@ -111,14 +111,14 @@ - (instancetype)initWithTarget:(id<FBiOSTarget, FBProcessSpawnCommands, FBXCTest
stdErrBuffer,
[FBLoggingDataConsumer consumerWithLogger:self.logger],
]];

return [[[FBTemporaryDirectory temporaryDirectoryWithLogger:self.logger] withTemporaryDirectory]
onQueue:self.target.workQueue pop:^FBFuture *(NSURL *temporaryDirectory) {
return [[FBOToolDynamicLibs
findFullPathForSanitiserDyldInBundle:self.configuration.testBundlePath onQueue:self.target.workQueue]
onQueue:self.target.workQueue fmap:^FBFuture<NSNull *> * (NSArray<NSString *> *libraries){
NSDictionary<NSString *, NSString *> *environment = [FBListTestStrategy setupEnvironmentWithDylibs:libraries shimPath:shimPath shimOutputFilePath:shimOutput.filePath bundlePath:self.configuration.testBundlePath];

return [[FBListTestStrategy
listTestProcessWithTarget:self.target
configuration:self.configuration
@@ -171,6 +171,7 @@ - (instancetype)initWithTarget:(id<FBiOSTarget, FBProcessSpawnCommands, FBXCTest
NSError *error = nil;
NSArray<NSDictionary<NSString *, NSString *> *> *tests = [NSJSONSerialization JSONObjectWithData:shimBuffer.data options:0 error:&error];
if (!tests) {
NSLog(@"Shimulator buffer data (should contain test information): %@", shimBuffer.data);
return [FBFuture futureWithError:error];
}
NSMutableArray<NSString *> *testNames = [NSMutableArray array];
@@ -211,7 +212,7 @@ - (instancetype)initWithTarget:(id<FBiOSTarget, FBProcessSpawnCommands, FBXCTest
NSString *launchPath = xctestPath;
NSTimeInterval timeout = configuration.testTimeout;


FBProcessIO *io = [[FBProcessIO alloc] initWithStdIn:nil stdOut:[FBProcessOutput outputForDataConsumer:stdOutConsumer] stdErr:[FBProcessOutput outputForDataConsumer:stdErrConsumer]];
// List test for app test bundle, so we use app binary instead of xctest to load test bundle.
if ([FBBundleDescriptor isApplicationAtPath:configuration.runnerAppPath]) {
@@ -240,11 +241,11 @@ - (instancetype)initWithTarget:(id<FBiOSTarget, FBProcessSpawnCommands, FBXCTest
launchPath = appBundle.binary.path;
FBProcessSpawnConfiguration *spawnConfiguration = [[FBProcessSpawnConfiguration alloc] initWithLaunchPath:launchPath arguments:@[] environment:environment io:io mode:FBProcessSpawnModeDefault];
return [FBListTestStrategy listTestProcessWithSpawnConfiguration:spawnConfiguration onTarget:target timeout:timeout logger:logger];

} else {
FBProcessSpawnConfiguration *spawnConfiguration = [[FBProcessSpawnConfiguration alloc] initWithLaunchPath:launchPath arguments:@[] environment:environment io:io mode:FBProcessSpawnModeDefault];
FBArchitectureProcessAdapter *adapter = [[FBArchitectureProcessAdapter alloc] init];

// Note process adapter may change process configuration launch binary path if it decided to isolate desired arch.
// For more information look at `FBArchitectureProcessAdapter` docs.
return [[adapter adaptProcessConfiguration:spawnConfiguration toAnyArchitectureIn:configuration.architectures queue:target.workQueue temporaryDirectory:temporaryDirectory]

0 comments on commit 7385ce7

Please sign in to comment.