Skip to content

Commit

Permalink
Change buildslave's testPunctuation to not depend on the platform
Browse files Browse the repository at this point in the history
As a side effect, it now effectively checks that individual arguments are
passed properly, instead of just verifying their concatenation.
  • Loading branch information
SpecLad committed Oct 5, 2014
1 parent ffc2c3f commit f50a98e
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions slave/buildslave/test/unit/test_runprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def scriptCommand(function, *args):
runprocess_scripts = util.sibpath(__file__, 'runprocess-scripts.py')
return [sys.executable, runprocess_scripts, function] + list(args)


def printArgsCommand():
return [sys.executable, '-c', 'import sys; sys.stdout.write(repr(sys.argv[1:]))']


# windows returns rc 1, because exit status cannot indicate "signalled";
# posix returns rc -1 for "signalled"
FATAL_RC = -1
Expand Down Expand Up @@ -264,20 +269,14 @@ def testPunctuation(self):
# make sure special characters make it through unscathed
b = FakeSlaveBuilder(False, self.basedir)
punct = r'''!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~'''
s = runprocess.RunProcess(b, ['echo', punct, '%PATH%'],
args = [punct, '%PATH%']
s = runprocess.RunProcess(b, printArgsCommand() + args,
self.basedir)

d = s.start()

if runtime.platformType == "win32":
# Windows echo doesn't parse arguments, so they remain
# quoted/escaped
out_punct = '"' + punct.replace('"', r'\"') + '"'
else:
out_punct = punct

def check(ign):
self.failUnless({'stdout': nl(out_punct + ' %PATH%\n')} in b.updates, b.show())
self.failUnless({'stdout': nl(repr(args))} in b.updates, b.show())
self.failUnless({'rc': 0} in b.updates, b.show())
d.addCallback(check)
return d
Expand Down

0 comments on commit f50a98e

Please sign in to comment.