OLD | NEW |
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 '#include "c.h"', | 222 '#include "c.h"', |
223 '#else', | 223 '#else', |
224 '#include "b.h"', | 224 '#include "b.h"', |
225 '#endif', | 225 '#endif', |
226 '#include "a.h"'] | 226 '#include "a.h"'] |
227 mock_file = MockFile('', contents) | 227 mock_file = MockFile('', contents) |
228 warnings = PRESUBMIT._CheckIncludeOrderInFile( | 228 warnings = PRESUBMIT._CheckIncludeOrderInFile( |
229 mock_input_api, mock_file, range(1, len(contents) + 1)) | 229 mock_input_api, mock_file, range(1, len(contents) + 1)) |
230 self.assertEqual(0, len(warnings)) | 230 self.assertEqual(0, len(warnings)) |
231 | 231 |
232 def testSysIncludes(self): | 232 def testExcludedIncludes(self): |
233 # #include <sys/...>'s can appear in any order. | 233 # #include <sys/...>'s can appear in any order. |
234 mock_input_api = MockInputApi() | 234 mock_input_api = MockInputApi() |
235 contents = ['#include <sys/b.h>', | 235 contents = ['#include <sys/b.h>', |
236 '#include <sys/a.h>'] | 236 '#include <sys/a.h>'] |
237 mock_file = MockFile('', contents) | 237 mock_file = MockFile('', contents) |
238 warnings = PRESUBMIT._CheckIncludeOrderInFile( | 238 warnings = PRESUBMIT._CheckIncludeOrderInFile( |
239 mock_input_api, mock_file, range(1, len(contents) + 1)) | 239 mock_input_api, mock_file, range(1, len(contents) + 1)) |
240 self.assertEqual(0, len(warnings)) | 240 self.assertEqual(0, len(warnings)) |
241 | 241 |
| 242 contents = ['#include <atlbase.h>', |
| 243 '#include <aaa.h>'] |
| 244 mock_file = MockFile('', contents) |
| 245 warnings = PRESUBMIT._CheckIncludeOrderInFile( |
| 246 mock_input_api, mock_file, range(1, len(contents) + 1)) |
| 247 self.assertEqual(0, len(warnings)) |
| 248 |
| 249 contents = ['#include "build/build_config.h"', |
| 250 '#include "aaa.h"'] |
| 251 mock_file = MockFile('', contents) |
| 252 warnings = PRESUBMIT._CheckIncludeOrderInFile( |
| 253 mock_input_api, mock_file, range(1, len(contents) + 1)) |
| 254 self.assertEqual(0, len(warnings)) |
| 255 |
242 def testCheckOnlyCFiles(self): | 256 def testCheckOnlyCFiles(self): |
243 mock_input_api = MockInputApi() | 257 mock_input_api = MockInputApi() |
244 mock_output_api = MockOutputApi() | 258 mock_output_api = MockOutputApi() |
245 contents = ['#include <b.h>', | 259 contents = ['#include <b.h>', |
246 '#include <a.h>'] | 260 '#include <a.h>'] |
247 mock_file_cc = MockFile('something.cc', contents) | 261 mock_file_cc = MockFile('something.cc', contents) |
248 mock_file_h = MockFile('something.h', contents) | 262 mock_file_h = MockFile('something.h', contents) |
249 mock_file_other = MockFile('something.py', contents) | 263 mock_file_other = MockFile('something.py', contents) |
250 mock_input_api.files = [mock_file_cc, mock_file_h, mock_file_other] | 264 mock_input_api.files = [mock_file_cc, mock_file_h, mock_file_other] |
251 warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api) | 265 warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api) |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 'policy/DEPS', | 415 'policy/DEPS', |
402 'sandbox/DEPS', | 416 'sandbox/DEPS', |
403 'tools/memory_watcher/DEPS', | 417 'tools/memory_watcher/DEPS', |
404 'third_party/lss/DEPS', | 418 'third_party/lss/DEPS', |
405 ]) | 419 ]) |
406 self.assertEqual(expected, files_to_check); | 420 self.assertEqual(expected, files_to_check); |
407 | 421 |
408 | 422 |
409 if __name__ == '__main__': | 423 if __name__ == '__main__': |
410 unittest.main() | 424 unittest.main() |
OLD | NEW |