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

Side by Side Diff: build/check_gn_headers_unittest.py

Issue 2510303002: Add check_gn_headers.py to find missing headers in GN (Closed)
Patch Set: add linux and android files from tryjob runs Created 3 years, 11 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
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import logging
7 import json
8 import os
9 import unittest
10 import check_gn_headers
11
12
13 ninja_input = r'''
14 obj/a.o: #deps 1, deps mtime 123 (VALID)
15 ../../a.cc
16 ../../dir/path/b.h
17 ../../c.hh
18
19 obj/b.o: #deps 1, deps mtime 123 (STALE)
20 ../../b.cc
21 ../../dir2/path/b.h
22 ../../c2.hh
23
24 obj/c.o: #deps 1, deps mtime 123 (VALID)
25 ../../c.cc
26 ../../build/a.h
27 gen/b.h
28 ../../dir3/path/b.h
29 ../../c3.hh
30 '''
31 ninja_input_win = ninja_input.replace('/', '\\')
32
33
34 gn_input = json.loads(r'''
35 {
36 "others": [],
37 "targets": {
38 "//:All": {
39 },
40 "//:base": {
41 "sources": [ "//base/a.cc", "//base/a.h", "//base/b.hh" ],
42 "visibility": [ "*" ]
43 }
44 }
45 }
46 ''')
47
48
49 deps_input = r'''
50 deps = {
51 'src/breakpad/src':
52 Var('chromium_git') + '/breakpad/breakpad/src.git' + '@' + '',
53 }
54
55 deps_os = {
56 'win': {
57 'src/third_party/cygwin':
58 Var('chromium_git') + '/chromium/deps/cygwin.git' + '@' + '',
59
60 'src/third_party/psyco_win32':
61 Var('chromium_git') + '/chromium/deps/psyco_win32.git' + '@' + '',
62 },
63 'ios': {
64 'src/ios/third_party/earl_grey/src':
65 Var('chromium_git') + '...' + '@' + '',
66 },
67 }
68 '''
69
70
71 class CheckGnHeadersTest(unittest.TestCase):
72 def testNinja(self):
73 headers = check_gn_headers.extract_d_headers(ninja_input)
74 expected = set([
75 'dir/path/b.h',
76 'c.hh',
77 'dir3/path/b.h',
78 'c3.hh',
79 ])
80 self.assertEquals(headers, expected)
81
82 def testNinjaWin(self):
83 old_sep = os.sep
84 os.sep = '\\'
85
86 headers = check_gn_headers.extract_d_headers(ninja_input_win)
87 expected = set([
88 'dir\\path\\b.h',
89 'c.hh',
90 'dir3\\path\\b.h',
91 'c3.hh',
92 ])
93 self.assertEquals(headers, expected)
94
95 os.sep = old_sep
96
97 def testGn(self):
98 headers = check_gn_headers.extract_gn_headers(gn_input)
99 expected = set([
100 'base/a.h',
101 'base/b.hh',
102 ])
103 self.assertEquals(headers, expected)
104
105 def testDeps(self):
106 headers = check_gn_headers.extract_deps_prefixes(deps_input)
107 expected = set([
108 'breakpad/src',
109 'third_party/cygwin',
110 'third_party/psyco_win32',
111 'ios/third_party/earl_grey/src',
112 ])
113 self.assertEquals(headers, expected)
114
115
116 if __name__ == '__main__':
117 logging.getLogger().setLevel(logging.DEBUG)
118 unittest.main(verbosity=2)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698