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

Side by Side Diff: checkdeps/checkdeps_test.py

Issue 2653023004: Dependancy check for .proto files is added. (Closed)
Patch Set: Proto depscheck ignores partial paths. Created 3 years, 10 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 | « checkdeps/checkdeps.py ('k') | checkdeps/proto_checker.py » ('j') | 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 (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 """Tests for checkdeps. 6 """Tests for checkdeps.
7 """ 7 """
8 8
9 import os 9 import os
10 import unittest 10 import unittest
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 dirs_traversed = [] 191 dirs_traversed = []
192 for rules, filenames in self.deps_checker.GetAllRulesAndFiles(): 192 for rules, filenames in self.deps_checker.GetAllRulesAndFiles():
193 self.failUnlessEqual(type(filenames), list) 193 self.failUnlessEqual(type(filenames), list)
194 self.failUnlessEqual(filenames, sorted(filenames)) 194 self.failUnlessEqual(filenames, sorted(filenames))
195 if filenames: 195 if filenames:
196 dir_names = set(os.path.dirname(file) for file in filenames) 196 dir_names = set(os.path.dirname(file) for file in filenames)
197 self.failUnlessEqual(1, len(dir_names)) 197 self.failUnlessEqual(1, len(dir_names))
198 dirs_traversed.append(dir_names.pop()) 198 dirs_traversed.append(dir_names.pop())
199 self.failUnlessEqual(dirs_traversed, sorted(dirs_traversed)) 199 self.failUnlessEqual(dirs_traversed, sorted(dirs_traversed))
200 200
201 def testCheckPartialImportsAreAllowed(self):
202 problems = self.deps_checker.CheckAddedProtoImports(
203 [['checkdeps/testdata/test.proto',
204 ['import "no_rule_for_this/nogood.proto"']
205 ]])
206 self.failIf(problems)
207
208 def testCheckAddedFullPathImportsAllowed(self):
209 # NOTE: Base directory is buildtools.
210 problems = self.deps_checker.CheckAddedProtoImports(
211 [['checkdeps/testdata/test.proto',
212 ['import "checkdeps/testdata/allowed/good.proto"',
213 'import "checkdeps/testdata/disallowed/sub_folder/good.proto"']
214 ]])
215 self.failIf(problems)
216
217 def testCheckAddedFullPathImportsDisallowed(self):
218 problems = self.deps_checker.CheckAddedProtoImports(
219 [['checkdeps/testdata/test.proto',
220 ['import "checkdeps/testdata/disallowed/bad.proto"']
221 ]])
222 self.failUnless(problems)
223
224 def testCheckAddedFullPathImportsManyGarbageLines(self):
225 garbage_lines = ["My name is Sam%d\n" % num for num in range(50)]
226 problems = self.deps_checker.CheckAddedProtoImports(
227 [['checkdeps/testdata/test.proto',
228 garbage_lines]])
229 self.failIf(problems)
230
231 def testCheckAddedIncludesNoRuleFullPath(self):
232 problems = self.deps_checker.CheckAddedProtoImports(
233 [['checkdeps/testdata/test.proto',
234 ['import "../tools/some.proto"']
235 ]])
236 self.failUnless(problems)
201 237
202 if __name__ == '__main__': 238 if __name__ == '__main__':
203 unittest.main() 239 unittest.main()
OLDNEW
« no previous file with comments | « checkdeps/checkdeps.py ('k') | checkdeps/proto_checker.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698