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

Unified Diff: tools/checkdeps/checkdeps_test.py

Issue 10805042: Implement ability to specify temporarily-allowed dependencies in DEPS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/checkdeps/checkdeps.py ('k') | tools/checkdeps/cpp_checker.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/checkdeps/checkdeps_test.py
diff --git a/tools/checkdeps/checkdeps_test.py b/tools/checkdeps/checkdeps_test.py
new file mode 100755
index 0000000000000000000000000000000000000000..e650baf6d24b90befb72b5835dc5b52354320bfc
--- /dev/null
+++ b/tools/checkdeps/checkdeps_test.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Tests for checkdeps.
+"""
+
+import os
+import unittest
+
+
+import checkdeps
+
+
+class CheckDepsTest(unittest.TestCase):
+
+ def setUp(self):
+ self.deps_checker = checkdeps.DepsChecker(being_tested=True)
+
+ def testRegularCheckDepsRun(self):
+ problems = self.deps_checker.CheckDirectory(
+ os.path.join(self.deps_checker.base_directory,
+ 'tools/checkdeps/testdata'))
+ self.failUnlessEqual(3, len(problems))
+
+ def VerifySubstringsInProblems(key_path, substrings_in_sequence):
+ found = False
+ key_path = os.path.normpath(key_path)
+ for problem in problems:
+ index = problem.find(key_path)
+ if index != -1:
+ for substring in substrings_in_sequence:
+ index = problem.find(substring, index + 1)
+ self.failUnless(index != -1)
+ found = True
+ break
+ if not found:
+ self.fail('Found no problem for file %s' % key_path)
+
+ VerifySubstringsInProblems('testdata/allowed/test.h',
+ ['-tools/checkdeps/testdata/disallowed',
+ '-third_party/explicitly_disallowed',
+ 'Because of no rule applying'])
+ VerifySubstringsInProblems('testdata/disallowed/test.h',
+ ['-third_party/explicitly_disallowed',
+ 'Because of no rule applying',
+ 'Because of no rule applying'])
+ VerifySubstringsInProblems('disallowed/allowed/test.h',
+ ['-third_party/explicitly_disallowed',
+ 'Because of no rule applying',
+ 'Because of no rule applying'])
+
+ def testCheckAddedIncludesAllGood(self):
+ problems = self.deps_checker.CheckAddedCppIncludes(
+ [['tools/checkdeps/testdata/allowed/test.cc',
+ ['#include "tools/checkdeps/testdata/allowed/good.h"',
+ '#include "tools/checkdeps/testdata/disallowed/allowed/good.h"']
+ ]])
+ self.failIf(problems)
+
+ def testCheckAddedIncludesManyGarbageLines(self):
+ garbage_lines = ["My name is Sam%d\n" % num for num in range(50)]
+ problems = self.deps_checker.CheckAddedCppIncludes(
+ [['tools/checkdeps/testdata/allowed/test.cc', garbage_lines]])
+ self.failIf(problems)
+
+ def testCheckAddedIncludesNoRule(self):
+ problems = self.deps_checker.CheckAddedCppIncludes(
+ [['tools/checkdeps/testdata/allowed/test.cc',
+ ['#include "no_rule_for_this/nogood.h"']
+ ]])
+ self.failUnless(problems)
+
+ def testCheckAddedIncludesSkippedDirectory(self):
+ problems = self.deps_checker.CheckAddedCppIncludes(
+ [['tools/checkdeps/testdata/disallowed/allowed/skipped/test.cc',
+ ['#include "whatever/whocares.h"']
+ ]])
+ self.failIf(problems)
+
+ def testCheckAddedIncludesTempAllowed(self):
+ problems = self.deps_checker.CheckAddedCppIncludes(
+ [['tools/checkdeps/testdata/allowed/test.cc',
+ ['#include "tools/checkdeps/testdata/disallowed/temporarily_allowed.h"']
+ ]])
+ self.failUnless(problems)
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « tools/checkdeps/checkdeps.py ('k') | tools/checkdeps/cpp_checker.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698