From c53ec5520e39096e0804ce8d89a21378c0904481 Mon Sep 17 00:00:00 2001 From: thomasvl Date: Fri, 13 Jun 2008 19:21:50 +0000 Subject: Landing a log of AppleScript/AppleEvent support code. Landing GTMHTTPServer as a simple server but mainly for use in unittesting. _GTMCompileAssert for doing compile time assertions to GTMDefines.h Lots of improvments for UnitTesting, Dave's gonna put up a wiki page shortly with the full details of what can be done. --- Foundation/GTMScriptRunnerTest.m | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'Foundation/GTMScriptRunnerTest.m') diff --git a/Foundation/GTMScriptRunnerTest.m b/Foundation/GTMScriptRunnerTest.m index 5229800..45378bc 100644 --- a/Foundation/GTMScriptRunnerTest.m +++ b/Foundation/GTMScriptRunnerTest.m @@ -20,8 +20,9 @@ #import #import "GTMSenTestCase.h" #import "GTMScriptRunner.h" +#import "GTMUnitTestDevLog.h" -@interface GTMScriptRunnerTest : SenTestCase { +@interface GTMScriptRunnerTest : GTMTestCase { @private NSString *shScript_; NSString *perlScript_; @@ -67,14 +68,17 @@ - (void)tearDown { const char *path = [shScript_ fileSystemRepresentation]; - if (path) + if (path) { unlink(path); + } path = [perlScript_ fileSystemRepresentation]; - if (path) + if (path) { unlink(path); + } path = [shOutputScript_ fileSystemRepresentation]; - if (path) + if (path) { unlink(path); + } } - (void)testShCommands { @@ -184,30 +188,30 @@ output = [sr run:@"/usr/bin/env | wc -l"]; int numVars = [output intValue]; - STAssertTrue(numVars > 0, @"numVars should be positive"); + STAssertGreaterThan(numVars, 0, @"numVars should be positive"); // By default the environment is wiped clean, however shells often add a few // of their own env vars after things have been wiped. For example, sh will // add about 3 env vars (PWD, _, and SHLVL). - STAssertTrue(numVars < 5, @"Our env should be almost empty"); + STAssertLessThan(numVars, 5, @"Our env should be almost empty"); NSDictionary *newEnv = [NSDictionary dictionaryWithObject:@"bar" forKey:@"foo"]; [sr setEnvironment:newEnv]; output = [sr run:@"/usr/bin/env | wc -l"]; - STAssertTrue([output intValue] == numVars + 1, + STAssertEquals([output intValue], numVars + 1, @"should have one more env var now"); [sr setEnvironment:nil]; output = [sr run:@"/usr/bin/env | wc -l"]; - STAssertTrue([output intValue] == numVars, + STAssertEquals([output intValue], numVars, @"should be back down to %d vars", numVars); NSDictionary *currVars = [[NSProcessInfo processInfo] environment]; [sr setEnvironment:currVars]; output = [sr run:@"/usr/bin/env | wc -l"]; - STAssertTrue([output intValue] == [currVars count], + STAssertEquals([output intValue], (int)[currVars count], @"should be back down to %d vars", numVars); } @@ -339,6 +343,8 @@ STAssertNil([sr run:nil standardError:&err], nil); STAssertNil(err, nil); + [GTMUnitTestDevLog expectString:@"Failed to launch interpreter " + "'/path/that/does/not/exists/interpreter' due to: launch path not accessible"]; STAssertNil([sr run:@"ls /" standardError:&err], nil); STAssertNil(err, nil); } @@ -349,8 +355,12 @@ STAssertNotNil(sr, @"Script runner must not be nil"); NSString *err = nil; + [GTMUnitTestDevLog expectString:@"Failed to launch interpreter " + "'/path/that/does/not/exists/interpreter' due to: launch path not accessible"]; STAssertNil([sr runScript:shScript_ withArgs:nil standardError:&err], nil); STAssertNil(err, nil); + [GTMUnitTestDevLog expectString:@"Failed to launch interpreter " + "'/path/that/does/not/exists/interpreter' due to: launch path not accessible"]; STAssertNil([sr runScript:@"/path/that/does/not/exists/foo/bar/baz" withArgs:nil standardError:&err], nil); STAssertNil(err, nil); -- cgit v1.2.3