Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: lib/cros_build_lib_unittest.py

Issue 6575022: Revert "RunCommand was catching and rethrowing an exception, which seemed to generate" (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/cros_build_lib.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/cros_build_lib_unittest.py
diff --git a/lib/cros_build_lib_unittest.py b/lib/cros_build_lib_unittest.py
deleted file mode 100755
index a66424b8148c22f73b3a36f7f174bea7053b4002..0000000000000000000000000000000000000000
--- a/lib/cros_build_lib_unittest.py
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright (c) 2011 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.
-
-"""Unit tests for cros_build_lib."""
-
-import unittest
-
-import cros_build_lib
-
-class CrosBuildLibTest(unittest.TestCase):
- """Test class for cros_build_lib."""
-
- def testRunCommandSimple(self):
- """Test that RunCommand can run a simple successful command."""
- result = cros_build_lib.RunCommand(['ls'],
- # Keep the test quiet options
- print_cmd=False,
- redirect_stdout=True,
- redirect_stderr=True,
- # Test specific options
- exit_code=True)
- self.assertEqual(result, 0)
-
- def testRunCommandError(self):
- """Test that RunCommand can return an error code for a failed command."""
- result = cros_build_lib.RunCommand(['ls', '/nosuchdir'],
- # Keep the test quiet options
- print_cmd=False,
- redirect_stdout=True,
- redirect_stderr=True,
- # Test specific options
- error_ok=True,
- exit_code=True)
- self.assertNotEqual(result, 0)
-
- def testRunCommandErrorRetries(self):
- """Test that RunCommand can retry a failed command that always fails."""
-
- # We don't actually check that it's retrying, just exercise the code path.
- result = cros_build_lib.RunCommand(['ls', '/nosuchdir'],
- # Keep the test quiet options
- print_cmd=False,
- redirect_stdout=True,
- redirect_stderr=True,
- # Test specific options
- num_retries=2,
- error_ok=True,
- exit_code=True)
- self.assertNotEqual(result, 0)
-
- def testRunCommandErrorException(self):
- """Test that RunCommand can throw an exception when a command fails."""
-
- function = lambda : cros_build_lib.RunCommand(['ls', '/nosuchdir'],
- # Keep the test quiet options
- print_cmd=False,
- redirect_stdout=True,
- redirect_stderr=True)
- self.assertRaises(cros_build_lib.RunCommandException, function)
-
- def testRunCommandCaptureOutput(self):
- """Test that RunCommand can capture stdout if a command succeeds."""
-
- result = cros_build_lib.RunCommand(['echo', '-n', 'Hi'],
- # Keep the test quiet options
- print_cmd=False,
- redirect_stdout=True,
- redirect_stderr=True)
- self.assertEqual(result, 'Hi')
-
-
-if __name__ == '__main__':
- unittest.main()
« no previous file with comments | « lib/cros_build_lib.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698