OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/python | |
2 # | |
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | |
4 # Use of this source code is governed by a BSD-style license that can be | |
5 # found in the LICENSE file. | |
6 | |
7 """Unit tests for ctest.""" | |
sosa
2011/02/24 00:23:36
docstring
dgarrett
2011/02/24 01:06:46
Done.
| |
8 | |
9 import unittest | |
10 | |
11 import cros_build_lib | |
12 | |
13 class CrosBuildLibTest(unittest.TestCase): | |
14 """Test class for cros_build_lib.""" | |
15 | |
16 | |
17 #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.
| |
18 # exit_code=False, redirect_stdout=False, redirect_stderr=False, | |
19 # cwd=None, input=None, enter_chroot=False, num_retries=0): | |
20 | |
21 def setUp(self): | |
sosa
2011/02/24 00:23:36
Remove
dgarrett
2011/02/24 01:06:46
Done.
| |
22 pass | |
23 | |
24 def testRunCommandSimple(self): | |
25 result = cros_build_lib.RunCommand(['ls'], | |
26 # Keep the test quiet options | |
27 print_cmd=False, | |
28 redirect_stdout=True, | |
29 redirect_stderr=True, | |
30 # Test specific options | |
31 exit_code=True) | |
32 self.assertTrue(result == 0) | |
33 | |
34 def testRunCommandError(self): | |
35 result = cros_build_lib.RunCommand(['ls', '/nosuchdir'], | |
36 # Keep the test quiet options | |
37 print_cmd=False, | |
38 redirect_stdout=True, | |
39 redirect_stderr=True, | |
40 # Test specific options | |
41 error_ok=True, | |
42 exit_code=True) | |
43 self.assertTrue(result != 0) | |
44 | |
45 def testRunCommandErrorRetries(self): | |
46 result = cros_build_lib.RunCommand(['ls', '/nosuchdir'], | |
47 # Keep the test quiet options | |
48 print_cmd=False, | |
49 redirect_stdout=True, | |
50 redirect_stderr=True, | |
51 # Test specific options | |
52 num_retries=2, | |
53 error_ok=True, | |
54 exit_code=True) | |
55 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
| |
56 | |
57 def testRunCommandCaptureOutput(self): | |
58 result = cros_build_lib.RunCommand(['echo', '-n', 'Hi'], | |
59 # Keep the test quiet options | |
60 print_cmd=False, | |
61 redirect_stdout=True, | |
62 redirect_stderr=True) | |
63 self.assertTrue(result == 'Hi') | |
64 | |
65 | |
66 if __name__ == '__main__': | |
67 unittest.main() | |
OLD | NEW |