Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 """ | 1 """ |
| 2 TestCommon.py: a testing framework for commands and scripts | 2 TestCommon.py: a testing framework for commands and scripts |
| 3 with commonly useful error handling | 3 with commonly useful error handling |
| 4 | 4 |
| 5 The TestCommon module provides a simple, high-level interface for writing | 5 The TestCommon module provides a simple, high-level interface for writing |
| 6 tests of executable commands and scripts, especially commands and scripts | 6 tests of executable commands and scripts, especially commands and scripts |
| 7 that interact with the file system. All methods throw exceptions and | 7 that interact with the file system. All methods throw exceptions and |
| 8 exit on failure, with useful error messages. This makes a number of | 8 exit on failure, with useful error messages. This makes a number of |
| 9 explicit checks unnecessary, making the test scripts themselves simpler | 9 explicit checks unnecessary, making the test scripts themselves simpler |
| 10 to write and easier to read. | 10 to write and easier to read. |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 def separate_files(flist): | 182 def separate_files(flist): |
| 183 existing = [] | 183 existing = [] |
| 184 missing = [] | 184 missing = [] |
| 185 for f in flist: | 185 for f in flist: |
| 186 if os.path.exists(f): | 186 if os.path.exists(f): |
| 187 existing.append(f) | 187 existing.append(f) |
| 188 else: | 188 else: |
| 189 missing.append(f) | 189 missing.append(f) |
| 190 return existing, missing | 190 return existing, missing |
| 191 | 191 |
| 192 if os.name == 'posix': | 192 def _failed(self, status = 0): |
|
Nico
2012/05/17 20:31:57
The two branches looked identical to me, so I got
| |
| 193 def _failed(self, status = 0): | 193 if self.status is None or status is None: |
| 194 if self.status is None or status is None: | 194 return None |
| 195 return None | 195 try: |
| 196 return _status(self) != status | 196 return _status(self) not in status |
|
Mark Mentovai
2012/05/17 21:08:58
OK to the reorganization, but could you be consist
Nico
2012/05/17 21:29:36
Done. Huh, looks like this file doesn't use google
| |
| 197 def _status(self): | 197 except TypeError: |
| 198 return self.status | 198 # status wasn't an iterable |
| 199 elif os.name == 'nt': | 199 return _status(self) != status |
| 200 def _failed(self, status = 0): | 200 def _status(self): |
| 201 return not (self.status is None or status is None) and \ | 201 return self.status |
| 202 self.status != status | |
| 203 def _status(self): | |
| 204 return self.status | |
| 205 | 202 |
| 206 class TestCommon(TestCmd): | 203 class TestCommon(TestCmd): |
| 207 | 204 |
| 208 # Additional methods from the Perl Test::Cmd::Common module | 205 # Additional methods from the Perl Test::Cmd::Common module |
| 209 # that we may wish to add in the future: | 206 # that we may wish to add in the future: |
| 210 # | 207 # |
| 211 # $test->subdir('subdir', ...); | 208 # $test->subdir('subdir', ...); |
| 212 # | 209 # |
| 213 # $test->copy('src_file', 'dst_file'); | 210 # $test->copy('src_file', 'dst_file'); |
| 214 | 211 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 572 else: | 569 else: |
| 573 # We're under the development directory for this change, | 570 # We're under the development directory for this change, |
| 574 # so this is an Aegis invocation; pass the test (exit 0). | 571 # so this is an Aegis invocation; pass the test (exit 0). |
| 575 self.pass_test() | 572 self.pass_test() |
| 576 | 573 |
| 577 # Local Variables: | 574 # Local Variables: |
| 578 # tab-width:4 | 575 # tab-width:4 |
| 579 # indent-tabs-mode:nil | 576 # indent-tabs-mode:nil |
| 580 # End: | 577 # End: |
| 581 # vim: set expandtab tabstop=4 shiftwidth=4: | 578 # vim: set expandtab tabstop=4 shiftwidth=4: |
| OLD | NEW |