Пример #1
0
    def test_simple(self):
        self.patch_getCommand('cvs', 'path/to/cvs')
        self.clean_environ()
        self.make_command(
            cvs.CVS,
            dict(
                workdir='workdir',
                mode='copy',
                revision=None,
                cvsroot=':pserver:[email protected]:/cvsroot',
                cvsmodule='htdocs',
            ))

        expects = [
            Expect(['clobber', 'workdir'], self.basedir) + 0,
            Expect(['clobber', 'source'], self.basedir) + 0,
            Expect([
                'path/to/cvs', '-d',
                ':pserver:[email protected]:/cvsroot', '-z3',
                'checkout', '-d', 'source', 'htdocs'
            ],
                   self.basedir,
                   sendRC=False,
                   timeout=120,
                   usePTY=False) + 0,
            Expect(['copy', 'source', 'workdir'], self.basedir) + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(
            self.check_sourcedata,
            ":pserver:[email protected]:/cvsroot\nhtdocs\nNone\n")
        return d
Пример #2
0
    def test_run_mode_update_existing_known_rev(self):
        self.patch_getCommand('git', 'path/to/git')
        self.clean_environ()
        self.make_command(git.Git, dict(
            workdir='workdir',
            mode='update',
            revision='abcdef01',
            repourl='git://github.com/djmitche/buildbot.git',
          ),
            initial_sourcedata = "git://github.com/djmitche/buildbot.git master\n",
        )
        self.patch_sourcedirIsUpdateable(True)

        expects = [
            Expect(['path/to/git', 'reset', '--hard', 'abcdef01'],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'rev-parse', 'HEAD' ],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False, keepStdout=True)
                + { 'stdout' : '4026d33b0532b11f36b0875f63699adfa8ee8662\n' }
                + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(self.check_sourcedata, "git://github.com/djmitche/buildbot.git master\n")
        return d
Пример #3
0
    def test_run_mode_copy_nonexistant_ref(self):
        self.patch_getCommand('git', 'path/to/git')
        self.clean_environ()
        self.make_command(git.Git, dict(
            workdir='workdir',
            mode='copy',
            revision=None,
            branch='bogusref',
            repourl='git://github.com/djmitche/buildbot.git',
        ))
        self.patch_sourcedirIsUpdateable(True)

        expects = [
            Expect([ 'clobber', 'workdir' ],
                self.basedir)
                + 0,
            Expect([ 'path/to/git', 'clean', '-f', '-d', '-x'],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'fetch', '-t',
                     'git://github.com/djmitche/buildbot.git', '+bogusref' ],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False, keepStderr=True)
                + { 'stderr' : "fatal: Couldn't find remote ref bogusref\n" }
                + { 'rc': 128 }
                + 128,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        return d
Пример #4
0
    def test_run_with_submodules(self):
        self.patch_getCommand('git', 'path/to/git')
        self.clean_environ()
        self.make_command(git.Git, dict(
            workdir='workdir',
            mode='update',
            revision=None,
            submodules=True,
            repourl='git://github.com/djmitche/buildbot.git',
          ),
            initial_sourcedata = "git://github.com/djmitche/buildbot.git master\n",
        )
        self.patch_sourcedirIsUpdateable(False)

        expects = [
            Expect([ 'clobber', 'workdir' ],
                self.basedir)
                + 0,
            Expect([ 'path/to/git', 'init'],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'fetch', '-t',
                     'git://github.com/djmitche/buildbot.git', '+master' ],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False, keepStderr=True)
                + { 'stderr' : '' }
                + 0,
            Expect(['path/to/git', 'reset', '--hard', 'FETCH_HEAD'],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect(['path/to/git', 'branch', '-M', 'master'],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'submodule', 'init' ],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'submodule', 'update' ],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'submodule', 'foreach',
                                'git', 'clean', '-f', '-d', '-x'],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'rev-parse', 'HEAD' ],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False, keepStdout=True)
                + { 'stdout' : '4026d33b0532b11f36b0875f63699adfa8ee8662\n' }
                + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(self.check_sourcedata, "git://github.com/djmitche/buildbot.git master\n")
        return d
