aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMScriptRunnerTest.m
diff options
context:
space:
mode:
authorGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-06-03 17:15:14 +0000
committerGravatar gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-06-03 17:15:14 +0000
commitf73258a5111224da89ee20c7c89f2bf41d44b431 (patch)
tree808a074cee56d2837a879a7cd33eecf237daead2 /Foundation/GTMScriptRunnerTest.m
parentaf75496ff656f8b7ec5eca5507fcd1641c2a5ab9 (diff)
[Author: thomasvl]
Add a unittest for http://code.google.com/p/google-toolbox-for-mac/issues/detail?id=25 the bug isn't fixed yet, so the failing parts (they hang) are blocked from running. R=dmaclach DELTA=53 (53 added, 0 deleted, 0 changed)
Diffstat (limited to 'Foundation/GTMScriptRunnerTest.m')
-rw-r--r--Foundation/GTMScriptRunnerTest.m53
1 files changed, 53 insertions, 0 deletions
diff --git a/Foundation/GTMScriptRunnerTest.m b/Foundation/GTMScriptRunnerTest.m
index 3d74b9e..1da7f78 100644
--- a/Foundation/GTMScriptRunnerTest.m
+++ b/Foundation/GTMScriptRunnerTest.m
@@ -374,6 +374,59 @@
STAssertNil(err, nil);
}
+- (void)testLargeOutput {
+ // These tests cover the issues found in
+ // http://code.google.com/p/google-toolbox-for-mac/issues/detail?id=25
+
+ GTMScriptRunner *sr = [GTMScriptRunner runnerWithPython];
+ STAssertNotNil(sr, @"Script runner must not be nil");
+ NSString *output = nil, *err = nil, *cmd = nil;
+
+ NSString *generator_format_str =
+ @"import sys\n"
+ @"block = '.' * 512\n"
+ @"for x in [%@]:\n"
+ @" to_where = x[0]\n"
+ @" how_many = int(x[1:])\n"
+ @" for x in xrange(0, how_many):\n"
+ @" if to_where in [ 'o', 'b' ]:\n"
+ @" sys.stdout.write(block)\n"
+ @" if to_where in [ 'e', 'b' ]:\n"
+ @" sys.stderr.write(block)\n";
+
+ // Make sure we get both blocks
+ cmd = [NSString stringWithFormat:generator_format_str, @"'b1'"];
+ STAssertNotNil(cmd, nil);
+ output = [sr run:cmd standardError:&err];
+ STAssertEquals([output length], (NSUInteger)512, nil);
+ STAssertEquals([err length], (NSUInteger)512, nil);
+
+ // Test a large amount of data on only one connections at a time.
+ cmd = [NSString stringWithFormat:generator_format_str, @"'b1', 'o200'"];
+ STAssertNotNil(cmd, nil);
+ output = [sr run:cmd standardError:&err];
+ STAssertEquals([output length], (NSUInteger)(512 + 512*200), nil);
+ STAssertEquals([err length], (NSUInteger)512, nil);
+#if 0
+ // Not fixed yet
+ cmd = [NSString stringWithFormat:generator_format_str, @"'b1', 'e200'"];
+ STAssertNotNil(cmd, nil);
+ output = [sr run:cmd standardError:&err];
+ STAssertEquals([output length], (NSUInteger)512, nil);
+ STAssertEquals([err length], (NSUInteger)(512 + 512*200), nil);
+#endif
+
+ // Now send a large amount down both to make sure we spool it all in.
+#if 0
+ // Not fixed yet
+ cmd = [NSString stringWithFormat:generator_format_str, @"'b200'"];
+ STAssertNotNil(cmd, nil);
+ output = [sr run:cmd standardError:&err];
+ STAssertEquals([output length], (NSUInteger)(512*200), nil);
+ STAssertEquals([err length], (NSUInteger)(512*200), nil);
+#endif
+}
+
@end