Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 1 | # 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 Frysinger | 383367e | 2014-09-16 15:06:17 -0400 | [diff] [blame] | 7 | from __future__ import print_function |
| 8 | |
Aviv Keshet | b7519e1 | 2016-10-04 00:50:00 -0700 | [diff] [blame] | 9 | from chromite.lib import constants |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 10 | from chromite.lib import cros_test_lib |
| 11 | from chromite.scripts import cbuildbot |
| 12 | |
| 13 | |
Don Garrett | b85658c | 2015-06-30 19:07:22 -0700 | [diff] [blame] | 14 | # pylint: disable=protected-access |
| 15 | |
| 16 | |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 17 | class IsDistributedBuilderTest(cros_test_lib.TestCase): |
| 18 | """Test for cbuildbot._IsDistributedBuilder.""" |
| 19 | |
| 20 | # pylint: disable=W0212 |
| 21 | def testIsDistributedBuilder(self): |
| 22 | """Tests for _IsDistributedBuilder() under various configurations.""" |
| 23 | parser = cbuildbot._CreateParser() |
Paul Hobbs | 7358a14 | 2017-07-26 16:09:36 -0700 | [diff] [blame] | 24 | argv = ['amd64-generic-paladin'] |
Mike Frysinger | 80bba8a | 2017-08-18 15:28:36 -0400 | [diff] [blame] | 25 | options = cbuildbot.ParseCommandLine(parser, argv) |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 26 | options.buildbot = False |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 27 | |
| 28 | build_config = dict(pre_cq=False, |
| 29 | manifest_version=False) |
| 30 | chrome_rev = None |
| 31 | |
| 32 | def _TestConfig(expected): |
| 33 | self.assertEquals(expected, |
| 34 | cbuildbot._IsDistributedBuilder( |
| 35 | options=options, |
| 36 | chrome_rev=chrome_rev, |
| 37 | build_config=build_config)) |
| 38 | |
| 39 | # Default options. |
| 40 | _TestConfig(False) |
| 41 | |
Gaurav Shah | 298aa37 | 2014-01-31 09:27:24 -0800 | [diff] [blame] | 42 | build_config['pre_cq'] = True |
| 43 | _TestConfig(True) |
| 44 | |
| 45 | build_config['pre_cq'] = False |
| 46 | build_config['manifest_version'] = True |
| 47 | # Not running in buildbot mode even though manifest_version=True. |
| 48 | _TestConfig(False) |
| 49 | options.buildbot = True |
| 50 | _TestConfig(True) |
| 51 | |
| 52 | for chrome_rev in (constants.CHROME_REV_TOT, |
| 53 | constants.CHROME_REV_LOCAL, |
| 54 | constants.CHROME_REV_SPEC): |
| 55 | _TestConfig(False) |