summaryrefslogtreecommitdiffstats
path: root/tools/checkdeps/checkdeps_test.py
diff options
context:
space:
mode:
authorjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-06 17:26:36 +0000
committerjoi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-06 17:26:36 +0000
commit7c7503390271018572571ca67acc0fb6ab417d62 (patch)
treeed4b5114be40c96769f2221be9c90faf6f3965e0 /tools/checkdeps/checkdeps_test.py
parent4c032ee0623ddd773d97ee99d907670b374fcca8 (diff)
downloadchromium_src-7c7503390271018572571ca67acc0fb6ab417d62.zip
chromium_src-7c7503390271018572571ca67acc0fb6ab417d62.tar.gz
chromium_src-7c7503390271018572571ca67acc0fb6ab417d62.tar.bz2
Fix a bug in checkdeps due to a shallow copy.
Add regression test that now passes and would have caught the bug. Kudos to jam@ for spotting the symptoms of the bug, which primarily would manifest when specific_include_rules are being used, and only (I think) when running presubmit or doing checkdeps for a specific directory since in that case rules get built up in child->parent order rather than the parent->child order that the normal checkdeps run would use. BUG=None Review URL: https://chromiumcodereview.appspot.com/11440013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171516 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/checkdeps/checkdeps_test.py')
-rwxr-xr-xtools/checkdeps/checkdeps_test.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/checkdeps/checkdeps_test.py b/tools/checkdeps/checkdeps_test.py
index 2ce80fa..e8835a5 100755
--- a/tools/checkdeps/checkdeps_test.py
+++ b/tools/checkdeps/checkdeps_test.py
@@ -149,6 +149,29 @@ class CheckDepsTest(unittest.TestCase):
]])
self.failUnless(problems)
+ def testCopyIsDeep(self):
+ # Regression test for a bug where we were making shallow copies of
+ # Rules objects and therefore all Rules objects shared the same
+ # dictionary for specific rules.
+ #
+ # The first pair should bring in a rule from testdata/allowed/DEPS
+ # into that global dictionary that allows the
+ # temp_allowed_for_tests.h file to be included in files ending
+ # with _unittest.cc, and the second pair should completely fail
+ # once the bug is fixed, but succeed (with a temporary allowance)
+ # if the bug is in place.
+ problems = self.deps_checker.CheckAddedCppIncludes(
+ [['tools/checkdeps/testdata/allowed/test.cc',
+ ['#include "tools/checkdeps/testdata/disallowed/temporarily_allowed.h"']
+ ],
+ ['tools/checkdeps/testdata/disallowed/foo_unittest.cc',
+ ['#include "tools/checkdeps/testdata/bongo/temp_allowed_for_tests.h"']
+ ]])
+ # With the bug in place, there would be two problems reported, and
+ # the second would be for foo_unittest.cc.
+ self.failUnless(len(problems) == 1)
+ self.failUnless(problems[0][0].endswith('/test.cc'))
+
if __name__ == '__main__':
unittest.main()