OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import cStringIO | 6 import cStringIO |
7 import hashlib | 7 import hashlib |
8 import json | 8 import json |
9 import logging | 9 import logging |
10 import os | 10 import os |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 LEVEL = isolate.STATS_ONLY | 453 LEVEL = isolate.STATS_ONLY |
454 | 454 |
455 @staticmethod | 455 @staticmethod |
456 def _to_string(values): | 456 def _to_string(values): |
457 buf = cStringIO.StringIO() | 457 buf = cStringIO.StringIO() |
458 isolate.trace_inputs.pretty_print(values, buf) | 458 isolate.trace_inputs.pretty_print(values, buf) |
459 return buf.getvalue() | 459 return buf.getvalue() |
460 | 460 |
461 def test_fail(self): | 461 def test_fail(self): |
462 try: | 462 try: |
463 self._execute('trace', 'fail.isolate', [], True) | 463 self._execute('trace', 'fail.isolate', ['-v'], True) |
464 self.fail() | 464 self.fail() |
465 except subprocess.CalledProcessError, e: | 465 except subprocess.CalledProcessError, e: |
466 out = e.output | 466 out = e.output |
467 self._expect_no_tree() | 467 self._expect_no_tree() |
468 self._expect_results(['fail.py'], None, None) | 468 self._expect_results(['fail.py'], None, None) |
469 # In theory, there should be 2 \n at the end of expected but for an | 469 # In theory, there should be 2 \n at the end of expected but for an |
470 # unknown reason there's 3 \n on Windows so just rstrip() and compare the | 470 # unknown reason there's 3 \n on Windows so just rstrip() and compare the |
471 # text, that's sufficient for this test. | 471 # text, that's sufficient for this test. |
472 expected = 'Failure: 1\nFailing' | 472 expected = 'Failing' |
473 self.assertEquals(expected, out.rstrip()) | 473 self.assertEquals(expected, out.rstrip()) |
474 | 474 |
475 def test_missing_trailing_slash(self): | 475 def test_missing_trailing_slash(self): |
476 try: | 476 try: |
477 self._execute('trace', 'missing_trailing_slash.isolate', [], True) | 477 self._execute('trace', 'missing_trailing_slash.isolate', [], True) |
478 self.fail() | 478 self.fail() |
479 except subprocess.CalledProcessError, e: | 479 except subprocess.CalledProcessError, e: |
480 out = e.output | 480 out = e.output |
481 self._expect_no_tree() | 481 self._expect_no_tree() |
482 self._expect_no_result() | 482 self._expect_no_result() |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 ], | 552 ], |
553 } | 553 } |
554 self.assertEquals(self._to_string(expected), out) | 554 self.assertEquals(self._to_string(expected), out) |
555 | 555 |
556 | 556 |
557 | 557 |
558 if __name__ == '__main__': | 558 if __name__ == '__main__': |
559 VERBOSE = '-v' in sys.argv | 559 VERBOSE = '-v' in sys.argv |
560 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) | 560 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) |
561 unittest.main() | 561 unittest.main() |
OLD | NEW |