mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Merge pull request #257 from gnustep/nstask-msvc-test-fixes
Fix NSTask unit tests on Windows MSVC
This commit is contained in:
commit
886a9220da
6 changed files with 56 additions and 10 deletions
|
@ -1,3 +1,12 @@
|
|||
2022-08-05 Hugo Melder <contact@hugomelder.com>
|
||||
|
||||
* Tests/base/NSTask/Helpers/GNUmakefile:
|
||||
Fix compilation of NSTask helper test files on Windows MSVC.
|
||||
* Tests/base/NSTask/general.m:
|
||||
* Tests/base/NSTask/launch.m:
|
||||
* Tests/base/NSTask/notify.m:
|
||||
Conditionally use .exe suffix in executable paths.
|
||||
|
||||
2022-08-04 Hugo Melder <contact@hugomelder.com>
|
||||
|
||||
* Tests/base/coding/basictypes.m:
|
||||
|
|
|
@ -9,7 +9,7 @@ NSZombie_OBJC_FILES = NSZombie.m
|
|||
|
||||
processgroup_OBJC_FILES = processgroup.m
|
||||
|
||||
testcat_OBJC_FILES = testcat.m
|
||||
testcat_C_FILES = testcat.c
|
||||
|
||||
testecho_OBJC_FILES = testecho.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];
|
||||
|
|
|
@ -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]];
|
||||
|
|
|
@ -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";
|
||||
#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");
|
||||
|
|
Loading…
Reference in a new issue