예제 #1
0
    def testSequenceStopsOnHaltOnFailure(self):
        arg1 = shellsequence.ShellArg(command='make p1', haltOnFailure=True)
        arg2 = shellsequence.ShellArg(command='deploy p1')

        self.setupStep(
            shellsequence.ShellSequence(commands=[arg1, arg2],
                                        workdir='build'))
        self.expectCommands(ExpectShell(workdir='build', command='make p1') + 1)
        self.expectOutcome(result=FAILURE, state_string="'make p1'")
        return self.runStep()
예제 #2
0
 def testMultipleCommandsAreRun(self):
     arg1 = shellsequence.ShellArg(command='make p1')
     arg2 = shellsequence.ShellArg(command='deploy p1')
     self.setupStep(
         shellsequence.ShellSequence(commands=[arg1, arg2],
                                     workdir='build'))
     self.expectCommands(
         ExpectShell(workdir='build', command='make p1') + 0,
         ExpectShell(workdir='build', command='deploy p1') + 0)
     self.expectOutcome(result=SUCCESS, state_string="'deploy p1'")
     return self.runStep()
예제 #3
0
 def testWarningWins(self):
     arg1 = shellsequence.ShellArg(command='make p1',
                                   warnOnFailure=True,
                                   flunkOnFailure=False)
     arg2 = shellsequence.ShellArg(command='deploy p1')
     self.setupStep(
         shellsequence.ShellSequence(commands=[arg1, arg2],
                                     workdir='build'))
     self.expectCommands(ExpectShell(workdir='build', command='make p1') + 1,
                         ExpectShell(workdir='build', command='deploy p1') + 0)
     self.expectOutcome(result=WARNINGS, state_string="'deploy p1'")
     return self.runStep()
예제 #4
0
 def testSkipWorks(self):
     arg1 = shellsequence.ShellArg(command='make p1')
     arg2 = shellsequence.ShellArg(command='')
     arg3 = shellsequence.ShellArg(command='deploy p1')
     self.setup_step(
         shellsequence.ShellSequence(commands=[arg1, arg2, arg3],
                                     workdir='build'))
     self.expect_commands(
         ExpectShell(workdir='build', command='make p1').exit(0),
         ExpectShell(workdir='build', command='deploy p1').exit(0))
     self.expect_outcome(result=SUCCESS, state_string="'deploy p1'")
     return self.run_step()
예제 #5
0
    def testSequenceStopsOnHaltOnFailure(self):
        arg1 = shellsequence.ShellArg(command='make p1', haltOnFailure=True)
        arg2 = shellsequence.ShellArg(command='deploy p1')

        self.setupStep(
            shellsequence.ShellSequence(commands=[arg1, arg2],
                                        workdir='build'))
        self.expectCommands(
            ExpectShell(
                workdir='build', command='make p1', usePTY="slave-config") + 1)
        self.expectOutcome(result=FAILURE, status_text=["'make", "p1'"])
        return self.runStep()
예제 #6
0
 def testSkipWorks(self):
     arg1 = shellsequence.ShellArg(command='make p1')
     arg2 = shellsequence.ShellArg(command='')
     arg3 = shellsequence.ShellArg(command='deploy p1')
     self.setupStep(
         shellsequence.ShellSequence(commands=[arg1, arg2, arg3],
                                     workdir='build'))
     self.expectCommands(ExpectShell(workdir='build', command='make p1',
                                     usePTY="slave-config") + 0,
                         ExpectShell(workdir='build', command='deploy p1',
                                     usePTY="slave-config") + 0)
     self.expectOutcome(result=SUCCESS, state_string="'deploy p1'")
     return self.runStep()
예제 #7
0
 def testMultipleCommandsAreRun(self):
     arg1 = shellsequence.ShellArg(command='make p1')
     arg2 = shellsequence.ShellArg(command='deploy p1', logfile='deploy')
     self.setupStep(
         shellsequence.ShellSequence(commands=[arg1, arg2],
                                     workdir='build'))
     self.expectCommands(ExpectShell(workdir='build', command='make p1',
                                     usePTY="slave-config") + 0,
                         ExpectShell(workdir='build', command='deploy p1',
                                     usePTY="slave-config") + 0 +
                         Expect.log('stdio deploy p1'))
     self.expectOutcome(result=SUCCESS, state_string="'deploy p1'")
     return self.runStep()
