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.py. | 6 """Unit tests for gclient.py. |
7 | 7 |
8 See gclient_smoketest.py for integration tests. | 8 See gclient_smoketest.py for integration tests. |
9 """ | 9 """ |
10 | 10 |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 # Deps after this would have been skipped if we were obeying | 802 # Deps after this would have been skipped if we were obeying |
803 # |recurselist|. | 803 # |recurselist|. |
804 'svn://example.com/foo/bar/baz', | 804 'svn://example.com/foo/bar/baz', |
805 'svn://example.com/foo/bar/baz/fizz', | 805 'svn://example.com/foo/bar/baz/fizz', |
806 # And this dep would have been picked up if we were obeying | 806 # And this dep would have been picked up if we were obeying |
807 # |recurselist|. | 807 # |recurselist|. |
808 # 'svn://example.com/foo/bar/baz/fuzz', | 808 # 'svn://example.com/foo/bar/baz/fuzz', |
809 ], | 809 ], |
810 self._get_processed()) | 810 self._get_processed()) |
811 | 811 |
| 812 def testGitDeps(self): |
| 813 """Verifies gclient respects a .DEPS.git deps file. |
| 814 |
| 815 Along the way, we also test that if both DEPS and .DEPS.git are present, |
| 816 that gclient does not read the DEPS file. This will reliably catch bugs |
| 817 where gclient is always hitting the wrong file (DEPS). |
| 818 """ |
| 819 write( |
| 820 '.gclient', |
| 821 'solutions = [\n' |
| 822 ' { "name": "foo", "url": "svn://example.com/foo",\n' |
| 823 ' "deps_file" : ".DEPS.git",\n' |
| 824 ' },\n' |
| 825 ']') |
| 826 write( |
| 827 os.path.join('foo', '.DEPS.git'), |
| 828 'deps = {\n' |
| 829 ' "bar": "/bar",\n' |
| 830 '}') |
| 831 write( |
| 832 os.path.join('foo', 'DEPS'), |
| 833 'deps = {\n' |
| 834 ' "baz": "/baz",\n' |
| 835 '}') |
| 836 |
| 837 options, _ = gclient.OptionParser().parse_args([]) |
| 838 obj = gclient.GClient.LoadCurrentConfig(options) |
| 839 obj.RunOnDeps('None', []) |
| 840 self.assertEquals( |
| 841 [ |
| 842 'svn://example.com/foo', |
| 843 'svn://example.com/foo/bar', |
| 844 ], |
| 845 self._get_processed()) |
| 846 |
| 847 def testGitDepsFallback(self): |
| 848 """Verifies gclient respects fallback to DEPS upon missing deps file.""" |
| 849 write( |
| 850 '.gclient', |
| 851 'solutions = [\n' |
| 852 ' { "name": "foo", "url": "svn://example.com/foo",\n' |
| 853 ' "deps_file" : ".DEPS.git",\n' |
| 854 ' },\n' |
| 855 ']') |
| 856 write( |
| 857 os.path.join('foo', 'DEPS'), |
| 858 'deps = {\n' |
| 859 ' "bar": "/bar",\n' |
| 860 '}') |
| 861 |
| 862 options, _ = gclient.OptionParser().parse_args([]) |
| 863 obj = gclient.GClient.LoadCurrentConfig(options) |
| 864 obj.RunOnDeps('None', []) |
| 865 self.assertEquals( |
| 866 [ |
| 867 'svn://example.com/foo', |
| 868 'svn://example.com/foo/bar', |
| 869 ], |
| 870 self._get_processed()) |
| 871 |
812 | 872 |
813 if __name__ == '__main__': | 873 if __name__ == '__main__': |
814 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) | 874 sys.stdout = gclient_utils.MakeFileAutoFlush(sys.stdout) |
815 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) | 875 sys.stdout = gclient_utils.MakeFileAnnotated(sys.stdout, include_zero=True) |
816 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) | 876 sys.stderr = gclient_utils.MakeFileAutoFlush(sys.stderr) |
817 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) | 877 sys.stderr = gclient_utils.MakeFileAnnotated(sys.stderr, include_zero=True) |
818 logging.basicConfig( | 878 logging.basicConfig( |
819 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ | 879 level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][ |
820 min(sys.argv.count('-v'), 3)], | 880 min(sys.argv.count('-v'), 3)], |
821 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' | 881 format='%(relativeCreated)4d %(levelname)5s %(module)13s(' |
822 '%(lineno)d) %(message)s') | 882 '%(lineno)d) %(message)s') |
823 unittest.main() | 883 unittest.main() |
OLD | NEW |