Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: build/check_gn_headers_unittest.py

Issue 2841323003: Handle |public| in check_gn_headers.py (Closed)
Patch Set: add tests Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/check_gn_headers.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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": [ "*" ]
44 },
45 "//:star_public": {
46 "public": "*",
47 "sources": [ "//base/c.h" ],
48 "visibility": [ "*" ]
43 } 49 }
44 } 50 }
45 } 51 }
46 ''') 52 ''')
47 53
48 54
49 whitelist = r''' 55 whitelist = r'''
50 white-front.c 56 white-front.c
51 a/b/c/white-end.c # comment 57 a/b/c/white-end.c # comment
52 dir/white-both.c #more comment 58 dir/white-both.c #more comment
(...skipping 28 matching lines...) Expand all
81 ]) 87 ])
82 self.assertEquals(headers, expected) 88 self.assertEquals(headers, expected)
83 89
84 os.sep = old_sep 90 os.sep = old_sep
85 91
86 def testGn(self): 92 def testGn(self):
87 headers = check_gn_headers.ParseGNProjectJSON(gn_input) 93 headers = check_gn_headers.ParseGNProjectJSON(gn_input)
88 expected = set([ 94 expected = set([
89 'base/a.h', 95 'base/a.h',
90 'base/b.hh', 96 'base/b.hh',
97 'base/c.h',
98 'base/p.h',
91 ]) 99 ])
92 self.assertEquals(headers, expected) 100 self.assertEquals(headers, expected)
93 101
94 def testWhitelist(self): 102 def testWhitelist(self):
95 output = check_gn_headers.ParseWhiteList(whitelist) 103 output = check_gn_headers.ParseWhiteList(whitelist)
96 expected = set([ 104 expected = set([
97 'white-front.c', 105 'white-front.c',
98 'a/b/c/white-end.c', 106 'a/b/c/white-end.c',
99 'dir/white-both.c', 107 'dir/white-both.c',
100 'a/b/c', 108 'a/b/c',
101 ]) 109 ])
102 self.assertEquals(output, expected) 110 self.assertEquals(output, expected)
103 111
104 112
105 if __name__ == '__main__': 113 if __name__ == '__main__':
106 logging.getLogger().setLevel(logging.DEBUG) 114 logging.getLogger().setLevel(logging.DEBUG)
107 unittest.main(verbosity=2) 115 unittest.main(verbosity=2)
OLDNEW
« no previous file with comments | « build/check_gn_headers.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698