예제 #8
0
    def testShellArgInput(self):
        with self.assertRaisesConfigError(
                "the 'command' parameter of ShellArg must not be None"):
            shellsequence.ShellArg(command=None)
        arg1 = shellsequence.ShellArg(command=1)
        with self.assertRaisesConfigError(
                "1 is an invalid command, it must be a string or a list"):
            arg1.validateAttributes()
        arg2 = shellsequence.ShellArg(command=["make", 1])
        with self.assertRaisesConfigError(
                "['make', 1] must only have strings in it"):
            arg2.validateAttributes()

        for goodcmd in ["make p1", ["make", "p1"]]:
            arg = shellsequence.ShellArg(command=goodcmd)
            arg.validateAttributes()
예제 #9
0
    def testShellArgsAreRenderedAnewAtEachBuild(self):
        """Unit test to ensure that ShellArg instances are properly re-rendered.

        This unit test makes sure that ShellArg instances are rendered anew at
        each new build.
        """
        arg = shellsequence.ShellArg(
            command=WithProperties('make %s', 'project'),
            logfile=WithProperties('make %s', 'project'))
        step = shellsequence.ShellSequence(commands=[arg], workdir='build')

        # First "build"
        self.setupStep(step)
        self.properties.setProperty("project", "BUILDBOT-TEST-1", "TEST")
        self.expectCommands(
            ExpectShell(workdir='build', command='make BUILDBOT-TEST-1') + 0 +
            Expect.log('stdio make BUILDBOT-TEST-1'))
        self.expectOutcome(result=SUCCESS,
                           state_string="'make BUILDBOT-TEST-1'")
        self.runStep()

        # Second "build"
        self.setupStep(step)
        self.properties.setProperty("project", "BUILDBOT-TEST-2", "TEST")
        self.expectCommands(
            ExpectShell(workdir='build', command='make BUILDBOT-TEST-2') + 0 +
            Expect.log('stdio make BUILDBOT-TEST-2'))
        self.expectOutcome(result=SUCCESS,
                           state_string="'make BUILDBOT-TEST-2'")

        return self.runStep()
예제 #10
0
 def test_shell_arg_error_logfile_and_logname(self):
     with assertProducesWarnings(
             DeprecatedApiWarning,
             message_pattern="logfile is deprecated, use logname"):
         with self.assertRaisesConfigError(
                 "the 'logfile' parameter must not be specified when 'logname' is set"
         ):
             shellsequence.ShellArg(command="command",
                                    logname="logname",
                                    logfile="logfile")
예제 #11
0
 def testShellArgsAreRendered(self):
     arg1 = shellsequence.ShellArg(
         command=WithProperties('make %s', 'project'))
     self.setupStep(
         shellsequence.ShellSequence(commands=[arg1], workdir='build'))
     self.properties.setProperty("project", "BUILDBOT-TEST", "TEST")
     self.expectCommands(
         ExpectShell(workdir='build', command='make BUILDBOT-TEST') + 0)
     # TODO: need to factor command-summary stuff into a utility method and
     # use it here
     self.expectOutcome(result=SUCCESS, state_string="'make BUILDBOT-TEST'")
     return self.runStep()
예제 #12
0
 def testShellArgsAreRendered(self):
     arg1 = shellsequence.ShellArg(
         command=WithProperties('make %s', 'project'),
         logfile=WithProperties('make %s', 'project'))
     self.setupStep(
         shellsequence.ShellSequence(commands=[arg1], workdir='build'))
     self.properties.setProperty("project", "BUILDBOT-TEST", "TEST")
     self.expectCommands(
         ExpectShell(workdir='build',
                     command='make BUILDBOT-TEST',
                     usePTY="slave-config") + 0 +
         Expect.log('stdio make BUILDBOT-TEST'))
     self.expectOutcome(result=SUCCESS,
                        status_text=["'make", "BUILDBOT-TEST'"])
     return self.runStep()
예제 #13
0
 def testSanityChecksAreDoneInRuntimeWhenDynamicCmdIsInvalidShellArg(self):
     self.setupStep(
         self.createDynamicRun([shellsequence.ShellArg(command=1)]))
     self.expectOutcome(result=EXCEPTION,
                        state_string='finished (exception)')
     return self.runStep()
예제 #14
0
 def test_shell_arg_warn_deprecated_logfile(self):
     with assertProducesWarnings(
             DeprecatedApiWarning,
             message_pattern="logfile is deprecated, use logname"):
         shellsequence.ShellArg(command="command", logfile="logfile")
예제 #15
0
 def testSanityChecksAreDoneInRuntimeWhenDynamicCmdIsInvalidShellArg(self):
     self.setupStep(
         self.createDynamicRun([shellsequence.ShellArg(command=1)]))
     self.expectOutcome(result=EXCEPTION,
                        status_text=[1, 'invalid', 'params'])
     return self.runStep()