| 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 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1555 self.assertEqual(expected_saved_state, actual_saved_state) | 1555 self.assertEqual(expected_saved_state, actual_saved_state) |
| 1556 self.assertEqual( | 1556 self.assertEqual( |
| 1557 [ | 1557 [ |
| 1558 'foo.0.isolated', 'foo.1.isolated', | 1558 'foo.0.isolated', 'foo.1.isolated', |
| 1559 'foo.isolated', 'foo.isolated.state', | 1559 'foo.isolated', 'foo.isolated.state', |
| 1560 ], | 1560 ], |
| 1561 sorted(os.listdir(self.directory))) | 1561 sorted(os.listdir(self.directory))) |
| 1562 | 1562 |
| 1563 | 1563 |
| 1564 class IsolateCommand(IsolateBase): | 1564 class IsolateCommand(IsolateBase): |
| 1565 def setUp(self): | |
| 1566 super(IsolateCommand, self).setUp() | |
| 1567 self._old_get_command_handler = isolate.trace_inputs.get_command_handler | |
| 1568 isolate.trace_inputs.get_command_handler = ( | |
| 1569 lambda name: getattr(isolate, 'CMD%s' % name, None)) | |
| 1570 | |
| 1571 def tearDown(self): | |
| 1572 isolate.trace_inputs.get_command_handler = self._old_get_command_handler | |
| 1573 super(IsolateCommand, self).tearDown() | |
| 1574 | |
| 1575 def test_CMDrewrite(self): | 1565 def test_CMDrewrite(self): |
| 1576 isolate_file = os.path.join(self.cwd, 'x.isolate') | 1566 isolate_file = os.path.join(self.cwd, 'x.isolate') |
| 1577 data = ( | 1567 data = ( |
| 1578 '# Foo', | 1568 '# Foo', |
| 1579 '{', | 1569 '{', |
| 1580 '}', | 1570 '}', |
| 1581 ) | 1571 ) |
| 1582 with open(isolate_file, 'wb') as f: | 1572 with open(isolate_file, 'wb') as f: |
| 1583 f.write('\n'.join(data)) | 1573 f.write('\n'.join(data)) |
| 1584 | 1574 |
| 1585 self.assertEqual(0, isolate.CMDrewrite(['-i', isolate_file])) | 1575 cmd = ['-i', isolate_file] |
| 1576 self.assertEqual(0, isolate.CMDrewrite(isolate.OptionParserIsolate(), cmd)) |
| 1586 with open(isolate_file, 'rb') as f: | 1577 with open(isolate_file, 'rb') as f: |
| 1587 actual = f.read() | 1578 actual = f.read() |
| 1588 | 1579 |
| 1589 expected = "# Foo\n{\n 'conditions': [\n ],\n}\n" | 1580 expected = "# Foo\n{\n 'conditions': [\n ],\n}\n" |
| 1590 self.assertEqual(expected, actual) | 1581 self.assertEqual(expected, actual) |
| 1591 | 1582 |
| 1592 if sys.platform != 'win32': | 1583 if sys.platform != 'win32': |
| 1593 def test_CMDcheck_no_mode_on_windows(self): | 1584 def test_CMDcheck_no_mode_on_windows(self): |
| 1594 # Store for Windows, make sure file mode are not included. Hopefully, run | 1585 # Store for Windows, make sure file mode are not included. Hopefully, run |
| 1595 # this test on another OS. | 1586 # this test on another OS. |
| 1596 isolate_file = os.path.join( | 1587 isolate_file = os.path.join( |
| 1597 ROOT_DIR, 'tests', 'isolate', 'symlink_full.isolate') | 1588 ROOT_DIR, 'tests', 'isolate', 'symlink_full.isolate') |
| 1598 isolated_file = os.path.join(self.cwd, 'foo.isolated') | 1589 isolated_file = os.path.join(self.cwd, 'foo.isolated') |
| 1599 cmd = [ | 1590 cmd = [ |
| 1600 '-i', isolate_file, | 1591 '-i', isolate_file, |
| 1601 '-V', 'OS', 'win', | 1592 '-V', 'OS', 'win', |
| 1602 '-V', 'chromeos', '0', | 1593 '-V', 'chromeos', '0', |
| 1603 '-s', isolated_file, | 1594 '-s', isolated_file, |
| 1604 ] | 1595 ] |
| 1605 self.assertEqual(0, isolate.CMDcheck(cmd)) | 1596 self.assertEqual(0, isolate.CMDcheck(isolate.OptionParserIsolate(), cmd)) |
| 1606 with open(isolated_file, 'rb') as f: | 1597 with open(isolated_file, 'rb') as f: |
| 1607 actual = json.load(f) | 1598 actual = json.load(f) |
| 1608 mapped = [ | 1599 mapped = [ |
| 1609 os.path.join('files2', 'subdir', '42.txt'), | 1600 os.path.join('files2', 'subdir', '42.txt'), |
| 1610 os.path.join('files2', 'test_file1.txt'), | 1601 os.path.join('files2', 'test_file1.txt'), |
| 1611 os.path.join('files2', 'test_file2.txt'), | 1602 os.path.join('files2', 'test_file2.txt'), |
| 1612 os.path.join('symlink_full.py'), | 1603 os.path.join('symlink_full.py'), |
| 1613 ] | 1604 ] |
| 1614 files = dict( | 1605 files = dict( |
| 1615 ( | 1606 ( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1629 self.assertEqual(expected, actual) | 1620 self.assertEqual(expected, actual) |
| 1630 | 1621 |
| 1631 | 1622 |
| 1632 if __name__ == '__main__': | 1623 if __name__ == '__main__': |
| 1633 logging.basicConfig( | 1624 logging.basicConfig( |
| 1634 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR, | 1625 level=logging.DEBUG if '-v' in sys.argv else logging.ERROR, |
| 1635 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') | 1626 format='%(levelname)5s %(filename)15s(%(lineno)3d): %(message)s') |
| 1636 if '-v' in sys.argv: | 1627 if '-v' in sys.argv: |
| 1637 unittest.TestCase.maxDiff = None | 1628 unittest.TestCase.maxDiff = None |
| 1638 unittest.main() | 1629 unittest.main() |
| OLD | NEW |