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

Side by Side Diff: PRESUBMIT_test.py

Issue 11413036: Fix include order PRESUBMIT check: #if-#elif-#else (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | 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 import os 6 import os
7 import re 7 import re
8 import unittest 8 import unittest
9 9
10 import PRESUBMIT 10 import PRESUBMIT
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 def testConflictAdded2(self): 148 def testConflictAdded2(self):
149 scope = [(1, '#include "c.h"'), 149 scope = [(1, '#include "c.h"'),
150 (2, '#include "b.h"'), 150 (2, '#include "b.h"'),
151 (3, '#include "d.h"')] 151 (3, '#include "d.h"')]
152 mock_input_api = MockInputApi() 152 mock_input_api = MockInputApi()
153 warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api, 153 warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
154 '', [2]) 154 '', [2])
155 self.assertEqual(1, len(warnings)) 155 self.assertEqual(1, len(warnings))
156 self.assertTrue('2' in warnings[0]) 156 self.assertTrue('2' in warnings[0])
157 157
158 def testIfElifElseEndif(self):
159 mock_input_api = MockInputApi()
160 contents = ['#include "e.h"',
161 '#if foo',
162 '#include "d.h"',
163 '#elif bar',
164 '#include "c.h"',
165 '#else',
166 '#include "b.h"',
167 '#endif',
168 '#include "a.h"']
169 mock_file = MockFile('', contents)
170 warnings = PRESUBMIT._CheckIncludeOrderInFile(
171 mock_input_api, mock_file, True, range(1, len(contents) + 1))
172 self.assertEqual(0, len(warnings))
173
158 174
159 if __name__ == '__main__': 175 if __name__ == '__main__':
160 unittest.main() 176 unittest.main()
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698