| 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..7fda5f9a69f8e7192be22b3fc40af6a4a030661e
|
| --- /dev/null
|
| +++ b/tools/checkdeps/checkdeps_test.py
|
| @@ -0,0 +1,94 @@
|
| +#!/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))
|
| +
|
| + problem = problems[0]
|
| + index = problem.find('testdata/allowed/test.h')
|
| + self.failUnless(index != -1)
|
| + index = problem.find('-tools/checkdeps/testdata/disallowed', index + 1)
|
| + self.failUnless(index != -1)
|
| + index = problem.find('-third_party/explicitly_disallowed', index + 1)
|
| + self.failUnless(index != -1)
|
| + index = problem.find('Because of no rule applying', index + 1)
|
| + self.failUnless(index != -1)
|
| +
|
| + problem = problems[1]
|
| + index = problem.find('testdata/disallowed/test.h')
|
| + self.failUnless(index != -1)
|
| + index = problem.find('-third_party/explicitly_disallowed', index + 1)
|
| + self.failUnless(index != -1)
|
| + index = problem.find('Because of no rule applying', index + 1)
|
| + self.failUnless(index != -1)
|
| + index = problem.find('Because of no rule applying', index + 1)
|
| + self.failUnless(index != -1)
|
| +
|
| + problem = problems[2]
|
| + index = problem.find('disallowed/allowed/test.h')
|
| + self.failUnless(index != -1)
|
| + index = problem.find('-third_party/explicitly_disallowed', index + 1)
|
| + self.failUnless(index != -1)
|
| + index = problem.find('Because of no rule applying', index + 1)
|
| + self.failUnless(index != -1)
|
| + index = problem.find('Because of no rule applying', index + 1)
|
| + self.failUnless(index != -1)
|
| +
|
| + 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()
|
|
|