| 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 20 matching lines...) Expand all Loading... |
| 31 ninja_input_win = ninja_input.replace('/', '\\') | 31 ninja_input_win = ninja_input.replace('/', '\\') |
| 32 | 32 |
| 33 | 33 |
| 34 gn_input = json.loads(r''' | 34 gn_input = json.loads(r''' |
| 35 { | 35 { |
| 36 "others": [], | 36 "others": [], |
| 37 "targets": { | 37 "targets": { |
| 38 "//:All": { | 38 "//:All": { |
| 39 }, | 39 }, |
| 40 "//:base": { | 40 "//:base": { |
| 41 "public": [ "//base/p.h" ], |
| 41 "sources": [ "//base/a.cc", "//base/a.h", "//base/b.hh" ], | 42 "sources": [ "//base/a.cc", "//base/a.h", "//base/b.hh" ], |
| 42 "visibility": [ "*" ] | 43 "visibility": [ "*" ] |
| 43 } | 44 } |
| 44 } | 45 } |
| 45 } | 46 } |
| 46 ''') | 47 ''') |
| 47 | 48 |
| 48 | 49 |
| 49 whitelist = r''' | 50 whitelist = r''' |
| 50 white-front.c | 51 white-front.c |
| (...skipping 30 matching lines...) Expand all Loading... |
| 81 ]) | 82 ]) |
| 82 self.assertEquals(headers, expected) | 83 self.assertEquals(headers, expected) |
| 83 | 84 |
| 84 os.sep = old_sep | 85 os.sep = old_sep |
| 85 | 86 |
| 86 def testGn(self): | 87 def testGn(self): |
| 87 headers = check_gn_headers.ParseGNProjectJSON(gn_input) | 88 headers = check_gn_headers.ParseGNProjectJSON(gn_input) |
| 88 expected = set([ | 89 expected = set([ |
| 89 'base/a.h', | 90 'base/a.h', |
| 90 'base/b.hh', | 91 'base/b.hh', |
| 92 'base/p.h', |
| 91 ]) | 93 ]) |
| 92 self.assertEquals(headers, expected) | 94 self.assertEquals(headers, expected) |
| 93 | 95 |
| 94 def testWhitelist(self): | 96 def testWhitelist(self): |
| 95 output = check_gn_headers.ParseWhiteList(whitelist) | 97 output = check_gn_headers.ParseWhiteList(whitelist) |
| 96 expected = set([ | 98 expected = set([ |
| 97 'white-front.c', | 99 'white-front.c', |
| 98 'a/b/c/white-end.c', | 100 'a/b/c/white-end.c', |
| 99 'dir/white-both.c', | 101 'dir/white-both.c', |
| 100 'a/b/c', | 102 'a/b/c', |
| 101 ]) | 103 ]) |
| 102 self.assertEquals(output, expected) | 104 self.assertEquals(output, expected) |
| 103 | 105 |
| 104 | 106 |
| 105 if __name__ == '__main__': | 107 if __name__ == '__main__': |
| 106 logging.getLogger().setLevel(logging.DEBUG) | 108 logging.getLogger().setLevel(logging.DEBUG) |
| 107 unittest.main(verbosity=2) | 109 unittest.main(verbosity=2) |
| OLD | NEW |