Пример #5
0
    def test_simple(self):
        self.patch_getCommand('bzr', 'path/to/bzr')
        self.clean_environ()
        self.make_command(
            bzr.Bzr,
            dict(
                workdir='workdir',
                mode='copy',
                revision='12',
                repourl='http://bazaar.launchpad.net/~bzr/bzr-gtk/trunk',
            ))

        exp_environ = dict(PWD='.', LC_MESSAGES='C')
        verinfo = textwrap.dedent("""\
            revision-id: [email protected]
            date: 2007-12-11 17:51:18 +0000
            build-date: 2007-12-13 13:14:51 +1000
            revno: 3104
            branch-nick: bzr.dev
        """)
        expects = [
            Expect(['clobber', 'workdir'], self.basedir) + 0,
            Expect(['clobber', 'source'], self.basedir) + 0,
            Expect([
                'path/to/bzr', 'checkout', '--revision', '12',
                'http://bazaar.launchpad.net/~bzr/bzr-gtk/trunk', 'source'
            ],
                   self.basedir,
                   sendRC=False,
                   timeout=120,
                   usePTY=False) + 0,
            Expect(['path/to/bzr', 'version-info'],
                   self.basedir_source,
                   sendRC=False,
                   usePTY=False,
                   keepStdout=True,
                   environ=exp_environ,
                   sendStderr=False,
                   sendStdout=False) + {
                       'stdout': verinfo
                   } + 0,
            Expect(['copy', 'source', 'workdir'], self.basedir) + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(self.check_sourcedata,
                      "http://bazaar.launchpad.net/~bzr/bzr-gtk/trunk\n")
        return d
Пример #6
0
    def test_db_needs_migrating(self):
        "Test a basic invocation with mode=copy and no existing sourcedir"
        self.patch_getCommand('mtn', 'path/to/mtn')
        self.clean_environ()
        self.make_command(mtn.Monotone, dict(
            workdir='workdir',
            mode='copy',
            revision=None,
            repourl=self.repourl,
            branch=self.branch
        ),
            # no sourcedata -> will do fresh checkout
            initial_sourcedata = None,
        )
        exp_environ = dict(PWD='.', LC_MESSAGES='C')
        expects = [
            Expect([ 'path/to/mtn', 'db', 'info',
                     '--db', os.path.join(self.basedir, 'db.mtn') ],
                   self.basedir,
                   keepStdout=True, sendRC=False, sendStderr=False,
                   usePTY=False, environ=exp_environ)
            + { 'stdout' : 'blah blah (migration needed)\n' }
            + 0,
            Expect([ 'path/to/mtn', 'db', 'migrate',
                     '--db', os.path.join(self.basedir, 'db.mtn') ],
                   self.basedir,
                   sendRC=False, usePTY=False,
                   environ=exp_environ) + 0,
            Expect([ 'clobber', 'workdir' ],
                   self.basedir) + 0,
            Expect([ 'clobber', 'source' ],
                   self.basedir) + 0,
            Expect(['path/to/mtn', 'pull', self.repourl+"?"+self.branch,
                     '--db', os.path.join(self.basedir, 'db.mtn'),
                     '--ticker=none'],
                   self.basedir,
                   keepStdout=True, sendRC=False, timeout=120, usePTY=False,
                   environ=exp_environ) + 0,
            Expect(['path/to/mtn', 'checkout', self.basedir_source,
                    '--db', os.path.join(self.basedir, 'db.mtn'),
                    '--branch', 'ca.monotone.sandbox.buildbot'],
                   self.basedir,
                   keepStdout=True, sendRC=False, timeout=120, usePTY=False,
                   environ=exp_environ) + 0,
            Expect(['path/to/mtn', 'automate', 'select', 'w:'],
                   self.basedir_source,
                   keepStdout=True, sendRC=False, timeout=120, usePTY=False)
                   + 0,
            Expect([ 'copy', 'source', 'workdir'],
                   self.basedir)
                   + 0,
            ]

        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(self.check_sourcedata, self.repourl+"?"+self.branch)
        return d
Пример #7
0
    def test_startCommand(self):
        # set up a fake step to receive updates
        st = FakeStep()

        # patch runprocess to handle the 'echo', below
        self.patch_runprocess(
            Expect([ 'echo', 'hello' ], os.path.join(self.basedir, 'sb', 'workdir'))
            + { 'hdr' : 'headers' } + { 'stdout' : 'hello\n' } + { 'rc' : 0 }
            + 0,
        )

        d = defer.succeed(None)
        def do_start(_):
            return self.sb.callRemote("startCommand", FakeRemote(st),
                                      "13", "shell", dict(
                                                command=[ 'echo', 'hello' ],
                                                workdir='workdir',
                                            ))
        d.addCallback(do_start)
        d.addCallback(lambda _ : st.wait_for_finish())
        def check(_):
            self.assertEqual(st.actions, [
                         ['update', [[{'hdr': 'headers'}, 0]]],
                         ['update', [[{'stdout': 'hello\n'}, 0]]],
                         ['update', [[{'rc': 0}, 0]]],
                         ['update', [[{'elapsed': 1}, 0]]],
                         ['complete', None],
                    ])
        d.addCallback(check)
        return d
Пример #8
0
    def test_db_too_new(self):
        "Test a basic invocation with mode=copy and no existing sourcedir"
        self.patch_getCommand('mtn', 'path/to/mtn')
        self.clean_environ()
        self.make_command(
            mtn.Monotone,
            dict(workdir='workdir',
                 mode='copy',
                 revision=None,
                 repourl=self.repourl,
                 branch=self.branch),
            # no sourcedata -> will do fresh checkout
            initial_sourcedata=None,
        )

        exp_environ = dict(PWD='.', LC_MESSAGES='C')
        expects = [
            Expect([
                'path/to/mtn', 'db', 'info', '--db',
                os.path.join(self.basedir, 'db.mtn')
            ],
                   self.basedir,
                   keepStdout=True,
                   sendRC=False,
                   sendStderr=False,
                   usePTY=False,
                   environ=exp_environ) + {
                       'stdout': 'blah blah (too new, cannot use)\n'
                   } + 0
        ]

        self.patch_runprocess(*expects)

        d = self.run_command()
        return self.assertFailure(d, mtn.MonotoneError)
Пример #9
0
    def test_startCommand_failure(self):
        # set up a fake step to receive updates
        st = FakeStep()

        # patch runprocess to generate a failure
        self.patch_runprocess(
            Expect(['sleep', '10'], os.path.join(self.basedir, 'sb',
                                                 'workdir')) +
            failure.Failure(Exception("Oops")))
        # patch the log.err, otherwise trial will think something *actually* failed
        self.patch(log, "err", lambda f: None)

        d = defer.succeed(None)

        def do_start(_):
            return self.sb.callRemote(
                "startCommand", FakeRemote(st), "13", "shell",
                dict(command=['sleep', '10'], workdir='workdir'))

        d.addCallback(do_start)
        d.addCallback(lambda _: st.wait_for_finish())

        def check(_):
            self.assertEqual(st.actions[1][0], 'complete')
            self.assertTrue(isinstance(st.actions[1][1], failure.Failure))

        d.addCallback(check)
        return d
Пример #10
0
    def test_simple(self):
        self.make_command(shell.SlaveShellCommand,
                          dict(
                              command=['echo', 'hello'],
                              workdir='workdir',
                          ))

        self.patch_runprocess(
            Expect(['echo', 'hello'], self.basedir_workdir) +
            {'hdr': 'headers'} + {'stdout': 'hello\n'} + {'rc': 0} + 0, )

        d = self.run_command()

        # note that SlaveShellCommand does not add any extra updates of it own
        def check(_):
            self.assertUpdates([{
                'hdr': 'headers'
            }, {
                'stdout': 'hello\n'
            }, {
                'rc': 0
            }], self.builder.show())

        d.addCallback(check)
        return d
Пример #11
0
    def test_user_parameter(self):
        """
        Test that the 'user' parameter is threaded through into the
        underlying RunProcess object.
        """

        user = '******'
        self.make_command(
            shell.SlaveShellCommand,
            dict(
                command=['true'],
                workdir='workdir',
                user=user,
            ))

        self.patch_runprocess(
            Expect([
                'true',
            ], self.basedir_workdir, user=user) + {'hdr': 'headers'} +
            {'rc': 0} + 0, )

        d = self.run_command()

        # Verify that the 'user' parameter is correctly passed into the
        # RunProcess object.
        def check(_):
            self.assertTrue(hasattr(self.cmd.command, 'user'))
            self.assertEqual(self.cmd.command.user, user)

        d.addCallback(check)
        return d
Пример #12
0
    def test_update_existing(self):
        self.patch_getCommand('hg', 'path/to/hg')
        self.clean_environ()
        self.make_command(hg.Mercurial, dict(
            workdir='workdir',
            mode='update',
            revision=None,
            repourl='http://bitbucket.org/nicolas17/pyboinc',
        ),
            initial_sourcedata = "http://bitbucket.org/nicolas17/pyboinc\n",
        )
        self.patch_sourcedirIsUpdateable(True)

        exp_environ = dict(PWD='.', LC_MESSAGES='C')
        expects = [
            Expect(['path/to/hg', 'pull', '--verbose', 'http://bitbucket.org/nicolas17/pyboinc'],
                self.basedir_workdir,
                sendRC=False, timeout=120, keepStdout=True, usePTY=False)
                + 0,
            Expect(['path/to/hg', 'identify', '--num', '--branch'],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False, keepStdout=True,
                keepStderr=True)
                + { 'stdout' : '-1 default\n' }
                + 0,
            Expect(['path/to/hg', 'paths', 'default'],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False, keepStdout=True,
                keepStderr=True)
                + { 'stdout' : 'http://bitbucket.org/nicolas17/pyboinc\n' }
                + 0,
            Expect(['path/to/hg', 'update', '--clean', '--repository',
                    'workdir', '--rev', 'default'],
                self.basedir,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect(['path/to/hg', 'parents', '--template', '{node}\\n'],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False, environ=exp_environ,
                keepStdout=True)
                + { 'stdout' : 'b7ddc0b638fa11cdac7c0345c40c6f76d8a7166d' }
                + 0,
        ]
        self.patch_runprocess(*expects)
        d = self.run_command()
        d.addCallback(self.check_sourcedata, "http://bitbucket.org/nicolas17/pyboinc\n")
        return d
Пример #13
0
    def test_run_mode_update_fresh(self):
        self.patch_getCommand('mtn', 'path/to/mtn')
        self.clean_environ()
        self.make_command(mtn.Monotone, dict(
            workdir='workdir',
            mode='update',
            revision=None,
            repourl=self.repourl,
            branch=self.branch,
            progress=True, # added here for better coverage
        ),
            initial_sourcedata = self.repourl+"?"+self.branch
        )
        self.patch_sourcedirIsUpdateable(False)

        exp_environ = dict(PWD='.', LC_MESSAGES='C')
        expects = [
            Expect([ 'path/to/mtn', 'db', 'info',
                     '--db', os.path.join(self.basedir, 'db.mtn')],
                   self.basedir,
                   keepStdout=True, sendRC=False, sendStderr=False,
                   usePTY=False, environ=exp_environ) + 0,
            Expect([ 'clobber', 'workdir' ],
                   self.basedir) + 0,
            Expect([ 'path/to/mtn', 'pull', self.repourl+"?"+self.branch,
                     '--db', os.path.join(self.basedir, 'db.mtn'),
                     '--ticker=dot'],
                   self.basedir,
                   keepStdout=True, sendRC=False, timeout=120, usePTY=False,
                   environ=exp_environ) + 0,
            Expect(['path/to/mtn', 'checkout', self.basedir_workdir,
                    '--db', os.path.join(self.basedir, 'db.mtn'),
                    '--branch', 'ca.monotone.sandbox.buildbot'],
                   self.basedir,
                   keepStdout=True, sendRC=False, timeout=120, usePTY=False,
                   environ=exp_environ) + 0,
            Expect(['path/to/mtn', 'automate', 'select', 'w:'],
                   self.basedir_workdir,
                   keepStdout=True, sendRC=False, timeout=120, usePTY=False)
                   + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(self.check_sourcedata, self.repourl+"?"+self.branch)
        return d
Пример #14
0
    def test_simple(self):
        self.patch_getCommand('svn', 'path/to/svn')
        self.patch_getCommand('svnversion', 'path/to/svnversion')
        self.clean_environ()
        self.make_command(
            svn.SVN,
            dict(
                workdir='workdir',
                mode='copy',
                revision=None,
                svnurl='http://svn.local/app/trunk',
            ))

        exp_environ = dict(PWD='.', LC_MESSAGES='C')
        expects = [
            Expect(['clobber', 'workdir'], self.basedir) + 0,
            Expect(['clobber', 'source'], self.basedir) + 0,
            Expect([
                'path/to/svn', 'checkout', '--non-interactive',
                '--no-auth-cache', '--revision', 'HEAD',
                'http://svn.local/app/trunk@HEAD', 'source'
            ],
                   self.basedir,
                   sendRC=False,
                   timeout=120,
                   usePTY=False,
                   environ=exp_environ) + 0,
            Expect(['path/to/svnversion', '.'],
                   self.basedir_source,
                   sendRC=False,
                   timeout=120,
                   usePTY=False,
                   keepStdout=True,
                   environ=exp_environ,
                   sendStderr=False,
                   sendStdout=False) + {
                       'stdout': '9753\n'
                   } + 0,
            Expect(['copy', 'source', 'workdir'], self.basedir) + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(self.check_sourcedata, "http://svn.local/app/trunk\n")
        return d
Пример #15
0
    def test_run_mode_copy_fresh_sourcedir(self):
        "Test a basic invocation with mode=copy and no existing sourcedir"
        self.patch_getCommand('git', 'path/to/git')
        self.clean_environ()
        self.make_command(git.Git, dict(
            workdir='workdir',
            mode='copy',
            revision=None,
            repourl='git://github.com/djmitche/buildbot.git',
        ),
            # no sourcedata -> will do fresh checkout
            initial_sourcedata = None,
        )

        expects = [
            Expect([ 'clobber', 'workdir' ],
                self.basedir)
                + 0,
            Expect([ 'clobber', 'source' ],
                self.basedir)
                + 0,
            # TODO: capture makedirs invocation here
            Expect([ 'path/to/git', 'init'],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'fetch', '-t',
                     'git://github.com/djmitche/buildbot.git', '+master' ],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False, keepStderr=True)
                + { 'stderr' : '' }
                + 0,
            Expect(['path/to/git', 'reset', '--hard', 'FETCH_HEAD'],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect(['path/to/git', 'branch', '-M', 'master'],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'rev-parse', 'HEAD' ],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False, keepStdout=True)
                + { 'stdout' : '4026d33b0532b11f36b0875f63699adfa8ee8662\n' }
                + 0,
            Expect([ 'copy', 'source', 'workdir'],
                self.basedir)
                + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(self.check_sourcedata, "git://github.com/djmitche/buildbot.git master\n")
        return d
Пример #16
0
    def test_run_mode_copy_gerrit_branch(self):
        self.patch_getCommand('git', 'path/to/git')
        self.clean_environ()
        self.make_command(
            git.Git,
            dict(
                workdir='workdir',
                mode='copy',
                revision=None,
                branch='local-branch',
                gerrit_branch='real-branch',
                repourl='git://github.com/djmitche/buildbot.git',
            ))
        self.patch_sourcedirIsUpdateable(True)

        expects = [
            Expect(['clobber', 'workdir'], self.basedir) + 0,
            Expect(['path/to/git', 'clean', '-f', '-d', '-x'],
                   self.basedir_source,
                   sendRC=False,
                   timeout=120,
                   usePTY=False) + 0,
            Expect([
                'path/to/git', 'fetch', '-t',
                'git://github.com/djmitche/buildbot.git', '+real-branch'
            ],
                   self.basedir_source,
                   sendRC=False,
                   timeout=120,
                   usePTY=False,
                   keepStderr=True) + {
                       'stderr': ''
                   } + 0,
            Expect(['path/to/git', 'reset', '--hard', 'FETCH_HEAD'],
                   self.basedir_source,
                   sendRC=False,
                   timeout=120,
                   usePTY=False) + 0,
            Expect(
                ['path/to/git', 'branch', '-M', 'local-branch'
                 ],  # note, not the same branch
                self.basedir_source,
                sendRC=False,
                timeout=120,
                usePTY=False) + 0,
            Expect(['path/to/git', 'rev-parse', 'HEAD'],
                   self.basedir_source,
                   sendRC=False,
                   timeout=120,
                   usePTY=False,
                   keepStdout=True) + {
                       'stdout': '4026d33b0532b11f36b0875f63699adfa8ee8662\n'
                   } + 0,
            Expect(['copy', 'source', 'workdir'], self.basedir) + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        return d
Пример #17
0
    def test_startCommand_interruptCommand(self):
        # set up a fake step to receive updates
        st = FakeStep()

        # patch runprocess to pretend to sleep (it will really just hang forever,
        # except that we interrupt it)
        self.patch_runprocess(
            Expect(['sleep', '10'], os.path.join(
                self.basedir, 'sb', 'workdir')) + {'hdr': 'headers'} +
            {'wait': True})

        d = defer.succeed(None)

        def do_start(_):
            return self.sb.callRemote(
                "startCommand", FakeRemote(st), "13", "shell",
                dict(
                    command=['sleep', '10'],
                    workdir='workdir',
                ))

        d.addCallback(do_start)

        # wait a jiffy..
        def do_wait(_):
            d = defer.Deferred()
            reactor.callLater(0.01, d.callback, None)
            return d

        d.addCallback(do_wait)

        # and then interrupt the step
        def do_interrupt(_):
            return self.sb.callRemote("interruptCommand", "13", "tl/dr")

        d.addCallback(do_interrupt)

        d.addCallback(lambda _: st.wait_for_finish())

        def check(_):
            self.assertEqual(st.actions, [
                ['update', [[{
                    'hdr': 'headers'
                }, 0]]],
                ['update', [[{
                    'hdr': 'killing'
                }, 0]]],
                ['update', [[{
                    'rc': -1
                }, 0]]],
                ['complete', None],
            ])

        d.addCallback(check)
        return d
Пример #18
0
    def test_run_with_shallow_and_reference(self):
        self.patch_getCommand('git', 'path/to/git')
        self.clean_environ()
        self.make_command(git.Git, dict(
            workdir='workdir',
            mode='update',
            revision=None,
            shallow=True,
            reference="/some/repo",
            repourl='git://github.com/djmitche/buildbot.git',
          ),
            initial_sourcedata = "git://github.com/djmitche/buildbot.git master\n",
        )
        self.patch_sourcedirIsUpdateable(False)

        expects = [
            Expect([ 'clobber', 'workdir' ],
                self.basedir)
                + 0,
            Expect(['path/to/git', 'clone', '--depth', '1',
                    '--reference', '/some/repo', # note: no ../objects
                    'git://github.com/djmitche/buildbot.git',
                    self.basedir_workdir],
                self.basedir,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'setFileContents',
                     os.path.join(self.basedir_workdir,
                                  *'.git/objects/info/alternates'.split('/')),
                     os.path.join('/some/repo', 'objects'), ],
                self.basedir)
                + 0,
            Expect([ 'path/to/git', 'fetch', '-t',
                     'git://github.com/djmitche/buildbot.git', '+master' ],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False, keepStderr=True)
                + { 'stderr' : '' }
                + 0,
            Expect(['path/to/git', 'reset', '--hard', 'FETCH_HEAD'],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect(['path/to/git', 'branch', '-M', 'master'],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'rev-parse', 'HEAD' ],
                self.basedir_workdir,
                sendRC=False, timeout=120, usePTY=False, keepStdout=True)
                + { 'stdout' : '4026d33b0532b11f36b0875f63699adfa8ee8662\n' }
                + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(self.check_sourcedata, "git://github.com/djmitche/buildbot.git master\n")
        return d
    def test_simple(self):
        self.patch_getCommand('darcs', 'path/to/darcs')
        self.clean_environ()
        self.make_command(
            darcs.Darcs,
            dict(
                workdir='workdir',
                mode='copy',
                revision=None,
                repourl='http://darcs.net',
            ))

        exp_environ = dict(PWD='.', LC_MESSAGES='C')
        expects = [
            Expect(['clobber', 'workdir'], self.basedir) + 0,
            Expect(['clobber', 'source'], self.basedir) + 0,
            Expect([
                'path/to/darcs', 'get', '--verbose', '--partial',
                '--repo-name', 'source', 'http://darcs.net'
            ],
                   self.basedir,
                   sendRC=False,
                   timeout=120,
                   usePTY=False) + 0,
            Expect(['path/to/darcs', 'changes', '--context'],
                   self.basedir_source,
                   sendRC=False,
                   timeout=120,
                   usePTY=False,
                   keepStdout=True,
                   environ=exp_environ,
                   sendStderr=False,
                   sendStdout=False) + {
                       'stdout': example_changes
                   } + 0,
            Expect(['copy', 'source', 'workdir'], self.basedir) + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(self.check_sourcedata, "http://darcs.net\n")
        return d
    def test_simple(self):
        self.patch_getCommand('bk', 'path/to/bk')
        self.clean_environ()
        self.make_command(bk.BK, dict(
            workdir='workdir',
            mode='copy',
            revision='1.114',
            bkurl='http://bkdemo.bkbits.net/bk_demo1',
        ))

        exp_environ = dict(PWD='.', LC_MESSAGES='C')
        expects = [
            Expect(['clobber', 'workdir'],
                   self.basedir)
            + 0,
            Expect(['clobber', 'source'],
                   self.basedir)
            + 0,
            Expect(['path/to/bk', 'clone', '-r1.114',
                    'http://bkdemo.bkbits.net/bk_demo1', 'source'],
                   self.basedir,
                   sendRC=False, timeout=120, usePTY=False)
            + 0,
            Expect(['path/to/bk', 'changes', '-r+', '-d:REV:'],
                   self.basedir_source,
                   sendRC=False, usePTY=False, timeout=120, sendStderr=False,
                   sendStdout=False, keepStdout=True, environ=exp_environ)
            + {'stdout': '1.114\n'}  # TODO: is this what BK outputs?
            + 0,
            Expect(['copy', 'source', 'workdir'],
                   self.basedir)
            + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
                # TODO: why the extra quotes?
        d.addCallback(self.check_sourcedata, '"http://bkdemo.bkbits.net/bk_demo1\n"')
        return d
Пример #21
0
    def test_run_mode_copy_update_sourcedir(self):
        """test a copy where the sourcedata indicates that the source directory
        can be updated"""
        self.patch_getCommand('git', 'path/to/git')
        self.clean_environ()
        self.make_command(
            git.Git,
            dict(
                workdir='workdir',
                mode='copy',
                revision=None,
                repourl='git://github.com/djmitche/buildbot.git',
                progress=True,  # added here for better coverage
            ),
            initial_sourcedata=
            "git://github.com/djmitche/buildbot.git master\n",
        )
        self.patch_sourcedirIsUpdateable(True)

        expects = [
            Expect(['clobber', 'workdir'], self.basedir) + 0,
            Expect([
                'path/to/git', 'fetch', '-t',
                'git://github.com/djmitche/buildbot.git', '+master',
                '--progress'
            ],
                   self.basedir_source,
                   sendRC=False,
                   timeout=120,
                   usePTY=False,
                   keepStderr=True) + {
                       'stderr': ''
                   } + 0,
            Expect(['path/to/git', 'reset', '--hard', 'FETCH_HEAD'],
                   self.basedir_source,
                   sendRC=False,
                   timeout=120,
                   usePTY=False) + 0,
            Expect(['path/to/git', 'branch', '-M', 'master'],
                   self.basedir_source,
                   sendRC=False,
                   timeout=120,
                   usePTY=False) + 0,
            Expect(['path/to/git', 'rev-parse', 'HEAD'],
                   self.basedir_source,
                   sendRC=False,
                   timeout=120,
                   usePTY=False,
                   keepStdout=True) + {
                       'stdout': '4026d33b0532b11f36b0875f63699adfa8ee8662\n'
                   } + 0,
            Expect(['copy', 'source', 'workdir'], self.basedir) + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(self.check_sourcedata,
                      "git://github.com/djmitche/buildbot.git master\n")
        return d
Пример #22
0
    def test_nonexistant_ref(self):
        self.patch_getCommand('git', 'path/to/git')
        self.clean_environ()
        self.make_command(git.Git, dict(
            workdir='workdir',
            mode='copy',
            revision=None,
            repourl='git://github.com/djmitche/buildbot.git',
        ))

        expects = [
            Expect([ 'clobber', 'workdir' ],
                self.basedir)
                + 0,
            Expect([ 'clobber', 'source' ],
                self.basedir)
                + 0,
            # TODO: capture makedirs invocation here
            Expect([ 'path/to/git', 'init'],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'clean', '-f', '-d', '-x'],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'fetch', '-t',
                     'git://github.com/djmitche/buildbot.git', '+master' ],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False, keepStderr=True)
                + { 'stderr' : "fatal: Couldn't find remote ref master\n" }
                + { 'rc': 128 }
                + 128,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        return d
Пример #23
0
    def test_copy_update_sourcedir(self):
        self.patch_getCommand('git', 'path/to/git')
        self.clean_environ()
        self.make_command(git.Git, dict(
            workdir='workdir',
            mode='copy',
            revision=None,
            repourl='git://github.com/djmitche/buildbot.git',
          ),
            initial_sourcedata = "git://github.com/djmitche/buildbot.git master\n",
        )

        # monkey-patch sourcedirIsUpdateable to think that it is updatable
        def sourcedirIsUpdateable():
            return True
        self.patch(self.cmd, "sourcedirIsUpdateable", sourcedirIsUpdateable)

        expects = [
            Expect([ 'clobber', 'workdir' ],
                self.basedir)
                + 0,
            Expect([ 'path/to/git', 'fetch', '-t',
                     'git://github.com/djmitche/buildbot.git', '+master' ],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False, keepStderr=True)
                + { 'stderr' : '' }
                + 0,
            Expect(['path/to/git', 'reset', '--hard', 'FETCH_HEAD'],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect(['path/to/git', 'branch', '-M', 'master'],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False)
                + 0,
            Expect([ 'path/to/git', 'rev-parse', 'HEAD' ],
                self.basedir_source,
                sendRC=False, timeout=120, usePTY=False, keepStdout=True)
                + { 'stdout' : '4026d33b0532b11f36b0875f63699adfa8ee8662\n' }
                + 0,
            Expect([ 'copy', 'source', 'workdir'],
                self.basedir)
                + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(self.check_sourcedata, "git://github.com/djmitche/buildbot.git master\n")
        return d
Пример #24
0
    def test_simple(self):
        self.patch_getCommand('p4', 'path/to/p4')
        self.clean_environ()
        self.make_command(
            p4.P4,
            dict(
                workdir='workdir',
                mode='copy',
                revision=None,
                p4port='p4dserv:1666',
                p4client='buildbot_test_10',
                p4user='******',
                p4passwd='hushnow',
                p4base='//mydepot/myproj/',
                branch='mytrunk',
                p4extra_views=[],
            ))

        exp_environ = dict(PWD='.', LC_MESSAGES='C')
        # can't use textwrap.dedent here, because in 2.4 it converts \t to 8x' '
        client_spec = """\
Client: buildbot_test_10

Owner: jimmy

Description:
\tCreated by jimmy

Root:\t%s

Options:\tallwrite rmdir

LineEnd:\tlocal

View:
\t//mydepot/myproj/mytrunk/... //buildbot_test_10/source/...
""" % self.basedir
        expects = [
            Expect(['clobber', 'workdir'], self.basedir) + 0,
            Expect(['clobber', 'source'], self.basedir) + 0,
            Expect(
                [
                    'p4', '-p', 'p4dserv:1666', '-u', 'jimmy', '-P',
                    Obfuscated('hushnow', 'XXXXXXXX'), 'client', '-i'
                ],
                self.basedir,
                # TODO: empty env?
                sendRC=False,
                timeout=120,
                usePTY=False,
                environ={},
                initialStdin=client_spec) + 0,
            Expect(
                [
                    'p4', '-p', 'p4dserv:1666', '-u', 'jimmy', '-P',
                    Obfuscated('hushnow', 'XXXXXXXX'), '-c',
                    'buildbot_test_10', 'sync', '-f'
                ],
                self.basedir,
                # TODO: empty env?
                sendRC=False,
                timeout=120,
                usePTY=False,
                environ={}) + 0,
            Expect([
                'p4', '-p', 'p4dserv:1666', '-u', 'jimmy', '-P',
                Obfuscated('hushnow', 'XXXXXXXX'), '-c', 'buildbot_test_10',
                'changes', '-s', 'submitted', '-m', '1', '#have'
            ],
                   self.basedir,
                   sendRC=False,
                   timeout=120,
                   usePTY=False,
                   environ=exp_environ,
                   keepStdout=True) +
            {
                'stdout': 'Change 28147 on 2008/04/07 by p4user@hostname\n'
            } + 0,
            Expect(['copy', 'source', 'workdir'], self.basedir) + 0,
        ]
        self.patch_runprocess(*expects)

        d = self.run_command()
        d.addCallback(
            self.check_sourcedata, "['p4dserv:1666', 'buildbot_test_10', " +
            "'//mydepot/myproj/', 'mytrunk', [], None, %s, 'copy', 'workdir']"
            % repr(self.basedir))
        return d