| 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 26 matching lines...) Expand all Loading... |
| 37 "targets": { | 37 "targets": { |
| 38 "//:All": { | 38 "//:All": { |
| 39 }, | 39 }, |
| 40 "//:base": { | 40 "//:base": { |
| 41 "public": [ "//base/p.h" ], | 41 "public": [ "//base/p.h" ], |
| 42 "sources": [ "//base/a.cc", "//base/a.h", "//base/b.hh" ], | 42 "sources": [ "//base/a.cc", "//base/a.h", "//base/b.hh" ], |
| 43 "visibility": [ "*" ] | 43 "visibility": [ "*" ] |
| 44 }, | 44 }, |
| 45 "//:star_public": { | 45 "//:star_public": { |
| 46 "public": "*", | 46 "public": "*", |
| 47 "sources": [ "//base/c.h" ], | 47 "sources": [ "//base/c.h", "//tmp/gen/a.h" ], |
| 48 "visibility": [ "*" ] | 48 "visibility": [ "*" ] |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 ''') | 52 ''') |
| 53 | 53 |
| 54 | 54 |
| 55 whitelist = r''' | 55 whitelist = r''' |
| 56 white-front.c | 56 white-front.c |
| 57 a/b/c/white-end.c # comment | 57 a/b/c/white-end.c # comment |
| (...skipping 25 matching lines...) Expand all Loading... |
| 83 'dir\\path\\b.h', | 83 'dir\\path\\b.h', |
| 84 'c.hh', | 84 'c.hh', |
| 85 'dir3\\path\\b.h', | 85 'dir3\\path\\b.h', |
| 86 'c3.hh', | 86 'c3.hh', |
| 87 ]) | 87 ]) |
| 88 self.assertEquals(headers, expected) | 88 self.assertEquals(headers, expected) |
| 89 | 89 |
| 90 os.sep = old_sep | 90 os.sep = old_sep |
| 91 | 91 |
| 92 def testGn(self): | 92 def testGn(self): |
| 93 headers = check_gn_headers.ParseGNProjectJSON(gn_input) | 93 headers = check_gn_headers.ParseGNProjectJSON(gn_input, |
| 94 'out/Release', 'tmp') |
| 94 expected = set([ | 95 expected = set([ |
| 95 'base/a.h', | 96 'base/a.h', |
| 96 'base/b.hh', | 97 'base/b.hh', |
| 97 'base/c.h', | 98 'base/c.h', |
| 98 'base/p.h', | 99 'base/p.h', |
| 100 'out/Release/gen/a.h', |
| 99 ]) | 101 ]) |
| 100 self.assertEquals(headers, expected) | 102 self.assertEquals(headers, expected) |
| 101 | 103 |
| 102 def testWhitelist(self): | 104 def testWhitelist(self): |
| 103 output = check_gn_headers.ParseWhiteList(whitelist) | 105 output = check_gn_headers.ParseWhiteList(whitelist) |
| 104 expected = set([ | 106 expected = set([ |
| 105 'white-front.c', | 107 'white-front.c', |
| 106 'a/b/c/white-end.c', | 108 'a/b/c/white-end.c', |
| 107 'dir/white-both.c', | 109 'dir/white-both.c', |
| 108 'a/b/c', | 110 'a/b/c', |
| 109 ]) | 111 ]) |
| 110 self.assertEquals(output, expected) | 112 self.assertEquals(output, expected) |
| 111 | 113 |
| 112 | 114 |
| 113 if __name__ == '__main__': | 115 if __name__ == '__main__': |
| 114 logging.getLogger().setLevel(logging.DEBUG) | 116 logging.getLogger().setLevel(logging.DEBUG) |
| 115 unittest.main(verbosity=2) | 117 unittest.main(verbosity=2) |
| OLD | NEW |