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

Unified Diff: lib/cros_build_lib_unittest.py

Issue 6576016: 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
« lib/cros_build_lib.py ('K') | « 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
new file mode 100755
index 0000000000000000000000000000000000000000..c25a677b7d4b0404f072cf987efc4863dd8830c4
--- /dev/null
+++ b/lib/cros_build_lib_unittest.py
@@ -0,0 +1,67 @@
+#!/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 ctest."""
sosa 2011/02/24 00:23:36 docstring
dgarrett 2011/02/24 01:06:46 Done.
+
+import unittest
+
+import cros_build_lib
+
+class CrosBuildLibTest(unittest.TestCase):
+ """Test class for cros_build_lib."""
+
+
+#RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
sosa 2011/02/24 00:23:36 left for reference?
dgarrett 2011/02/24 01:06:46 Yeah, I meant to pull it out though. Done.
+# exit_code=False, redirect_stdout=False, redirect_stderr=False,
+# cwd=None, input=None, enter_chroot=False, num_retries=0):
+
+ def setUp(self):
sosa 2011/02/24 00:23:36 Remove
dgarrett 2011/02/24 01:06:46 Done.
+ pass
+
+ def testRunCommandSimple(self):
+ 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.assertTrue(result == 0)
+
+ def testRunCommandError(self):
+ 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.assertTrue(result != 0)
+
+ def testRunCommandErrorRetries(self):
+ 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.assertTrue(result != 0)
sosa 2011/02/24 00:23:36 Should prob add a test with error_ok=False and use
dgarrett 2011/02/24 01:06:46 Yep. Meant to look up the name of that assert test
+
+ def testRunCommandCaptureOutput(self):
+ result = cros_build_lib.RunCommand(['echo', '-n', 'Hi'],
+ # Keep the test quiet options
+ print_cmd=False,
+ redirect_stdout=True,
+ redirect_stderr=True)
+ self.assertTrue(result == 'Hi')
+
+
+if __name__ == '__main__':
+ unittest.main()
« lib/cros_build_lib.py ('K') | « lib/cros_build_lib.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698