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 """Unit tests for gclient_scm.py.""" | 6 """Unit tests for gclient_scm.py.""" |
7 | 7 |
8 # pylint: disable=E1103 | 8 # pylint: disable=E1103 |
9 | 9 |
10 # Import before super_mox to keep valid references. | 10 # Import before super_mox to keep valid references. |
11 from shutil import rmtree | 11 from shutil import rmtree |
12 from subprocess import Popen, PIPE, STDOUT | 12 from subprocess import Popen, PIPE, STDOUT |
13 | 13 |
14 import logging | 14 import logging |
15 import os | 15 import os |
16 import re | 16 import re |
17 import sys | 17 import sys |
18 import tempfile | 18 import tempfile |
19 import unittest | 19 import unittest |
20 | 20 |
21 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | 21 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
22 | 22 |
23 from testing_support.super_mox import mox, StdoutCheck, SuperMoxTestBase | 23 from testing_support.super_mox import mox, StdoutCheck, SuperMoxTestBase |
24 from testing_support.super_mox import TestCaseUtils | 24 from testing_support.super_mox import TestCaseUtils |
25 | 25 |
26 import gclient_scm | 26 import gclient_scm |
| 27 import git_cache |
27 import subprocess2 | 28 import subprocess2 |
28 | 29 |
| 30 # Disable global git cache |
| 31 git_cache.Mirror.SetCachePath(None) |
| 32 |
29 # Shortcut since this function is used often | 33 # Shortcut since this function is used often |
30 join = gclient_scm.os.path.join | 34 join = gclient_scm.os.path.join |
31 | 35 |
32 TIMESTAMP_RE = re.compile('\[[0-9]{1,2}:[0-9]{2}:[0-9]{2}\] (.*)', re.DOTALL) | 36 TIMESTAMP_RE = re.compile('\[[0-9]{1,2}:[0-9]{2}:[0-9]{2}\] (.*)', re.DOTALL) |
33 def strip_timestamps(value): | 37 def strip_timestamps(value): |
34 lines = value.splitlines(True) | 38 lines = value.splitlines(True) |
35 for i in xrange(len(lines)): | 39 for i in xrange(len(lines)): |
36 m = TIMESTAMP_RE.match(lines[i]) | 40 m = TIMESTAMP_RE.match(lines[i]) |
37 if m: | 41 if m: |
38 lines[i] = m.group(1) | 42 lines[i] = m.group(1) |
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 file_list = [] | 1568 file_list = [] |
1565 options.revision = 'unmanaged' | 1569 options.revision = 'unmanaged' |
1566 scm.update(options, (), file_list) | 1570 scm.update(options, (), file_list) |
1567 self.assertEquals(file_list, expected_file_list) | 1571 self.assertEquals(file_list, expected_file_list) |
1568 self.assertEquals(scm.revinfo(options, (), None), | 1572 self.assertEquals(scm.revinfo(options, (), None), |
1569 '069c602044c5388d2d15c3f875b057c852003458') | 1573 '069c602044c5388d2d15c3f875b057c852003458') |
1570 self.checkstdout('________ unmanaged solution; skipping .\n') | 1574 self.checkstdout('________ unmanaged solution; skipping .\n') |
1571 | 1575 |
1572 | 1576 |
1573 if __name__ == '__main__': | 1577 if __name__ == '__main__': |
1574 if '-v' in sys.argv: | 1578 level = logging.DEBUG if '-v' in sys.argv else logging.FATAL |
1575 logging.basicConfig( | 1579 logging.basicConfig( |
1576 level=logging.DEBUG, | 1580 level=level, |
1577 format='%(asctime).19s %(levelname)s %(filename)s:' | 1581 format='%(asctime).19s %(levelname)s %(filename)s:' |
1578 '%(lineno)s %(message)s') | 1582 '%(lineno)s %(message)s') |
1579 unittest.main() | 1583 unittest.main() |
1580 | 1584 |
1581 # vim: ts=2:sw=2:tw=80:et: | 1585 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |