From f73258a5111224da89ee20c7c89f2bf41d44b431 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Wed, 3 Jun 2009 17:15:14 +0000 Subject: [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) --- Foundation/GTMScriptRunnerTest.m | 53 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'Foundation/GTMScriptRunnerTest.m') 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 -- cgit v1.2.3