mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-11 00:30:49 +00:00
Conditionally use .exe suffix in executable paths in NSTask tests
This commit is contained in:
parent
e84fd88e6b
commit
dd2d3f684c
3 changed files with 46 additions and 9 deletions
|
@ -10,6 +10,8 @@ int main()
|
||||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||||
NSFileManager *mgr;
|
NSFileManager *mgr;
|
||||||
NSString *helpers;
|
NSString *helpers;
|
||||||
|
NSString *testecho;
|
||||||
|
NSString *testcat;
|
||||||
NSArray *args;
|
NSArray *args;
|
||||||
id task;
|
id task;
|
||||||
id info;
|
id info;
|
||||||
|
@ -18,6 +20,16 @@ int main()
|
||||||
id pth2;
|
id pth2;
|
||||||
BOOL yes;
|
BOOL yes;
|
||||||
|
|
||||||
|
/* Windows MSVC adds the '.exe' suffix to executables
|
||||||
|
*/
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
testecho = @"testecho.exe";
|
||||||
|
testcat = @"testcat.exe";
|
||||||
|
#else
|
||||||
|
testecho = @"testecho";
|
||||||
|
testcat = @"testcat";
|
||||||
|
#endif
|
||||||
|
|
||||||
info = [NSProcessInfo processInfo];
|
info = [NSProcessInfo processInfo];
|
||||||
env = [[info environment] mutableCopy];
|
env = [[info environment] mutableCopy];
|
||||||
yes = YES;
|
yes = YES;
|
||||||
|
@ -32,7 +44,8 @@ int main()
|
||||||
helpers = [helpers stringByAppendingPathComponent: @"Helpers"];
|
helpers = [helpers stringByAppendingPathComponent: @"Helpers"];
|
||||||
helpers = [helpers stringByAppendingPathComponent: @"obj"];
|
helpers = [helpers stringByAppendingPathComponent: @"obj"];
|
||||||
|
|
||||||
pth1 = [helpers stringByAppendingPathComponent: @"testcat"];
|
pth1 = [helpers stringByAppendingPathComponent: testcat];
|
||||||
|
pth2 = [helpers stringByAppendingPathComponent: testecho];
|
||||||
|
|
||||||
/* Try some tasks. Make sure the program we use is common between Unix
|
/* Try some tasks. Make sure the program we use is common between Unix
|
||||||
and Windows (and others?) */
|
and Windows (and others?) */
|
||||||
|
@ -43,7 +56,6 @@ int main()
|
||||||
|
|
||||||
task = [NSTask new];
|
task = [NSTask new];
|
||||||
args = [NSArray arrayWithObjects: @"xxx", @"yyy", nil];
|
args = [NSArray arrayWithObjects: @"xxx", @"yyy", nil];
|
||||||
pth2 = [helpers stringByAppendingPathComponent: @"testecho"];
|
|
||||||
[task setEnvironment: env];
|
[task setEnvironment: env];
|
||||||
[task setLaunchPath: pth2];
|
[task setLaunchPath: pth2];
|
||||||
[task setArguments: args];
|
[task setArguments: args];
|
||||||
|
|
|
@ -8,15 +8,28 @@
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||||
NSTask *task;
|
NSTask *task;
|
||||||
NSPipe *outPipe;
|
NSPipe *outPipe;
|
||||||
NSFileManager *mgr;
|
NSFileManager *mgr;
|
||||||
NSString *helpers;
|
NSString *helpers;
|
||||||
|
NSString *testecho;
|
||||||
|
NSString *testcat;
|
||||||
|
NSString *processgroup;
|
||||||
NSFileHandle *outHandle;
|
NSFileHandle *outHandle;
|
||||||
NSAutoreleasePool *arp;
|
|
||||||
NSData *data = nil;
|
NSData *data = nil;
|
||||||
|
|
||||||
arp = [[NSAutoreleasePool alloc] init];
|
/* Windows MSVC adds the '.exe' suffix to executables
|
||||||
|
*/
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
testecho = @"testecho.exe";
|
||||||
|
testcat = @"testcat.exe";
|
||||||
|
processgroup = @"processgroup.exe";
|
||||||
|
#else
|
||||||
|
testecho = @"testecho";
|
||||||
|
testcat = @"testcat";
|
||||||
|
processgroup = @"processgroup";
|
||||||
|
#endif
|
||||||
|
|
||||||
mgr = [NSFileManager defaultManager];
|
mgr = [NSFileManager defaultManager];
|
||||||
helpers = [mgr currentDirectoryPath];
|
helpers = [mgr currentDirectoryPath];
|
||||||
|
@ -25,7 +38,7 @@ int main()
|
||||||
|
|
||||||
task = [[NSTask alloc] init];
|
task = [[NSTask alloc] init];
|
||||||
outPipe = [[NSPipe pipe] retain];
|
outPipe = [[NSPipe pipe] retain];
|
||||||
[task setLaunchPath: [helpers stringByAppendingPathComponent: @"testcat"]];
|
[task setLaunchPath: [helpers stringByAppendingPathComponent: testcat]];
|
||||||
[task setArguments: [NSArray arrayWithObjects: nil]];
|
[task setArguments: [NSArray arrayWithObjects: nil]];
|
||||||
[task setStandardOutput: outPipe];
|
[task setStandardOutput: outPipe];
|
||||||
outHandle = [outPipe fileHandleForReading];
|
outHandle = [outPipe fileHandleForReading];
|
||||||
|
@ -39,7 +52,7 @@ int main()
|
||||||
|
|
||||||
task = [[NSTask alloc] init];
|
task = [[NSTask alloc] init];
|
||||||
outPipe = [[NSPipe pipe] retain];
|
outPipe = [[NSPipe pipe] retain];
|
||||||
[task setLaunchPath: [helpers stringByAppendingPathComponent: @"testecho"]];
|
[task setLaunchPath: [helpers stringByAppendingPathComponent: testecho]];
|
||||||
[task setArguments: [NSArray arrayWithObjects: @"Hello", @"there", nil]];
|
[task setArguments: [NSArray arrayWithObjects: @"Hello", @"there", nil]];
|
||||||
[task setStandardOutput: outPipe];
|
[task setStandardOutput: outPipe];
|
||||||
outHandle = [outPipe fileHandleForReading];
|
outHandle = [outPipe fileHandleForReading];
|
||||||
|
@ -59,7 +72,7 @@ int main()
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
task = [[NSTask alloc] init];
|
task = [[NSTask alloc] init];
|
||||||
[task setLaunchPath:
|
[task setLaunchPath:
|
||||||
[helpers stringByAppendingPathComponent: @"processgroup"]];
|
[helpers stringByAppendingPathComponent: processgroup]];
|
||||||
[task setArguments: [NSArray arrayWithObjects:
|
[task setArguments: [NSArray arrayWithObjects:
|
||||||
[NSString stringWithFormat: @"%d", getpgrp()],
|
[NSString stringWithFormat: @"%d", getpgrp()],
|
||||||
nil]];
|
nil]];
|
||||||
|
|
|
@ -32,7 +32,19 @@ static BOOL taskTerminationNotificationReceived;
|
||||||
- (void) testNSTaskNotifications
|
- (void) testNSTaskNotifications
|
||||||
{
|
{
|
||||||
NSDate *deadline;
|
NSDate *deadline;
|
||||||
|
NSString *testsleep;
|
||||||
|
NSString *testecho;
|
||||||
BOOL earlyTermination = NO;
|
BOOL earlyTermination = NO;
|
||||||
|
|
||||||
|
/* Windows MSVC adds the '.exe' suffix to executables
|
||||||
|
*/
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
testecho = @"testecho.exe";
|
||||||
|
testsleep = @"testsleep.exe";
|
||||||
|
#else
|
||||||
|
testecho = @"testecho";
|
||||||
|
testsleep = @"testsleep.exe";
|
||||||
|
#endif
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +60,7 @@ static BOOL taskTerminationNotificationReceived;
|
||||||
{
|
{
|
||||||
BOOL terminated = NO;
|
BOOL terminated = NO;
|
||||||
[task setLaunchPath:
|
[task setLaunchPath:
|
||||||
[path stringByAppendingPathComponent: @"testsleep"]];
|
[path stringByAppendingPathComponent: testsleep]];
|
||||||
[task launch];
|
[task launch];
|
||||||
NSLog(@"Launched pid %d", [task processIdentifier]);
|
NSLog(@"Launched pid %d", [task processIdentifier]);
|
||||||
NSLog(@"Running run loop for 5 seconds");
|
NSLog(@"Running run loop for 5 seconds");
|
||||||
|
@ -74,7 +86,7 @@ static BOOL taskTerminationNotificationReceived;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[task setLaunchPath:
|
[task setLaunchPath:
|
||||||
[path stringByAppendingPathComponent: @"testecho"]];
|
[path stringByAppendingPathComponent: testecho]];
|
||||||
[task launch];
|
[task launch];
|
||||||
NSLog(@"Launched pid %d", [task processIdentifier]);
|
NSLog(@"Launched pid %d", [task processIdentifier]);
|
||||||
NSLog(@"Running run loop for 15 seconds");
|
NSLog(@"Running run loop for 15 seconds");
|
||||||
|
|
Loading…
Reference in a new issue