2 # Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Unit tests for the cbuildbot program"""
8 from __future__ import print_function
13 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(
14 os.path.abspath(__file__)))))
16 from chromite.cbuildbot import constants
17 from chromite.lib import cros_test_lib
18 from chromite.scripts import cbuildbot
21 class IsDistributedBuilderTest(cros_test_lib.TestCase):
22 """Test for cbuildbot._IsDistributedBuilder."""
24 # pylint: disable=W0212
25 def testIsDistributedBuilder(self):
26 """Tests for _IsDistributedBuilder() under various configurations."""
27 parser = cbuildbot._CreateParser()
28 argv = ['x86-generic-paladin']
29 (options, _) = cbuildbot._ParseCommandLine(parser, argv)
30 options.buildbot = False
31 options.pre_cq = False
33 build_config = dict(pre_cq=False,
34 manifest_version=False)
37 def _TestConfig(expected):
38 self.assertEquals(expected,
39 cbuildbot._IsDistributedBuilder(
41 chrome_rev=chrome_rev,
42 build_config=build_config))
47 # In Pre-CQ mode, we run as as a distributed builder.
51 options.pre_cq = False
52 build_config['pre_cq'] = True
55 build_config['pre_cq'] = False
56 build_config['manifest_version'] = True
57 # Not running in buildbot mode even though manifest_version=True.
59 options.buildbot = True
62 for chrome_rev in (constants.CHROME_REV_TOT,
63 constants.CHROME_REV_LOCAL,
64 constants.CHROME_REV_SPEC):
68 if __name__ == '__main__':