OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2017 The Chromium Authors. All rights reserved. | 2 # Copyright 2017 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 logging | 6 import logging |
7 import json | 7 import json |
8 import os | 8 import os |
9 import unittest | 9 import unittest |
10 import check_gn_headers | 10 import check_gn_headers |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 a/b/c/white-end.c # comment | 51 a/b/c/white-end.c # comment |
52 dir/white-both.c #more comment | 52 dir/white-both.c #more comment |
53 | 53 |
54 # empty line above | 54 # empty line above |
55 a/b/c | 55 a/b/c |
56 ''' | 56 ''' |
57 | 57 |
58 | 58 |
59 class CheckGnHeadersTest(unittest.TestCase): | 59 class CheckGnHeadersTest(unittest.TestCase): |
60 def testNinja(self): | 60 def testNinja(self): |
61 headers = check_gn_headers.ParseNinjaDepsOutput(ninja_input) | 61 headers = check_gn_headers.ParseNinjaDepsOutput(ninja_input.split('\n')) |
62 expected = set([ | 62 expected = set([ |
63 'dir/path/b.h', | 63 'dir/path/b.h', |
64 'c.hh', | 64 'c.hh', |
65 'dir3/path/b.h', | 65 'dir3/path/b.h', |
66 'c3.hh', | 66 'c3.hh', |
67 ]) | 67 ]) |
68 self.assertEquals(headers, expected) | 68 self.assertEquals(headers, expected) |
69 | 69 |
70 def testNinjaWin(self): | 70 def testNinjaWin(self): |
71 old_sep = os.sep | 71 old_sep = os.sep |
72 os.sep = '\\' | 72 os.sep = '\\' |
73 | 73 |
74 headers = check_gn_headers.ParseNinjaDepsOutput(ninja_input_win) | 74 headers = check_gn_headers.ParseNinjaDepsOutput( |
| 75 ninja_input_win.split('\n')) |
75 expected = set([ | 76 expected = set([ |
76 'dir\\path\\b.h', | 77 'dir\\path\\b.h', |
77 'c.hh', | 78 'c.hh', |
78 'dir3\\path\\b.h', | 79 'dir3\\path\\b.h', |
79 'c3.hh', | 80 'c3.hh', |
80 ]) | 81 ]) |
81 self.assertEquals(headers, expected) | 82 self.assertEquals(headers, expected) |
82 | 83 |
83 os.sep = old_sep | 84 os.sep = old_sep |
84 | 85 |
(...skipping 12 matching lines...) Expand all Loading... |
97 'a/b/c/white-end.c', | 98 'a/b/c/white-end.c', |
98 'dir/white-both.c', | 99 'dir/white-both.c', |
99 'a/b/c', | 100 'a/b/c', |
100 ]) | 101 ]) |
101 self.assertEquals(output, expected) | 102 self.assertEquals(output, expected) |
102 | 103 |
103 | 104 |
104 if __name__ == '__main__': | 105 if __name__ == '__main__': |
105 logging.getLogger().setLevel(logging.DEBUG) | 106 logging.getLogger().setLevel(logging.DEBUG) |
106 unittest.main(verbosity=2) | 107 unittest.main(verbosity=2) |
OLD | NEW |