| 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 | |
| 9 import unittest | 8 import unittest |
| 10 import check_gn_headers | 9 import check_gn_headers |
| 11 | 10 |
| 12 | 11 |
| 13 ninja_input = r''' | 12 ninja_input = r''' |
| 14 obj/a.o: #deps 1, deps mtime 123 (VALID) | 13 obj/a.o: #deps 1, deps mtime 123 (VALID) |
| 15 ../../a.cc | 14 ../../a.cc |
| 16 ../../dir/path/b.h | 15 ../../dir/path/b.h |
| 17 ../../c.hh | 16 ../../c.hh |
| 18 | 17 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 dir/white-both.c #more comment | 57 dir/white-both.c #more comment |
| 59 | 58 |
| 60 # empty line above | 59 # empty line above |
| 61 a/b/c | 60 a/b/c |
| 62 ''' | 61 ''' |
| 63 | 62 |
| 64 | 63 |
| 65 class CheckGnHeadersTest(unittest.TestCase): | 64 class CheckGnHeadersTest(unittest.TestCase): |
| 66 def testNinja(self): | 65 def testNinja(self): |
| 67 headers = check_gn_headers.ParseNinjaDepsOutput( | 66 headers = check_gn_headers.ParseNinjaDepsOutput( |
| 68 ninja_input.split('\n'), 'out/Release') | 67 ninja_input.split('\n'), 'out/Release', False) |
| 69 expected = set([ | 68 expected = { |
| 70 'dir/path/b.h', | 69 'dir/path/b.h': ['obj/a.o'], |
| 71 'c.hh', | 70 'c.hh': ['obj/a.o'], |
| 72 'dir3/path/b.h', | 71 'dir3/path/b.h': ['obj/c.o'], |
| 73 'c3.hh', | 72 'c3.hh': ['obj/c.o'], |
| 74 ]) | 73 } |
| 75 self.assertEquals(headers, expected) | 74 self.assertEquals(headers, expected) |
| 76 | 75 |
| 77 def testGn(self): | 76 def testGn(self): |
| 78 headers = check_gn_headers.ParseGNProjectJSON(gn_input, | 77 headers = check_gn_headers.ParseGNProjectJSON(gn_input, |
| 79 'out/Release', 'tmp') | 78 'out/Release', 'tmp') |
| 80 expected = set([ | 79 expected = set([ |
| 81 'base/a.h', | 80 'base/a.h', |
| 82 'base/b.hh', | 81 'base/b.hh', |
| 83 'base/c.h', | 82 'base/c.h', |
| 84 'base/p.h', | 83 'base/p.h', |
| 85 'out/Release/gen/a.h', | 84 'out/Release/gen/a.h', |
| 86 ]) | 85 ]) |
| 87 self.assertEquals(headers, expected) | 86 self.assertEquals(headers, expected) |
| 88 | 87 |
| 89 def testWhitelist(self): | 88 def testWhitelist(self): |
| 90 output = check_gn_headers.ParseWhiteList(whitelist) | 89 output = check_gn_headers.ParseWhiteList(whitelist) |
| 91 expected = set([ | 90 expected = set([ |
| 92 'white-front.c', | 91 'white-front.c', |
| 93 'a/b/c/white-end.c', | 92 'a/b/c/white-end.c', |
| 94 'dir/white-both.c', | 93 'dir/white-both.c', |
| 95 'a/b/c', | 94 'a/b/c', |
| 96 ]) | 95 ]) |
| 97 self.assertEquals(output, expected) | 96 self.assertEquals(output, expected) |
| 98 | 97 |
| 99 | 98 |
| 100 if __name__ == '__main__': | 99 if __name__ == '__main__': |
| 101 logging.getLogger().setLevel(logging.DEBUG) | 100 logging.getLogger().setLevel(logging.DEBUG) |
| 102 unittest.main(verbosity=2) | 101 unittest.main(verbosity=2) |
| OLD | NEW |