diff --git a/Tests/base/NSTask/general.m b/Tests/base/NSTask/general.m index 80b882e6e..852ab5ddf 100644 --- a/Tests/base/NSTask/general.m +++ b/Tests/base/NSTask/general.m @@ -10,6 +10,8 @@ int main() NSAutoreleasePool *arp = [NSAutoreleasePool new]; NSFileManager *mgr; NSString *helpers; + NSString *testecho; + NSString *testcat; NSArray *args; id task; id info; @@ -18,6 +20,16 @@ int main() id pth2; 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]; env = [[info environment] mutableCopy]; yes = YES; @@ -32,7 +44,8 @@ int main() helpers = [helpers stringByAppendingPathComponent: @"Helpers"]; 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 and Windows (and others?) */ @@ -43,7 +56,6 @@ int main() task = [NSTask new]; args = [NSArray arrayWithObjects: @"xxx", @"yyy", nil]; - pth2 = [helpers stringByAppendingPathComponent: @"testecho"]; [task setEnvironment: env]; [task setLaunchPath: pth2]; [task setArguments: args]; diff --git a/Tests/base/NSTask/launch.m b/Tests/base/NSTask/launch.m index e93a41378..3605b4aad 100644 --- a/Tests/base/NSTask/launch.m +++ b/Tests/base/NSTask/launch.m @@ -8,15 +8,28 @@ int main() { + NSAutoreleasePool *arp = [NSAutoreleasePool new]; NSTask *task; NSPipe *outPipe; NSFileManager *mgr; NSString *helpers; + NSString *testecho; + NSString *testcat; + NSString *processgroup; NSFileHandle *outHandle; - NSAutoreleasePool *arp; 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]; helpers = [mgr currentDirectoryPath]; @@ -25,7 +38,7 @@ int main() task = [[NSTask alloc] init]; outPipe = [[NSPipe pipe] retain]; - [task setLaunchPath: [helpers stringByAppendingPathComponent: @"testcat"]]; + [task setLaunchPath: [helpers stringByAppendingPathComponent: testcat]]; [task setArguments: [NSArray arrayWithObjects: nil]]; [task setStandardOutput: outPipe]; outHandle = [outPipe fileHandleForReading]; @@ -39,7 +52,7 @@ int main() task = [[NSTask alloc] init]; outPipe = [[NSPipe pipe] retain]; - [task setLaunchPath: [helpers stringByAppendingPathComponent: @"testecho"]]; + [task setLaunchPath: [helpers stringByAppendingPathComponent: testecho]]; [task setArguments: [NSArray arrayWithObjects: @"Hello", @"there", nil]]; [task setStandardOutput: outPipe]; outHandle = [outPipe fileHandleForReading]; @@ -59,7 +72,7 @@ int main() #if !defined(_WIN32) task = [[NSTask alloc] init]; [task setLaunchPath: - [helpers stringByAppendingPathComponent: @"processgroup"]]; + [helpers stringByAppendingPathComponent: processgroup]]; [task setArguments: [NSArray arrayWithObjects: [NSString stringWithFormat: @"%d", getpgrp()], nil]]; diff --git a/Tests/base/NSTask/notify.m b/Tests/base/NSTask/notify.m index 221d3e453..c5e32c84c 100644 --- a/Tests/base/NSTask/notify.m +++ b/Tests/base/NSTask/notify.m @@ -32,7 +32,19 @@ static BOOL taskTerminationNotificationReceived; - (void) testNSTaskNotifications { NSDate *deadline; + NSString *testsleep; + NSString *testecho; 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 (;;) { @@ -48,7 +60,7 @@ static BOOL taskTerminationNotificationReceived; { BOOL terminated = NO; [task setLaunchPath: - [path stringByAppendingPathComponent: @"testsleep"]]; + [path stringByAppendingPathComponent: testsleep]]; [task launch]; NSLog(@"Launched pid %d", [task processIdentifier]); NSLog(@"Running run loop for 5 seconds"); @@ -74,7 +86,7 @@ static BOOL taskTerminationNotificationReceived; else { [task setLaunchPath: - [path stringByAppendingPathComponent: @"testecho"]]; + [path stringByAppendingPathComponent: testecho]]; [task launch]; NSLog(@"Launched pid %d", [task processIdentifier]); NSLog(@"Running run loop for 15 seconds");