"Fossies" - the Fresh Open Source Software Archive

Member "buildbot-2.5.1/buildbot/test/unit/test_steps_source_gerrit.py" (24 Nov 2019, 9279 Bytes) of package /linux/misc/buildbot-2.5.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "test_steps_source_gerrit.py": 2.4.1_vs_2.5.0.

    1 # This file is part of Buildbot.  Buildbot is free software: you can
    2 # redistribute it and/or modify it under the terms of the GNU General Public
    3 # License as published by the Free Software Foundation, version 2.
    4 #
    5 # This program is distributed in the hope that it will be useful, but WITHOUT
    6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    7 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    8 # details.
    9 #
   10 # You should have received a copy of the GNU General Public License along with
   11 # this program; if not, write to the Free Software Foundation, Inc., 51
   12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   13 #
   14 # Copyright Buildbot Team Members
   15 
   16 from twisted.trial import unittest
   17 
   18 from buildbot.process.results import SUCCESS
   19 from buildbot.steps.source import gerrit
   20 from buildbot.test.fake.remotecommand import Expect
   21 from buildbot.test.fake.remotecommand import ExpectShell
   22 from buildbot.test.util import config
   23 from buildbot.test.util import sourcesteps
   24 from buildbot.test.util.misc import TestReactorMixin
   25 
   26 
   27 class TestGerrit(sourcesteps.SourceStepMixin, config.ConfigErrorsMixin,
   28                  TestReactorMixin, unittest.TestCase):
   29 
   30     def setUp(self):
   31         self.setUpTestReactor()
   32         return self.setUpSourceStep()
   33 
   34     def tearDown(self):
   35         return self.tearDownSourceStep()
   36 
   37     def test_mode_full_clean(self):
   38         self.setupStep(
   39             gerrit.Gerrit(repourl='http://github.com/buildbot/buildbot.git',
   40                           mode='full', method='clean'))
   41         self.build.setProperty("event.change.project", "buildbot")
   42         self.sourcestamp.project = 'buildbot'
   43         self.build.setProperty("event.patchSet.ref", "gerrit_branch")
   44 
   45         self.expectCommands(
   46             ExpectShell(workdir='wkdir',
   47                         command=['git', '--version'])
   48             + ExpectShell.log('stdio',
   49                               stdout='git version 1.7.5')
   50             + 0,
   51             Expect('stat', dict(file='wkdir/.buildbot-patched',
   52                                 logEnviron=True))
   53             + 1,
   54             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
   55                                'timeout': 1200})
   56             + Expect.update('files', ['.git'])
   57             + 0,
   58             ExpectShell(workdir='wkdir',
   59                         command=['git', 'clean', '-f', '-f', '-d'])
   60             + 0,
   61             ExpectShell(workdir='wkdir',
   62                         command=['git', 'fetch', '-t',
   63                                  'http://github.com/buildbot/buildbot.git',
   64                                  'gerrit_branch', '--progress'])
   65             + 0,
   66             ExpectShell(workdir='wkdir',
   67                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
   68             + 0,
   69             ExpectShell(workdir='wkdir',
   70                         command=['git', 'checkout', '-B', 'gerrit_branch'])
   71             + 0,
   72             ExpectShell(workdir='wkdir',
   73                         command=['git', 'rev-parse', 'HEAD'])
   74             + ExpectShell.log('stdio',
   75                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
   76             + 0,
   77         )
   78         self.expectOutcome(result=SUCCESS)
   79         self.expectProperty(
   80             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', 'Gerrit')
   81         return self.runStep()
   82 
   83     def test_mode_full_clean_force_build(self):
   84         self.setupStep(
   85             gerrit.Gerrit(repourl='http://github.com/buildbot/buildbot.git',
   86                           mode='full', method='clean'))
   87         self.build.setProperty("event.change.project", "buildbot")
   88         self.sourcestamp.project = 'buildbot'
   89         self.build.setProperty("gerrit_change", "1234/567")
   90 
   91         self.expectCommands(
   92             ExpectShell(workdir='wkdir',
   93                         command=['git', '--version'])
   94             + ExpectShell.log('stdio',
   95                               stdout='git version 1.7.5')
   96             + 0,
   97             Expect('stat', dict(file='wkdir/.buildbot-patched',
   98                                 logEnviron=True))
   99             + 1,
  100             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  101                                'timeout': 1200})
  102             + Expect.update('files', ['.git'])
  103             + 0,
  104             ExpectShell(workdir='wkdir',
  105                         command=['git', 'clean', '-f', '-f', '-d'])
  106             + 0,
  107             ExpectShell(workdir='wkdir',
  108                         command=['git', 'fetch', '-t',
  109                                  'http://github.com/buildbot/buildbot.git',
  110                                  'refs/changes/34/1234/567', '--progress'])
  111             + 0,
  112             ExpectShell(workdir='wkdir',
  113                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  114             + 0,
  115             ExpectShell(workdir='wkdir',
  116                         command=['git', 'checkout', '-B', 'refs/changes/34/1234/567'])
  117             + 0,
  118             ExpectShell(workdir='wkdir',
  119                         command=['git', 'rev-parse', 'HEAD'])
  120             + ExpectShell.log('stdio',
  121                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  122             + 0,
  123         )
  124         self.expectOutcome(result=SUCCESS)
  125         self.expectProperty(
  126             'got_revision', 'f6ad368298bd941e934a41f3babc827b2aa95a1d', 'Gerrit')
  127         return self.runStep()
  128 
  129     def test_mode_full_clean_force_same_project(self):
  130         self.setupStep(
  131             gerrit.Gerrit(repourl='http://github.com/buildbot/buildbot.git',
  132                           mode='full', method='clean', codebase='buildbot'))
  133         self.build.setProperty("event.change.project", "buildbot")
  134         self.sourcestamp.project = 'buildbot'
  135         self.build.setProperty("gerrit_change", "1234/567")
  136 
  137         self.expectCommands(
  138             ExpectShell(workdir='wkdir',
  139                         command=['git', '--version'])
  140             + ExpectShell.log('stdio',
  141                               stdout='git version 1.7.5')
  142             + 0,
  143             Expect('stat', dict(file='wkdir/.buildbot-patched',
  144                                 logEnviron=True))
  145             + 1,
  146             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  147                                'timeout': 1200})
  148             + Expect.update('files', ['.git'])
  149             + 0,
  150             ExpectShell(workdir='wkdir',
  151                         command=['git', 'clean', '-f', '-f', '-d'])
  152             + 0,
  153             ExpectShell(workdir='wkdir',
  154                         command=['git', 'fetch', '-t',
  155                                  'http://github.com/buildbot/buildbot.git',
  156                                  'refs/changes/34/1234/567', '--progress'])
  157             + 0,
  158             ExpectShell(workdir='wkdir',
  159                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  160             + 0,
  161             ExpectShell(workdir='wkdir',
  162                         command=['git', 'checkout', '-B', 'refs/changes/34/1234/567'])
  163             + 0,
  164             ExpectShell(workdir='wkdir',
  165                         command=['git', 'rev-parse', 'HEAD'])
  166             + ExpectShell.log('stdio',
  167                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  168             + 0,
  169         )
  170         self.expectOutcome(result=SUCCESS)
  171         self.expectProperty(
  172             'got_revision', {'buildbot': 'f6ad368298bd941e934a41f3babc827b2aa95a1d'}, 'Gerrit')
  173         return self.runStep()
  174 
  175     def test_mode_full_clean_different_project(self):
  176         self.setupStep(
  177             gerrit.Gerrit(repourl='http://github.com/buildbot/buildbot.git',
  178                           mode='full', method='clean', codebase='buildbot'))
  179         self.build.setProperty("event.change.project", "buildbot")
  180         self.sourcestamp.project = 'not_buildbot'
  181         self.build.setProperty("gerrit_change", "1234/567")
  182 
  183         self.expectCommands(
  184             ExpectShell(workdir='wkdir',
  185                         command=['git', '--version'])
  186             + ExpectShell.log('stdio',
  187                               stdout='git version 1.7.5')
  188             + 0,
  189             Expect('stat', dict(file='wkdir/.buildbot-patched',
  190                                 logEnviron=True))
  191             + 1,
  192             Expect('listdir', {'dir': 'wkdir', 'logEnviron': True,
  193                                'timeout': 1200})
  194             + Expect.update('files', ['.git'])
  195             + 0,
  196             ExpectShell(workdir='wkdir',
  197                         command=['git', 'clean', '-f', '-f', '-d'])
  198             + 0,
  199             ExpectShell(workdir='wkdir',
  200                         command=['git', 'fetch', '-t',
  201                                  'http://github.com/buildbot/buildbot.git',
  202                                  'HEAD', '--progress'])
  203             + 0,
  204             ExpectShell(workdir='wkdir',
  205                         command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
  206             + 0,
  207             ExpectShell(workdir='wkdir',
  208                         command=['git', 'rev-parse', 'HEAD'])
  209             + ExpectShell.log('stdio',
  210                               stdout='f6ad368298bd941e934a41f3babc827b2aa95a1d')
  211             + 0,
  212         )
  213         self.expectOutcome(result=SUCCESS)
  214         return self.runStep()