[Cronet] Handle redirects in CronetHttpURLConnection
[chromium-blink-merge.git] / PRESUBMIT_test.py
blob9d82644ac71b5d4f64376d9f590cad90f21cb043
1 #!/usr/bin/env python
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
4 # found in the LICENSE file.
6 import glob
7 import json
8 import os
9 import re
10 import subprocess
11 import sys
12 import unittest
14 import PRESUBMIT
15 from PRESUBMIT_test_mocks import MockChange, MockFile
16 from PRESUBMIT_test_mocks import MockInputApi, MockOutputApi
18 _TEST_DATA_DIR = 'base/test/data/presubmit'
20 class IncludeOrderTest(unittest.TestCase):
21 def testSystemHeaderOrder(self):
22 scope = [(1, '#include <csystem.h>'),
23 (2, '#include <cppsystem>'),
24 (3, '#include "acustom.h"')]
25 all_linenums = [linenum for (linenum, _) in scope]
26 mock_input_api = MockInputApi()
27 warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
28 '', all_linenums)
29 self.assertEqual(0, len(warnings))
31 def testSystemHeaderOrderMismatch1(self):
32 scope = [(10, '#include <cppsystem>'),
33 (20, '#include <csystem.h>'),
34 (30, '#include "acustom.h"')]
35 all_linenums = [linenum for (linenum, _) in scope]
36 mock_input_api = MockInputApi()
37 warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
38 '', all_linenums)
39 self.assertEqual(1, len(warnings))
40 self.assertTrue('20' in warnings[0])
42 def testSystemHeaderOrderMismatch2(self):
43 scope = [(10, '#include <cppsystem>'),
44 (20, '#include "acustom.h"'),
45 (30, '#include <csystem.h>')]
46 all_linenums = [linenum for (linenum, _) in scope]
47 mock_input_api = MockInputApi()
48 warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
49 '', all_linenums)
50 self.assertEqual(1, len(warnings))
51 self.assertTrue('30' in warnings[0])
53 def testSystemHeaderOrderMismatch3(self):
54 scope = [(10, '#include "acustom.h"'),
55 (20, '#include <csystem.h>'),
56 (30, '#include <cppsystem>')]
57 all_linenums = [linenum for (linenum, _) in scope]
58 mock_input_api = MockInputApi()
59 warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
60 '', all_linenums)
61 self.assertEqual(2, len(warnings))
62 self.assertTrue('20' in warnings[0])
63 self.assertTrue('30' in warnings[1])
65 def testAlphabeticalOrderMismatch(self):
66 scope = [(10, '#include <csystem.h>'),
67 (15, '#include <bsystem.h>'),
68 (20, '#include <cppsystem>'),
69 (25, '#include <bppsystem>'),
70 (30, '#include "bcustom.h"'),
71 (35, '#include "acustom.h"')]
72 all_linenums = [linenum for (linenum, _) in scope]
73 mock_input_api = MockInputApi()
74 warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
75 '', all_linenums)
76 self.assertEqual(3, len(warnings))
77 self.assertTrue('15' in warnings[0])
78 self.assertTrue('25' in warnings[1])
79 self.assertTrue('35' in warnings[2])
81 def testSpecialFirstInclude1(self):
82 mock_input_api = MockInputApi()
83 contents = ['#include "some/path/foo.h"',
84 '#include "a/header.h"']
85 mock_file = MockFile('some/path/foo.cc', contents)
86 warnings = PRESUBMIT._CheckIncludeOrderInFile(
87 mock_input_api, mock_file, range(1, len(contents) + 1))
88 self.assertEqual(0, len(warnings))
90 def testSpecialFirstInclude2(self):
91 mock_input_api = MockInputApi()
92 contents = ['#include "some/other/path/foo.h"',
93 '#include "a/header.h"']
94 mock_file = MockFile('some/path/foo.cc', contents)
95 warnings = PRESUBMIT._CheckIncludeOrderInFile(
96 mock_input_api, mock_file, range(1, len(contents) + 1))
97 self.assertEqual(0, len(warnings))
99 def testSpecialFirstInclude3(self):
100 mock_input_api = MockInputApi()
101 contents = ['#include "some/path/foo.h"',
102 '#include "a/header.h"']
103 mock_file = MockFile('some/path/foo_platform.cc', contents)
104 warnings = PRESUBMIT._CheckIncludeOrderInFile(
105 mock_input_api, mock_file, range(1, len(contents) + 1))
106 self.assertEqual(0, len(warnings))
108 def testSpecialFirstInclude4(self):
109 mock_input_api = MockInputApi()
110 contents = ['#include "some/path/bar.h"',
111 '#include "a/header.h"']
112 mock_file = MockFile('some/path/foo_platform.cc', contents)
113 warnings = PRESUBMIT._CheckIncludeOrderInFile(
114 mock_input_api, mock_file, range(1, len(contents) + 1))
115 self.assertEqual(1, len(warnings))
116 self.assertTrue('2' in warnings[0])
118 def testSpecialFirstInclude5(self):
119 mock_input_api = MockInputApi()
120 contents = ['#include "some/other/path/foo.h"',
121 '#include "a/header.h"']
122 mock_file = MockFile('some/path/foo-suffix.h', contents)
123 warnings = PRESUBMIT._CheckIncludeOrderInFile(
124 mock_input_api, mock_file, range(1, len(contents) + 1))
125 self.assertEqual(0, len(warnings))
127 def testSpecialFirstInclude6(self):
128 mock_input_api = MockInputApi()
129 contents = ['#include "some/other/path/foo_win.h"',
130 '#include <set>',
131 '#include "a/header.h"']
132 mock_file = MockFile('some/path/foo_unittest_win.h', contents)
133 warnings = PRESUBMIT._CheckIncludeOrderInFile(
134 mock_input_api, mock_file, range(1, len(contents) + 1))
135 self.assertEqual(0, len(warnings))
137 def testOrderAlreadyWrong(self):
138 scope = [(1, '#include "b.h"'),
139 (2, '#include "a.h"'),
140 (3, '#include "c.h"')]
141 mock_input_api = MockInputApi()
142 warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
143 '', [3])
144 self.assertEqual(0, len(warnings))
146 def testConflictAdded1(self):
147 scope = [(1, '#include "a.h"'),
148 (2, '#include "c.h"'),
149 (3, '#include "b.h"')]
150 mock_input_api = MockInputApi()
151 warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
152 '', [2])
153 self.assertEqual(1, len(warnings))
154 self.assertTrue('3' in warnings[0])
156 def testConflictAdded2(self):
157 scope = [(1, '#include "c.h"'),
158 (2, '#include "b.h"'),
159 (3, '#include "d.h"')]
160 mock_input_api = MockInputApi()
161 warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api,
162 '', [2])
163 self.assertEqual(1, len(warnings))
164 self.assertTrue('2' in warnings[0])
166 def testIfElifElseEndif(self):
167 mock_input_api = MockInputApi()
168 contents = ['#include "e.h"',
169 '#define foo',
170 '#include "f.h"',
171 '#undef foo',
172 '#include "e.h"',
173 '#if foo',
174 '#include "d.h"',
175 '#elif bar',
176 '#include "c.h"',
177 '#else',
178 '#include "b.h"',
179 '#endif',
180 '#include "a.h"']
181 mock_file = MockFile('', contents)
182 warnings = PRESUBMIT._CheckIncludeOrderInFile(
183 mock_input_api, mock_file, range(1, len(contents) + 1))
184 self.assertEqual(0, len(warnings))
186 def testExcludedIncludes(self):
187 # #include <sys/...>'s can appear in any order.
188 mock_input_api = MockInputApi()
189 contents = ['#include <sys/b.h>',
190 '#include <sys/a.h>']
191 mock_file = MockFile('', contents)
192 warnings = PRESUBMIT._CheckIncludeOrderInFile(
193 mock_input_api, mock_file, range(1, len(contents) + 1))
194 self.assertEqual(0, len(warnings))
196 contents = ['#include <atlbase.h>',
197 '#include <aaa.h>']
198 mock_file = MockFile('', contents)
199 warnings = PRESUBMIT._CheckIncludeOrderInFile(
200 mock_input_api, mock_file, range(1, len(contents) + 1))
201 self.assertEqual(0, len(warnings))
203 contents = ['#include "build/build_config.h"',
204 '#include "aaa.h"']
205 mock_file = MockFile('', contents)
206 warnings = PRESUBMIT._CheckIncludeOrderInFile(
207 mock_input_api, mock_file, range(1, len(contents) + 1))
208 self.assertEqual(0, len(warnings))
210 def testCheckOnlyCFiles(self):
211 mock_input_api = MockInputApi()
212 mock_output_api = MockOutputApi()
213 contents = ['#include <b.h>',
214 '#include <a.h>']
215 mock_file_cc = MockFile('something.cc', contents)
216 mock_file_h = MockFile('something.h', contents)
217 mock_file_other = MockFile('something.py', contents)
218 mock_input_api.files = [mock_file_cc, mock_file_h, mock_file_other]
219 warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api)
220 self.assertEqual(1, len(warnings))
221 self.assertEqual(2, len(warnings[0].items))
222 self.assertEqual('promptOrNotify', warnings[0].type)
224 def testUncheckableIncludes(self):
225 mock_input_api = MockInputApi()
226 contents = ['#include <windows.h>',
227 '#include "b.h"',
228 '#include "a.h"']
229 mock_file = MockFile('', contents)
230 warnings = PRESUBMIT._CheckIncludeOrderInFile(
231 mock_input_api, mock_file, range(1, len(contents) + 1))
232 self.assertEqual(1, len(warnings))
234 contents = ['#include "gpu/command_buffer/gles_autogen.h"',
235 '#include "b.h"',
236 '#include "a.h"']
237 mock_file = MockFile('', contents)
238 warnings = PRESUBMIT._CheckIncludeOrderInFile(
239 mock_input_api, mock_file, range(1, len(contents) + 1))
240 self.assertEqual(1, len(warnings))
242 contents = ['#include "gl_mock_autogen.h"',
243 '#include "b.h"',
244 '#include "a.h"']
245 mock_file = MockFile('', contents)
246 warnings = PRESUBMIT._CheckIncludeOrderInFile(
247 mock_input_api, mock_file, range(1, len(contents) + 1))
248 self.assertEqual(1, len(warnings))
250 contents = ['#include "ipc/some_macros.h"',
251 '#include "b.h"',
252 '#include "a.h"']
253 mock_file = MockFile('', contents)
254 warnings = PRESUBMIT._CheckIncludeOrderInFile(
255 mock_input_api, mock_file, range(1, len(contents) + 1))
256 self.assertEqual(1, len(warnings))
259 class VersionControlConflictsTest(unittest.TestCase):
260 def testTypicalConflict(self):
261 lines = ['<<<<<<< HEAD',
262 ' base::ScopedTempDir temp_dir_;',
263 '=======',
264 ' ScopedTempDir temp_dir_;',
265 '>>>>>>> master']
266 errors = PRESUBMIT._CheckForVersionControlConflictsInFile(
267 MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
268 self.assertEqual(3, len(errors))
269 self.assertTrue('1' in errors[0])
270 self.assertTrue('3' in errors[1])
271 self.assertTrue('5' in errors[2])
273 class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase):
274 def testTypicalNotMatchedChange(self):
275 diff = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)']
276 mock_input_api = MockInputApi()
277 mock_input_api.files = [MockFile('some/path/foo.cc', diff)]
278 warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api,
279 MockOutputApi())
280 self.assertEqual(1, len(warnings))
281 self.assertEqual('warning', warnings[0].type)
283 def testTypicalCorrectlyMatchedChange(self):
284 diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)']
285 diff_xml = ['<histogram name="Bla.Foo.Dummy"> </histogram>']
286 mock_input_api = MockInputApi()
287 mock_input_api.files = [
288 MockFile('some/path/foo.cc', diff_cc),
289 MockFile('tools/metrics/histograms/histograms.xml', diff_xml),
291 warnings = []
292 warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api,
293 MockOutputApi())
294 self.assertEqual(0, len(warnings))
296 class BadExtensionsTest(unittest.TestCase):
297 def testBadRejFile(self):
298 mock_input_api = MockInputApi()
299 mock_input_api.files = [
300 MockFile('some/path/foo.cc', ''),
301 MockFile('some/path/foo.cc.rej', ''),
302 MockFile('some/path2/bar.h.rej', ''),
305 results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi())
306 self.assertEqual(1, len(results))
307 self.assertEqual(2, len(results[0].items))
308 self.assertTrue('foo.cc.rej' in results[0].items[0])
309 self.assertTrue('bar.h.rej' in results[0].items[1])
311 def testBadOrigFile(self):
312 mock_input_api = MockInputApi()
313 mock_input_api.files = [
314 MockFile('other/path/qux.h.orig', ''),
315 MockFile('other/path/qux.h', ''),
316 MockFile('other/path/qux.cc', ''),
319 results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi())
320 self.assertEqual(1, len(results))
321 self.assertEqual(1, len(results[0].items))
322 self.assertTrue('qux.h.orig' in results[0].items[0])
324 def testGoodFiles(self):
325 mock_input_api = MockInputApi()
326 mock_input_api.files = [
327 MockFile('other/path/qux.h', ''),
328 MockFile('other/path/qux.cc', ''),
330 results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi())
331 self.assertEqual(0, len(results))
333 def testOnlyOwnersFiles(self):
334 mock_change = MockChange([
335 'some/path/OWNERS',
336 'A\Windows\Path\OWNERS',
338 results = PRESUBMIT.GetPreferredTryMasters(None, mock_change)
339 self.assertEqual({}, results)
342 class InvalidOSMacroNamesTest(unittest.TestCase):
343 def testInvalidOSMacroNames(self):
344 lines = ['#if defined(OS_WINDOWS)',
345 ' #elif defined(OS_WINDOW)',
346 ' # if defined(OS_MACOSX) || defined(OS_CHROME)',
347 '# else // defined(OS_MAC)',
348 '#endif // defined(OS_MACOS)']
349 errors = PRESUBMIT._CheckForInvalidOSMacrosInFile(
350 MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
351 self.assertEqual(len(lines), len(errors))
352 self.assertTrue(':1 OS_WINDOWS' in errors[0])
353 self.assertTrue('(did you mean OS_WIN?)' in errors[0])
355 def testValidOSMacroNames(self):
356 lines = ['#if defined(%s)' % m for m in PRESUBMIT._VALID_OS_MACROS]
357 errors = PRESUBMIT._CheckForInvalidOSMacrosInFile(
358 MockInputApi(), MockFile('some/path/foo_platform.cc', lines))
359 self.assertEqual(0, len(errors))
362 class InvalidIfDefinedMacroNamesTest(unittest.TestCase):
363 def testInvalidIfDefinedMacroNames(self):
364 lines = ['#if defined(TARGET_IPHONE_SIMULATOR)',
365 '#if !defined(TARGET_IPHONE_SIMULATOR)',
366 '#elif defined(TARGET_IPHONE_SIMULATOR)',
367 '#ifdef TARGET_IPHONE_SIMULATOR',
368 ' # ifdef TARGET_IPHONE_SIMULATOR',
369 '# if defined(VALID) || defined(TARGET_IPHONE_SIMULATOR)',
370 '# else // defined(TARGET_IPHONE_SIMULATOR)',
371 '#endif // defined(TARGET_IPHONE_SIMULATOR)',]
372 errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile(
373 MockInputApi(), MockFile('some/path/source.mm', lines))
374 self.assertEqual(len(lines), len(errors))
376 def testValidIfDefinedMacroNames(self):
377 lines = ['#if defined(FOO)',
378 '#ifdef BAR',]
379 errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile(
380 MockInputApi(), MockFile('some/path/source.cc', lines))
381 self.assertEqual(0, len(errors))
384 class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase):
385 def testFilesToCheckForIncomingDeps(self):
386 changed_lines = [
387 '"+breakpad",',
388 '"+chrome/installer",',
389 '"+chrome/plugin/chrome_content_plugin_client.h",',
390 '"+chrome/utility/chrome_content_utility_client.h",',
391 '"+chromeos/chromeos_paths.h",',
392 '"+components/crash",',
393 '"+components/nacl/common",',
394 '"+content/public/browser/render_process_host.h",',
395 '"+jni/fooblat.h",',
396 '"+grit", # For generated headers',
397 '"+grit/generated_resources.h",',
398 '"+grit/",',
399 '"+policy", # For generated headers and source',
400 '"+sandbox",',
401 '"+tools/memory_watcher",',
402 '"+third_party/lss/linux_syscall_support.h",',
404 files_to_check = PRESUBMIT._FilesToCheckForIncomingDeps(re, changed_lines)
405 expected = set([
406 'breakpad/DEPS',
407 'chrome/installer/DEPS',
408 'chrome/plugin/chrome_content_plugin_client.h',
409 'chrome/utility/chrome_content_utility_client.h',
410 'chromeos/chromeos_paths.h',
411 'components/crash/DEPS',
412 'components/nacl/common/DEPS',
413 'content/public/browser/render_process_host.h',
414 'policy/DEPS',
415 'sandbox/DEPS',
416 'tools/memory_watcher/DEPS',
417 'third_party/lss/linux_syscall_support.h',
419 self.assertEqual(expected, files_to_check);
422 class JSONParsingTest(unittest.TestCase):
423 def testSuccess(self):
424 input_api = MockInputApi()
425 filename = 'valid_json.json'
426 contents = ['// This is a comment.',
427 '{',
428 ' "key1": ["value1", "value2"],',
429 ' "key2": 3 // This is an inline comment.',
432 input_api.files = [MockFile(filename, contents)]
433 self.assertEqual(None,
434 PRESUBMIT._GetJSONParseError(input_api, filename))
436 def testFailure(self):
437 input_api = MockInputApi()
438 test_data = [
439 ('invalid_json_1.json',
440 ['{ x }'],
441 'Expecting property name:'),
442 ('invalid_json_2.json',
443 ['// Hello world!',
444 '{ "hello": "world }'],
445 'Unterminated string starting at:'),
446 ('invalid_json_3.json',
447 ['{ "a": "b", "c": "d", }'],
448 'Expecting property name:'),
449 ('invalid_json_4.json',
450 ['{ "a": "b" "c": "d" }'],
451 'Expecting , delimiter:'),
454 input_api.files = [MockFile(filename, contents)
455 for (filename, contents, _) in test_data]
457 for (filename, _, expected_error) in test_data:
458 actual_error = PRESUBMIT._GetJSONParseError(input_api, filename)
459 self.assertTrue(expected_error in str(actual_error),
460 "'%s' not found in '%s'" % (expected_error, actual_error))
462 def testNoEatComments(self):
463 input_api = MockInputApi()
464 file_with_comments = 'file_with_comments.json'
465 contents_with_comments = ['// This is a comment.',
466 '{',
467 ' "key1": ["value1", "value2"],',
468 ' "key2": 3 // This is an inline comment.',
471 file_without_comments = 'file_without_comments.json'
472 contents_without_comments = ['{',
473 ' "key1": ["value1", "value2"],',
474 ' "key2": 3',
477 input_api.files = [MockFile(file_with_comments, contents_with_comments),
478 MockFile(file_without_comments,
479 contents_without_comments)]
481 self.assertEqual('No JSON object could be decoded',
482 str(PRESUBMIT._GetJSONParseError(input_api,
483 file_with_comments,
484 eat_comments=False)))
485 self.assertEqual(None,
486 PRESUBMIT._GetJSONParseError(input_api,
487 file_without_comments,
488 eat_comments=False))
491 class IDLParsingTest(unittest.TestCase):
492 def testSuccess(self):
493 input_api = MockInputApi()
494 filename = 'valid_idl_basics.idl'
495 contents = ['// Tests a valid IDL file.',
496 'namespace idl_basics {',
497 ' enum EnumType {',
498 ' name1,',
499 ' name2',
500 ' };',
502 ' dictionary MyType1 {',
503 ' DOMString a;',
504 ' };',
506 ' callback Callback1 = void();',
507 ' callback Callback2 = void(long x);',
508 ' callback Callback3 = void(MyType1 arg);',
509 ' callback Callback4 = void(EnumType type);',
511 ' interface Functions {',
512 ' static void function1();',
513 ' static void function2(long x);',
514 ' static void function3(MyType1 arg);',
515 ' static void function4(Callback1 cb);',
516 ' static void function5(Callback2 cb);',
517 ' static void function6(Callback3 cb);',
518 ' static void function7(Callback4 cb);',
519 ' };',
521 ' interface Events {',
522 ' static void onFoo1();',
523 ' static void onFoo2(long x);',
524 ' static void onFoo2(MyType1 arg);',
525 ' static void onFoo3(EnumType type);',
526 ' };',
527 '};'
529 input_api.files = [MockFile(filename, contents)]
530 self.assertEqual(None,
531 PRESUBMIT._GetIDLParseError(input_api, filename))
533 def testFailure(self):
534 input_api = MockInputApi()
535 test_data = [
536 ('invalid_idl_1.idl',
537 ['//',
538 'namespace test {',
539 ' dictionary {',
540 ' DOMString s;',
541 ' };',
542 '};'],
543 'Unexpected "{" after keyword "dictionary".\n'),
544 # TODO(yoz): Disabled because it causes the IDL parser to hang.
545 # See crbug.com/363830.
546 # ('invalid_idl_2.idl',
547 # (['namespace test {',
548 # ' dictionary MissingSemicolon {',
549 # ' DOMString a',
550 # ' DOMString b;',
551 # ' };',
552 # '};'],
553 # 'Unexpected symbol DOMString after symbol a.'),
554 ('invalid_idl_3.idl',
555 ['//',
556 'namespace test {',
557 ' enum MissingComma {',
558 ' name1',
559 ' name2',
560 ' };',
561 '};'],
562 'Unexpected symbol name2 after symbol name1.'),
563 ('invalid_idl_4.idl',
564 ['//',
565 'namespace test {',
566 ' enum TrailingComma {',
567 ' name1,',
568 ' name2,',
569 ' };',
570 '};'],
571 'Trailing comma in block.'),
572 ('invalid_idl_5.idl',
573 ['//',
574 'namespace test {',
575 ' callback Callback1 = void(;',
576 '};'],
577 'Unexpected ";" after "(".'),
578 ('invalid_idl_6.idl',
579 ['//',
580 'namespace test {',
581 ' callback Callback1 = void(long );',
582 '};'],
583 'Unexpected ")" after symbol long.'),
584 ('invalid_idl_7.idl',
585 ['//',
586 'namespace test {',
587 ' interace Events {',
588 ' static void onFoo1();',
589 ' };',
590 '};'],
591 'Unexpected symbol Events after symbol interace.'),
592 ('invalid_idl_8.idl',
593 ['//',
594 'namespace test {',
595 ' interface NotEvent {',
596 ' static void onFoo1();',
597 ' };',
598 '};'],
599 'Did not process Interface Interface(NotEvent)'),
600 ('invalid_idl_9.idl',
601 ['//',
602 'namespace test {',
603 ' interface {',
604 ' static void function1();',
605 ' };',
606 '};'],
607 'Interface missing name.'),
610 input_api.files = [MockFile(filename, contents)
611 for (filename, contents, _) in test_data]
613 for (filename, _, expected_error) in test_data:
614 actual_error = PRESUBMIT._GetIDLParseError(input_api, filename)
615 self.assertTrue(expected_error in str(actual_error),
616 "'%s' not found in '%s'" % (expected_error, actual_error))
619 class TryServerMasterTest(unittest.TestCase):
620 def testTryServerMasters(self):
621 bots = {
622 'tryserver.chromium.gpu': [
623 'linux_gpu',
624 'linux_gpu_triggered_tests',
625 'win_gpu',
626 'win_gpu_triggered_tests',
628 'tryserver.chromium.mac': [
629 'ios_dbg_simulator',
630 'ios_rel_device',
631 'ios_rel_device_ninja',
632 'mac_asan',
633 'mac_asan_64',
634 'mac_chromium_compile_dbg',
635 'mac_chromium_compile_rel',
636 'mac_chromium_dbg',
637 'mac_chromium_rel',
638 'mac_nacl_sdk',
639 'mac_nacl_sdk_build',
640 'mac_rel_naclmore',
641 'mac_valgrind',
642 'mac_x64_rel',
643 'mac_xcodebuild',
645 'tryserver.chromium.linux': [
646 'android_aosp',
647 'android_chromium_gn_compile_dbg',
648 'android_chromium_gn_compile_rel',
649 'android_clang_dbg',
650 'android_dbg',
651 'android_dbg_recipe',
652 'android_dbg_triggered_tests',
653 'android_dbg_triggered_tests_recipe',
654 'android_fyi_dbg',
655 'android_fyi_dbg_triggered_tests',
656 'android_rel',
657 'android_rel_triggered_tests',
658 'android_x86_dbg',
659 'blink_android_compile_dbg',
660 'blink_android_compile_rel',
661 'blink_presubmit',
662 'chromium_presubmit',
663 'linux_arm_cross_compile',
664 'linux_arm_tester',
665 'linux_chromeos_asan',
666 'linux_chromeos_browser_asan',
667 'linux_chromeos_valgrind',
668 'linux_chromium_chromeos_dbg',
669 'linux_chromium_chromeos_rel',
670 'linux_chromium_compile_dbg',
671 'linux_chromium_compile_rel',
672 'linux_chromium_dbg',
673 'linux_chromium_gn_dbg',
674 'linux_chromium_gn_rel',
675 'linux_chromium_rel',
676 'linux_chromium_trusty32_dbg',
677 'linux_chromium_trusty32_rel',
678 'linux_chromium_trusty_dbg',
679 'linux_chromium_trusty_rel',
680 'linux_clang_tsan',
681 'linux_ecs_ozone',
682 'linux_layout',
683 'linux_layout_asan',
684 'linux_layout_rel',
685 'linux_layout_rel_32',
686 'linux_nacl_sdk',
687 'linux_nacl_sdk_bionic',
688 'linux_nacl_sdk_bionic_build',
689 'linux_nacl_sdk_build',
690 'linux_redux',
691 'linux_rel_naclmore',
692 'linux_rel_precise32',
693 'linux_valgrind',
694 'tools_build_presubmit',
696 'tryserver.chromium.win': [
697 'win8_aura',
698 'win8_chromium_dbg',
699 'win8_chromium_rel',
700 'win_chromium_compile_dbg',
701 'win_chromium_compile_rel',
702 'win_chromium_dbg',
703 'win_chromium_rel',
704 'win_chromium_rel',
705 'win_chromium_x64_dbg',
706 'win_chromium_x64_rel',
707 'win_drmemory',
708 'win_nacl_sdk',
709 'win_nacl_sdk_build',
710 'win_rel_naclmore',
713 for master, bots in bots.iteritems():
714 for bot in bots:
715 self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot),
716 'bot=%s: expected %s, computed %s' % (
717 bot, master, PRESUBMIT.GetTryServerMasterForBot(bot)))
720 if __name__ == '__main__':
721 unittest.main()