Skip to content

Commit

Permalink
Address review comment: remove temp file when done.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Sep 27, 2024
1 parent 0607ae9 commit 61832b7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ - (void)readAttributeCacheWithController:(id _Nullable)controller
static const uint16_t kTimeoutInSeconds = 3;
static const uint64_t kDeviceId = 0x12344321;
static NSString * kOnboardingPayload = @"MT:Y.K90SO527JA0648G00";
static NSString * _Nullable sLogContentFilePath;
static NSString * kSimpleLogContent = @"This is a simple log\n";
static const uint16_t kLocalPort = 5541;

Expand Down Expand Up @@ -516,14 +517,14 @@ + (void)setUp
[super setUp];

__auto_type * uniqueName = [[NSUUID UUID] UUIDString];
__auto_type * uniquePath = [NSTemporaryDirectory() stringByAppendingPathComponent:uniqueName];
[[NSFileManager defaultManager] createFileAtPath:uniquePath
sLogContentFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:uniqueName];
[[NSFileManager defaultManager] createFileAtPath:sLogContentFilePath
contents:[kSimpleLogContent dataUsingEncoding:NSUTF8StringEncoding]
attributes:nil];
BOOL started = [self startAppWithName:@"all-clusters"
arguments:@[
@"--end_user_support_log",
uniquePath,
sLogContentFilePath,
]
payload:kOnboardingPayload];
XCTAssertTrue(started);
Expand All @@ -532,6 +533,10 @@ + (void)setUp
+ (void)tearDown
{
// Global teardown, runs once
if (sLogContentFilePath != nil) {
[[NSFileManager defaultManager] removeItemAtPath:sLogContentFilePath error:nil];
}

[self shutdownStack];
[super tearDown];
}
Expand Down

0 comments on commit 61832b7

Please sign in to comment.