blob: ed368813b4993295df540e5a75e39c1c518f27aa [file] [log] [blame]
Gaurav Shah298aa372014-01-31 09:27:24 -08001# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""Unit tests for the cbuildbot program"""
6
Mike Frysinger383367e2014-09-16 15:06:17 -04007from __future__ import print_function
8
Don Garrett88b8d782014-05-13 17:30:55 -07009from chromite.cbuildbot import constants
Gaurav Shah298aa372014-01-31 09:27:24 -080010from chromite.lib import cros_test_lib
11from chromite.scripts import cbuildbot
12
13
14class IsDistributedBuilderTest(cros_test_lib.TestCase):
15 """Test for cbuildbot._IsDistributedBuilder."""
16
17 # pylint: disable=W0212
18 def testIsDistributedBuilder(self):
19 """Tests for _IsDistributedBuilder() under various configurations."""
20 parser = cbuildbot._CreateParser()
21 argv = ['x86-generic-paladin']
Don Garrett0a873e02015-06-30 17:55:10 -070022 (options, _) = cbuildbot._ParseCommandLine(parser, argv)
Gaurav Shah298aa372014-01-31 09:27:24 -080023 options.buildbot = False
24 options.pre_cq = False
25
26 build_config = dict(pre_cq=False,
27 manifest_version=False)
28 chrome_rev = None
29
30 def _TestConfig(expected):
31 self.assertEquals(expected,
32 cbuildbot._IsDistributedBuilder(
33 options=options,
34 chrome_rev=chrome_rev,
35 build_config=build_config))
36
37 # Default options.
38 _TestConfig(False)
39
40 # In Pre-CQ mode, we run as as a distributed builder.
41 options.pre_cq = True
42 _TestConfig(True)
43
44 options.pre_cq = False
45 build_config['pre_cq'] = True
46 _TestConfig(True)
47
48 build_config['pre_cq'] = False
49 build_config['manifest_version'] = True
50 # Not running in buildbot mode even though manifest_version=True.
51 _TestConfig(False)
52 options.buildbot = True
53 _TestConfig(True)
54
55 for chrome_rev in (constants.CHROME_REV_TOT,
56 constants.CHROME_REV_LOCAL,
57 constants.CHROME_REV_SPEC):
58 _TestConfig(False)