Exemple #1
0
    def testKeepStderr(self):
        b = FakeWorkerForBuilder(self.basedir)
        s = runprocess.RunProcess(
            b, stderrCommand("hello"), self.basedir, keepStderr=True)

        yield s.start()

        self.assertTrue({'stderr': nl('hello\n')} in b.updates, b.show())
        self.assertTrue({'rc': 0} in b.updates, b.show())
        self.assertEqual(s.stderr, nl('hello\n'))
Exemple #2
0
    def testMultiWordStringCommandQuotes(self):
        b = FakeWorkerForBuilder(self.basedir)
        # careful!  This command must execute the same on windows and UNIX
        s = runprocess.RunProcess(b, 'echo "Happy Days and Jubilation"',
                                  self.basedir)

        if runtime.platformType == "win32":
            # echo doesn't parse out the quotes, so they come through in the
            # output
            exp = nl('"Happy Days and Jubilation"\n')
        else:
            exp = nl('Happy Days and Jubilation\n')
        yield s.start()

        self.assertTrue({'stdout': exp} in b.updates, b.show())
        self.assertTrue({'rc': 0} in b.updates, b.show())
Exemple #3
0
    def testStderr(self):
        b = FakeWorkerForBuilder(self.basedir)
        s = runprocess.RunProcess(b, stderrCommand("hello"), self.basedir)

        yield s.start()

        self.failIf({'stderr': nl('hello\n')} not in b.updates, b.show())
        self.assertTrue({'rc': 0} in b.updates, b.show())
Exemple #4
0
    def testStart(self):
        b = FakeWorkerForBuilder(self.basedir)
        s = runprocess.RunProcess(b, stdoutCommand('hello'), self.basedir)

        yield s.start()

        self.assertTrue({'stdout': nl('hello\n')} in b.updates, b.show())
        self.assertTrue({'rc': 0} in b.updates, b.show())
Exemple #5
0
    def testStringCommand(self):
        b = FakeWorkerForBuilder(self.basedir)
        # careful!  This command must execute the same on windows and UNIX
        s = runprocess.RunProcess(b, 'echo hello', self.basedir)

        yield s.start()

        self.assertTrue({'stdout': nl('hello\n')} in b.updates, b.show())
        self.assertTrue({'rc': 0} in b.updates, b.show())
Exemple #6
0
    def testInitialStdinUnicode(self):
        b = FakeWorkerForBuilder(self.basedir)
        s = runprocess.RunProcess(
            b, catCommand(), self.basedir, initialStdin=u'hello')

        yield s.start()

        self.assertTrue({'stdout': nl('hello')} in b.updates, b.show())
        self.assertTrue({'rc': 0} in b.updates, b.show())
    def testMultiWordStringCommandQuotes(self):
        b = FakeSlaveBuilder(False, self.basedir)
        # careful!  This command must execute the same on windows and UNIX
        s = runprocess.RunProcess(b, 'echo "Happy Days and Jubilation"',
                                  self.basedir)

        if runtime.platformType == "win32":
            # echo doesn't parse out the quotes, so they come through in the
            # output
            exp = nl('"Happy Days and Jubilation"\n')
        else:
            exp = nl('Happy Days and Jubilation\n')
        d = s.start()

        def check(ign):
            self.failUnless({'stdout': exp} in b.updates, b.show())
            self.failUnless({'rc': 0} in b.updates, b.show())
        d.addCallback(check)
        return d
Exemple #8
0
    def testPipeString(self):
        b = FakeWorkerForBuilder(self.basedir)
        # this is highly contrived, but it proves the point.
        cmd = sys.executable + \
            ' -c "import sys; sys.stdout.write(\'b\\na\\n\')" | sort'
        s = runprocess.RunProcess(b, cmd, self.basedir)

        yield s.start()

        self.assertTrue({'stdout': nl('a\nb\n')} in b.updates, b.show())
        self.assertTrue({'rc': 0} in b.updates, b.show())
Exemple #9
0
    def testMultiWordStringCommand(self):
        b = FakeWorkerForBuilder(self.basedir)
        # careful!  This command must execute the same on windows and UNIX
        s = runprocess.RunProcess(b, 'echo Happy Days and Jubilation',
                                  self.basedir)

        # no quoting occurs
        exp = nl('Happy Days and Jubilation\n')
        yield s.start()

        self.assertTrue({'stdout': exp} in b.updates, b.show())
        self.assertTrue({'rc': 0} in b.updates, b.show())
Exemple #10
0
    def testCommandMaxTime(self):
        b = FakeWorkerForBuilder(self.basedir)
        s = runprocess.RunProcess(b, sleepCommand(10), self.basedir, maxTime=5)
        clock = task.Clock()
        s._reactor = clock

        d = s.start()
        clock.advance(6)  # should knock out maxTime
        yield d

        self.assertTrue(
            {'stdout': nl('hello\n')} not in b.updates, b.show())
        self.assertTrue({'rc': FATAL_RC} in b.updates, b.show())
Exemple #11
0
    def testMultiWordStringCommand(self):
        b = FakeWorkerForBuilder(self.basedir)
        # careful!  This command must execute the same on windows and UNIX
        s = runprocess.RunProcess(b, 'echo Happy Days and Jubilation',
                                  self.basedir)

        # no quoting occurs
        exp = nl('Happy Days and Jubilation\n')
        d = s.start()

        def check(ign):
            self.failUnless({'stdout': exp} in b.updates, b.show())
            self.failUnless({'rc': 0} in b.updates, b.show())
        d.addCallback(check)
        return d
