Skip to content

Commit

Permalink
test for non existent directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Frith-Macdonald committed Oct 10, 2023
1 parent a5a9423 commit f0f841c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Tests/base/NSTask/launch.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#import <Foundation/NSFileManager.h>
#import <Foundation/NSData.h>
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSError.h>
#import <Foundation/FoundationErrors.h>

#import "ObjectTesting.h"

Expand All @@ -13,6 +15,7 @@
int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSError *error;
NSTask *task;
NSPipe *outPipe;
NSFileManager *mgr;
Expand Down Expand Up @@ -51,7 +54,8 @@ int main()
PASS([task standardOutput] == outPipe, "standardOutput returns pipe");
data = [outHandle readDataToEndOfFile];
PASS([data length] > 0, "was able to read data from subtask");
NSLog(@"Data was %*.*s", [data length], [data length], [data bytes]);
NSLog(@"Data was %*.*s",
(int)[data length], (int)[data length], (const char*)[data bytes]);
[task terminate];

task = [[NSTask alloc] init];
Expand All @@ -64,7 +68,8 @@ int main()
[task launch];
data = [outHandle readDataToEndOfFile];
PASS([data length] > 0, "was able to read data from subtask");
NSLog(@"Data was %*.*s", [data length], [data length], [data bytes]);
NSLog(@"Data was %*.*s",
(int)[data length], (int)[data length], (const char*)[data bytes]);
[task terminate];


Expand All @@ -73,6 +78,16 @@ int main()
[outPipe release];
[task release];

task = [[NSTask alloc] init];
[task setLaunchPath: [helpers stringByAppendingPathComponent: testcat]];
[task setArguments: [NSArray arrayWithObjects: nil]];
[task setCurrentDirectoryPath: @"not-a-directory"];
PASS([task launchAndReturnError: &error] == NO, "bad directory fails launch")
PASS(error != nil, "error is returned")
PASS([error domain] == NSCocoaErrorDomain, "error has expected domain")
PASS([error code] == NSFileNoSuchFileError, "error has expected code")
[task release];

#if !defined(_WIN32)
task = [[NSTask alloc] init];
[task setLaunchPath:
Expand Down

0 comments on commit f0f841c

Please sign in to comment.