diff options
Diffstat (limited to 'bootstrap')
l--------- | bootstrap/brillo | 1 | ||||
-rw-r--r-- | bootstrap/scripts/brillo.py | 59 | ||||
l--------- | bootstrap/scripts/brillo_unittest | 1 | ||||
-rw-r--r-- | bootstrap/scripts/brillo_unittest.py | 176 |
4 files changed, 0 insertions, 237 deletions
diff --git a/bootstrap/brillo b/bootstrap/brillo deleted file mode 120000 index 72196ceea..000000000 --- a/bootstrap/brillo +++ /dev/null @@ -1 +0,0 @@ -../scripts/wrapper.py
\ No newline at end of file diff --git a/bootstrap/scripts/brillo.py b/bootstrap/scripts/brillo.py deleted file mode 100644 index 1841a4771..000000000 --- a/bootstrap/scripts/brillo.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2015 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Bootstrap wrapper for 'brillo' command. - -For most commands of the form "brillo XYZ", we reinvoke -REPO_DIR/chromite/bin/brillo XYZ, after detecting REPO_DIR based on the CWD. - -For the "brillo sdk" command, we reinvoke "../bin/brillo sdk" from the current -git repository. This allows the SDK command to be run, even if there is no repo -checkout. -""" - -from __future__ import print_function - -import os - -from chromite.lib import bootstrap_lib -from chromite.lib import cros_build_lib -from chromite.lib import git -from chromite.lib import workspace_lib - - -def LocateBrilloCommand(args): - bootstrap_path = bootstrap_lib.FindBootstrapPath(save_to_env=True) - - if len(args) >= 1 and args[0] == 'sdk': - if not bootstrap_path: - cros_build_lib.Die( - 'You are bootstrapping chromite from a repo checkout.\n' - 'You must use a git clone. (brbug.com/580: link docs)') - - # Run 'brillo sdk' from the repository containing this command. - return os.path.join(bootstrap_path, 'bin', 'brillo') - - # If we are in a workspace, and the workspace has an associated SDK, use it. - workspace_path = workspace_lib.WorkspacePath() - if workspace_path: - sdk_path = bootstrap_lib.GetActiveSdkPath(bootstrap_path, workspace_path) - if not sdk_path: - cros_build_lib.Die( - 'The current workspace has no valid SDK.\n' - 'Please run "brillo sdk --update" (brbug.com/580: link docs)') - - # Use SDK associated with workspace, or nothing. - return os.path.join(sdk_path, 'chromite', 'bin', 'brillo') - - # Run all other commands from 'brillo' wrapper in repo detected via CWD. - repo_path = git.FindRepoCheckoutRoot(os.getcwd()) - if repo_path: - return os.path.join(repo_path, 'chromite', 'bin', 'brillo') - - # Couldn't find the real brillo command to run. - cros_build_lib.Die('Unable to detect which SDK you want to use.') - -def main(args): - bin_cmd = LocateBrilloCommand(args) - os.execv(bin_cmd, [bin_cmd] + args) diff --git a/bootstrap/scripts/brillo_unittest b/bootstrap/scripts/brillo_unittest deleted file mode 120000 index ef3e37b67..000000000 --- a/bootstrap/scripts/brillo_unittest +++ /dev/null @@ -1 +0,0 @@ -../../scripts/wrapper.py
\ No newline at end of file diff --git a/bootstrap/scripts/brillo_unittest.py b/bootstrap/scripts/brillo_unittest.py deleted file mode 100644 index c4c522672..000000000 --- a/bootstrap/scripts/brillo_unittest.py +++ /dev/null @@ -1,176 +0,0 @@ -# Copyright 2015 The Chromium OS Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""Test the bootstrap brillo command.""" - -from __future__ import print_function - -import mock -import os - -from chromite.lib import cros_build_lib -from chromite.lib import cros_test_lib -from chromite.lib import git - -from chromite.bootstrap.scripts import brillo - - -class TestBootstrapBrilloCmd(cros_test_lib.WorkspaceTestCase): - """Tests for the bootstrap brillo command.""" - - def setUp(self): - # Make certain we never exec anything. - self.mock_exec = self.PatchObject(os, 'execv', autospec=True) - - self.mock_repo_root = self.PatchObject( - git, 'FindRepoCheckoutRoot', autospec=True) - - def _verifyLocateBrilloCommand(self, expected): - self.assertEqual(expected, - brillo.LocateBrilloCommand(['flash'])) - self.assertEqual(expected, - brillo.LocateBrilloCommand(['flash', '--help'])) - - def _verifyLocateBrilloCommandSdkHandling(self, expected): - self.assertEqual(expected, - brillo.LocateBrilloCommand(['sdk'])) - self.assertEqual(expected, - brillo.LocateBrilloCommand(['sdk', '--help'])) - - def _verifyLocateBrilloCommandFail(self): - with self.assertRaises(cros_build_lib.DieSystemExit): - brillo.LocateBrilloCommand(['flash']) - - def _verifyLocateBrilloCommandSdkFail(self): - with self.assertRaises(cros_build_lib.DieSystemExit): - brillo.LocateBrilloCommand(['sdk']) - - def testCommandLookupActiveWorkspace(self): - """Test that sdk commands are run in the Git Repository.""" - self.CreateBootstrap('1.2.3') - self.CreateWorkspace('1.2.3') - - sdk_wrapper = os.path.join( - self.bootstrap_path, 'sdk_checkouts/1.2.3/chromite/bin/brillo') - bootstrap_wrapper = os.path.join(self.bootstrap_path, 'bin/brillo') - - # We are not inside a repo. - self.mock_repo_root.return_value = None - - self._verifyLocateBrilloCommand(sdk_wrapper) - self._verifyLocateBrilloCommandSdkHandling(bootstrap_wrapper) - - # We are inside a repo, shouldn't affect the result. - self.mock_repo_root.return_value = '/repo' - - self._verifyLocateBrilloCommand(sdk_wrapper) - self._verifyLocateBrilloCommandSdkHandling(bootstrap_wrapper) - - def testCommandLookupInactiveWorkspace(self): - """Test that sdk commands are run in the Git Repository.""" - self.CreateBootstrap() - self.CreateWorkspace() - self.mock_repo_root.return_value = None - - bootstrap_wrapper = os.path.join(self.bootstrap_path, 'bin/brillo') - - self._verifyLocateBrilloCommandFail() - self._verifyLocateBrilloCommandSdkHandling(bootstrap_wrapper) - - # Having a repo root shouldn't affect the result. - self.mock_repo_root.return_value = '/repo' - - self._verifyLocateBrilloCommandFail() - self._verifyLocateBrilloCommandSdkHandling(bootstrap_wrapper) - - def testCommandLookupRepoFromBootstrap(self): - """Test that sdk commands are run in the Git Repository.""" - self.CreateBootstrap('1.2.3') - self.CreateWorkspace() - self.mock_workspace_path.return_value = None - self.mock_repo_root.return_value = '/repo' - - bootstrap_wrapper = os.path.join(self.bootstrap_path, 'bin/brillo') - repo_wrapper = '/repo/chromite/bin/brillo' - - self._verifyLocateBrilloCommand(repo_wrapper) - self._verifyLocateBrilloCommandSdkHandling(bootstrap_wrapper) - - def testCommandLookupBootstrapOnly(self): - """Test that sdk commands are run in the Git Repository.""" - self.CreateBootstrap('1.2.3') - self.CreateWorkspace() - self.mock_workspace_path.return_value = None - self.mock_repo_root.return_value = None - - bootstrap_wrapper = os.path.join(self.bootstrap_path, 'bin/brillo') - - self._verifyLocateBrilloCommandFail() - self._verifyLocateBrilloCommandSdkHandling(bootstrap_wrapper) - - def testCommandLookupRepoOnly(self): - """Test that sdk commands are run in the Git Repository.""" - self.CreateBootstrap('1.2.3') - self.CreateWorkspace() - self.mock_bootstrap_path.return_value = None - self.mock_workspace_path.return_value = None - self.mock_repo_root.return_value = '/repo' - - repo_wrapper = '/repo/chromite/bin/brillo' - - self._verifyLocateBrilloCommand(repo_wrapper) - self._verifyLocateBrilloCommandSdkFail() - - def testMainInActiveWorkspace(self): - self.CreateBootstrap('1.2.3') - self.CreateWorkspace('1.2.3') - self.mock_repo_root.return_value = None - - brillo.main(['flash', '--help']) - - expected_cmd = os.path.join( - self.bootstrap_path, 'sdk_checkouts/1.2.3/chromite/bin/brillo') - - self.assertEqual( - [mock.call(expected_cmd, [expected_cmd, 'flash', '--help'])], - self.mock_exec.call_args_list) - - def testMainInRepo(self): - self.CreateBootstrap('1.2.3') - self.CreateWorkspace('1.2.3') - self.mock_workspace_path.return_value = None - self.mock_repo_root.return_value = '/repo' - - brillo.main(['flash', '--help']) - - expected_cmd = '/repo/chromite/bin/brillo' - - self.assertEqual( - [mock.call(expected_cmd, [expected_cmd, 'flash', '--help'])], - self.mock_exec.call_args_list) - - def testMainNoCmd(self): - self.CreateBootstrap('1.2.3') - self.CreateWorkspace('1.2.3') - self.mock_workspace_path.return_value = None - self.mock_repo_root.return_value = None - - with self.assertRaises(cros_build_lib.DieSystemExit): - brillo.main(['flash', '--help']) - - self.assertEqual([], self.mock_exec.call_args_list) - - def testMainSdkCmd(self): - self.CreateBootstrap('1.2.3') - self.CreateWorkspace('1.2.3') - self.mock_workspace_path.return_value = None - self.mock_repo_root.return_value = None - - brillo.main(['sdk', '--help']) - - expected_cmd = os.path.join(self.bootstrap_path, 'bin/brillo') - - self.assertEqual( - [mock.call(expected_cmd, [expected_cmd, 'sdk', '--help'])], - self.mock_exec.call_args_list) |