Exemple #12
0
    def testTrickyArguments(self):
        # make sure non-trivial arguments are passed verbatim
        b = FakeWorkerForBuilder(self.basedir)

        args = [
            'Happy Days and Jubilation',  # spaces
            r'''!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~''',  # special characters
            '%PATH%',  # Windows variable expansions
            # Expansions get an argument of their own, because the Windows
            # shell doesn't treat % as special unless it surrounds a
            # variable name.
        ]

        s = runprocess.RunProcess(b, printArgsCommand() + args, self.basedir)
        yield s.start()

        self.assertTrue({'stdout': nl(repr(args))} in b.updates, b.show())
        self.assertTrue({'rc': 0} in b.updates, b.show())
Exemple #13
0
 def check(ign):
     self.failUnless({'stderr': nl('hello\n')} in b.updates, b.show())
     self.failUnless({'rc': 0} in b.updates, b.show())
     self.failUnlessEquals(s.stderr, nl('hello\n'))
Exemple #14
0
 def check(ign):
     self.failIf({'stderr': nl('hello\n')} not in b.updates, b.show())
     self.failUnless({'rc': 0} in b.updates, b.show())
Exemple #15
0
 def check(ign):
     self.assertTrue({'stdout': nl('hello\n')} in b.updates, b.show())
     self.assertTrue({'rc': 0} in b.updates, b.show())
     self.assertEqual(s.stdout, nl('hello\n'))
Exemple #16
0
 def check(ign):
     self.failUnless({'stdout': nl('a\nb\n')} in b.updates, b.show())
     self.failUnless({'rc': 0} in b.updates, b.show())
Exemple #17
0
 def check(ign):
     self.assertTrue({'stdout': nl(repr(args))} in b.updates, b.show())
     self.assertTrue({'rc': 0} in b.updates, b.show())
Exemple #18
0
 def check(ign):
     self.failIf({'stderr': nl('hello\n')} in b.updates, b.show())
     self.assertTrue({'rc': 0} in b.updates, b.show())
Exemple #19
0
 def check(ign):
     self.failUnless({'stdout': nl('a\nb\n')} in b.updates, b.show())
     self.failUnless({'rc': 0} in b.updates, b.show())
 def testSendStatus(self):
     b = FakeSlaveBuilder(False, self.basedir)
     s = runprocess.RunProcess(b, stdoutCommand('hello'), self.basedir)
     s.sendStatus({'stdout': nl('hello\n')})
     self.failUnlessEqual(b.updates, [{'stdout': nl('hello\n')}], b.show())
Exemple #21
0
 def check(ign):
     self.assertTrue(
         {'stdout': nl('hello\n')} not in b.updates, b.show())
     self.assertTrue({'rc': FATAL_RC} in b.updates, b.show())
Exemple #22
0
 def check(ign):
     self.failIf({'stderr': nl('hello\n')} not in b.updates, b.show())
     self.failUnless({'rc': 0} in b.updates, b.show())
Exemple #23
0
 def check(ign):
     self.failUnless({'stderr': nl('hello\n')} in b.updates, b.show())
     self.failUnless({'rc': 0} in b.updates, b.show())
     self.failUnlessEquals(s.stderr, nl('hello\n'))
Exemple #24
0
 def check(ign):
     self.failUnless({'stdout': nl(repr(args))} in b.updates, b.show())
     self.failUnless({'rc': 0} in b.updates, b.show())
Exemple #25
0
 def check(ign):
     self.assertTrue({'stdout': nl('a\nb\n')} in b.updates, b.show())
     self.assertTrue({'rc': 0} in b.updates, b.show())
Exemple #26
0
 def check(ign):
     self.failUnless({'stdout': nl(repr(args))} in b.updates, b.show())
     self.failUnless({'rc': 0} in b.updates, b.show())
Exemple #27
0
 def check(ign):
     self.assertTrue({'stdout': nl('hello\n')} not in b.updates,
                     b.show())
     self.assertTrue({'rc': FATAL_RC} in b.updates, b.show())
Exemple #28
0
 def check(ign):
     self.failUnless(
         {'stdout': nl('hello\n')} not in b.updates, b.show())
     self.failUnless({'rc': FATAL_RC} in b.updates, b.show())
Exemple #29
0
 def testSendStatus(self):
     b = FakeWorkerForBuilder(self.basedir)
     s = runprocess.RunProcess(b, stdoutCommand('hello'), self.basedir)
     s.sendStatus({'stdout': nl('hello\n')})
     self.assertEqual(b.updates, [{'stdout': nl('hello\n')}], b.show())
Exemple #30
0
 def check(ign):
     self.assertTrue({'stderr': nl('hello\n')} in b.updates, b.show())
     self.assertTrue({'rc': 0} in b.updates, b.show())
     self.assertEqual(s.stderr, nl('hello\n'))
Exemple #31
0
 def check(ign):
     self.failIf({'stdout': nl('hello\n')} in b.updates, b.show())
     self.assertTrue({'rc': 0} in b.updates, b.show())
Exemple #32
0
 def check(ign):
     self.assertTrue({'stdout': nl('a\nb\n')} in b.updates, b.show())
     self.assertTrue({'rc': 0} in b.updates, b.show())
Exemple #33
0
 def check(ign):
     self.failUnless(
         {'stdout': nl('hello\n')} not in b.updates, b.show())
     self.failUnless({'rc': FATAL_RC} in b.updates, b.show())
Exemple #34
0
 def testSendStatus(self):
     b = FakeWorkerForBuilder(self.basedir)
     s = runprocess.RunProcess(b, stdoutCommand('hello'), self.basedir)
     s.sendStatus({'stdout': nl('hello\n')})
     self.assertEqual(b.updates, [{'stdout': nl('hello\n')}], b.show())
Exemple #35
0
 def check(ign):
     self.assertTrue({'stdout': nl(repr(args))} in b.updates, b.show())
     self.assertTrue({'rc': 0} in b.updates, b.show())