| 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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 try: | 357 try: |
| 358 self._execute(mode, 'missing_trailing_slash.isolate', [], True) | 358 self._execute(mode, 'missing_trailing_slash.isolate', [], True) |
| 359 self.fail() | 359 self.fail() |
| 360 except subprocess.CalledProcessError as e: | 360 except subprocess.CalledProcessError as e: |
| 361 self.assertEqual('', e.output) | 361 self.assertEqual('', e.output) |
| 362 out = e.stderr | 362 out = e.stderr |
| 363 self._expect_no_tree() | 363 self._expect_no_tree() |
| 364 self._expect_no_result() | 364 self._expect_no_result() |
| 365 root = file_path.get_native_path_case(unicode(ROOT_DIR)) | 365 root = file_path.get_native_path_case(unicode(ROOT_DIR)) |
| 366 expected = ( | 366 expected = ( |
| 367 '\n' | 367 'Input directory %s must have a trailing slash' % |
| 368 'Error: Input directory %s must have a trailing slash\n' % | |
| 369 os.path.join(root, 'tests', 'isolate', 'files1') | 368 os.path.join(root, 'tests', 'isolate', 'files1') |
| 370 ) | 369 ) |
| 371 self.assertEqual(expected, out) | 370 self.assertIn(expected, out) |
| 372 | 371 |
| 373 def _test_non_existent(self, mode): | 372 def _test_non_existent(self, mode): |
| 374 try: | 373 try: |
| 375 self._execute(mode, 'non_existent.isolate', [], True) | 374 self._execute(mode, 'non_existent.isolate', [], True) |
| 376 self.fail() | 375 self.fail() |
| 377 except subprocess.CalledProcessError as e: | 376 except subprocess.CalledProcessError as e: |
| 378 self.assertEqual('', e.output) | 377 self.assertEqual('', e.output) |
| 379 out = e.stderr | 378 out = e.stderr |
| 380 self._expect_no_tree() | 379 self._expect_no_tree() |
| 381 self._expect_no_result() | 380 self._expect_no_result() |
| 382 root = file_path.get_native_path_case(unicode(ROOT_DIR)) | 381 root = file_path.get_native_path_case(unicode(ROOT_DIR)) |
| 383 expected = ( | 382 expected = ( |
| 384 '\n' | 383 'Input file %s doesn\'t exist' % |
| 385 'Error: Input file %s doesn\'t exist\n' % | |
| 386 os.path.join(root, 'tests', 'isolate', 'A_file_that_do_not_exist') | 384 os.path.join(root, 'tests', 'isolate', 'A_file_that_do_not_exist') |
| 387 ) | 385 ) |
| 388 self.assertEqual(expected, out) | 386 self.assertIn(expected, out) |
| 389 | 387 |
| 390 def _test_all_items_invalid(self, mode): | 388 def _test_all_items_invalid(self, mode): |
| 391 out = self._execute(mode, 'all_items_invalid.isolate', | 389 out = self._execute(mode, 'all_items_invalid.isolate', |
| 392 ['--ignore_broken_item'], True) | 390 ['--ignore_broken_item'], True) |
| 393 self._expect_results(['empty.py'], None, None, None) | 391 self._expect_results(['empty.py'], None, None, None) |
| 394 | 392 |
| 395 return out or '' | 393 return out or '' |
| 396 | 394 |
| 397 | 395 |
| 398 class Isolate(unittest.TestCase): | 396 class Isolate(unittest.TestCase): |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 | 833 |
| 836 def test_no_run(self): | 834 def test_no_run(self): |
| 837 try: | 835 try: |
| 838 self._execute('trace', 'no_run.isolate', [], True) | 836 self._execute('trace', 'no_run.isolate', [], True) |
| 839 self.fail() | 837 self.fail() |
| 840 except subprocess.CalledProcessError, e: | 838 except subprocess.CalledProcessError, e: |
| 841 out = e.output | 839 out = e.output |
| 842 err = e.stderr | 840 err = e.stderr |
| 843 self._expect_no_tree() | 841 self._expect_no_tree() |
| 844 self._expect_no_result() | 842 self._expect_no_result() |
| 845 expected = '\nError: No command to run.\n' | 843 expected = 'No command to run.' |
| 846 self.assertEqual('', out) | 844 self.assertEqual('', out) |
| 847 self.assertEqual(expected, err) | 845 self.assertIn(expected, err) |
| 848 | 846 |
| 849 # TODO(csharp): Disabled until crbug.com/150823 is fixed. | 847 # TODO(csharp): Disabled until crbug.com/150823 is fixed. |
| 850 def do_not_test_touch_only(self): | 848 def do_not_test_touch_only(self): |
| 851 out = self._execute( | 849 out = self._execute( |
| 852 'trace', 'touch_only.isolate', ['-V', 'FLAG', 'trace'], True) | 850 'trace', 'touch_only.isolate', ['-V', 'FLAG', 'trace'], True) |
| 853 self.assertEqual('', out) | 851 self.assertEqual('', out) |
| 854 self._expect_no_tree() | 852 self._expect_no_tree() |
| 855 empty = os.path.join('files1', 'test_file1.txt') | 853 empty = os.path.join('files1', 'test_file1.txt') |
| 856 self._expect_results( | 854 self._expect_results( |
| 857 ['touch_only.py', 'trace'], None, {u'FLAG': u'trace'}, empty) | 855 ['touch_only.py', 'trace'], None, {u'FLAG': u'trace'}, empty) |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1168 self.assertEqual('Simply works.\n', stdout) | 1166 self.assertEqual('Simply works.\n', stdout) |
| 1169 self.assertEqual(0, proc.returncode) | 1167 self.assertEqual(0, proc.returncode) |
| 1170 | 1168 |
| 1171 | 1169 |
| 1172 if __name__ == '__main__': | 1170 if __name__ == '__main__': |
| 1173 VERBOSE = '-v' in sys.argv | 1171 VERBOSE = '-v' in sys.argv |
| 1174 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) | 1172 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) |
| 1175 if VERBOSE: | 1173 if VERBOSE: |
| 1176 unittest.TestCase.maxDiff = None | 1174 unittest.TestCase.maxDiff = None |
| 1177 unittest.main() | 1175 unittest.main() |
| OLD | NEW |