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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
396 # Does not inherit from the other *Base classes. | 396 # Does not inherit from the other *Base classes. |
397 def test_help_modes(self): | 397 def test_help_modes(self): |
398 # Check coherency in the help and implemented modes. | 398 # Check coherency in the help and implemented modes. |
399 p = subprocess.Popen( | 399 p = subprocess.Popen( |
400 [sys.executable, os.path.join(ROOT_DIR, 'isolate.py'), '--help'], | 400 [sys.executable, os.path.join(ROOT_DIR, 'isolate.py'), '--help'], |
401 stdout=subprocess.PIPE, | 401 stdout=subprocess.PIPE, |
402 stderr=subprocess.STDOUT, | 402 stderr=subprocess.STDOUT, |
403 cwd=ROOT_DIR) | 403 cwd=ROOT_DIR) |
404 out = p.communicate()[0].splitlines() | 404 out = p.communicate()[0].splitlines() |
405 self.assertEqual(0, p.returncode) | 405 self.assertEqual(0, p.returncode) |
406 out = out[out.index('') + 1:] | 406 out = out[out.index('Commands are:') + 1:] |
407 out = out[:out.index('')] | 407 out = out[:out.index('')] |
408 modes = [re.match(r'^ (\w+) .+', l) for l in out] | 408 regexp = '^ (?:\x1b\\[\\d\\dm)(\\w+)\s*(:?\x1b\\[\\d\\dm) .+' |
Vadim Sh.
2013/08/19 17:54:02
err.... what is that? :) looks like write-only reg
M-A Ruel
2013/08/19 20:05:03
ANSI escape code. ESC[\d\dm
http://en.wikipedia.or
| |
409 modes = tuple(m.group(1) for m in modes if m) | 409 modes = [re.match(regexp, l) for l in out] |
410 modes = [m.group(1) for m in modes if m] | |
410 self.assertEqual(sorted(EXPECTED_MODES), sorted(modes)) | 411 self.assertEqual(sorted(EXPECTED_MODES), sorted(modes)) |
411 | 412 |
412 def test_modes(self): | 413 def test_modes(self): |
413 # This is a bit redundant but make sure all combinations are tested. | 414 # This is a bit redundant but make sure all combinations are tested. |
414 files = sorted( | 415 files = sorted( |
415 i[:-len('.isolate')] | 416 i[:-len('.isolate')] |
416 for i in os.listdir(os.path.join(ROOT_DIR, 'tests', 'isolate')) | 417 for i in os.listdir(os.path.join(ROOT_DIR, 'tests', 'isolate')) |
417 if i.endswith('.isolate') | 418 if i.endswith('.isolate') |
418 ) | 419 ) |
419 files.remove('simple') | 420 files.remove('simple') |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1151 self.assertEqual('Simply works.\n', stdout) | 1152 self.assertEqual('Simply works.\n', stdout) |
1152 self.assertEqual(0, proc.returncode) | 1153 self.assertEqual(0, proc.returncode) |
1153 | 1154 |
1154 | 1155 |
1155 if __name__ == '__main__': | 1156 if __name__ == '__main__': |
1156 VERBOSE = '-v' in sys.argv | 1157 VERBOSE = '-v' in sys.argv |
1157 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) | 1158 logging.basicConfig(level=logging.DEBUG if VERBOSE else logging.ERROR) |
1158 if VERBOSE: | 1159 if VERBOSE: |
1159 unittest.TestCase.maxDiff = None | 1160 unittest.TestCase.maxDiff = None |
1160 unittest.main() | 1161 unittest.main() |
OLD | NEW |