[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 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. |
| 5 | |
[email protected] | 99171a9 | 2014-06-03 08:44:47 | [diff] [blame] | 6 | import glob |
| 7 | import json |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 8 | import os |
| 9 | import re |
[email protected] | 99171a9 | 2014-06-03 08:44:47 | [diff] [blame] | 10 | import subprocess |
| 11 | import sys |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 12 | import unittest |
| 13 | |
| 14 | import PRESUBMIT |
| 15 | |
| 16 | |
[email protected] | 99171a9 | 2014-06-03 08:44:47 | [diff] [blame] | 17 | _TEST_DATA_DIR = 'base/test/data/presubmit' |
| 18 | |
| 19 | |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 20 | class MockInputApi(object): |
| 21 | def __init__(self): |
[email protected] | 99171a9 | 2014-06-03 08:44:47 | [diff] [blame] | 22 | self.json = json |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 23 | self.re = re |
| 24 | self.os_path = os.path |
[email protected] | 99171a9 | 2014-06-03 08:44:47 | [diff] [blame] | 25 | self.python_executable = sys.executable |
| 26 | self.subprocess = subprocess |
[email protected] | b8079ae4a | 2012-12-05 19:56:49 | [diff] [blame] | 27 | self.files = [] |
[email protected] | 120cf540d | 2012-12-10 17:55:53 | [diff] [blame] | 28 | self.is_committing = False |
[email protected] | b8079ae4a | 2012-12-05 19:56:49 | [diff] [blame] | 29 | |
[email protected] | e120b01 | 2014-08-15 19:08:35 | [diff] [blame] | 30 | def AffectedFiles(self, file_filter=None): |
[email protected] | b8079ae4a | 2012-12-05 19:56:49 | [diff] [blame] | 31 | return self.files |
| 32 | |
[email protected] | 99171a9 | 2014-06-03 08:44:47 | [diff] [blame] | 33 | def PresubmitLocalPath(self): |
| 34 | return os.path.dirname(__file__) |
| 35 | |
| 36 | def ReadFile(self, filename, mode='rU'): |
| 37 | for file_ in self.files: |
| 38 | if file_.LocalPath() == filename: |
| 39 | return '\n'.join(file_.NewContents()) |
| 40 | # Otherwise, file is not in our mock API. |
| 41 | raise IOError, "No such file or directory: '%s'" % filename |
| 42 | |
[email protected] | b8079ae4a | 2012-12-05 19:56:49 | [diff] [blame] | 43 | |
| 44 | class MockOutputApi(object): |
| 45 | class PresubmitResult(object): |
| 46 | def __init__(self, message, items=None, long_text=''): |
| 47 | self.message = message |
| 48 | self.items = items |
| 49 | self.long_text = long_text |
| 50 | |
| 51 | class PresubmitError(PresubmitResult): |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 52 | def __init__(self, message, items, long_text=''): |
| 53 | MockOutputApi.PresubmitResult.__init__(self, message, items, long_text) |
[email protected] | 120cf540d | 2012-12-10 17:55:53 | [diff] [blame] | 54 | self.type = 'error' |
[email protected] | b8079ae4a | 2012-12-05 19:56:49 | [diff] [blame] | 55 | |
| 56 | class PresubmitPromptWarning(PresubmitResult): |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 57 | def __init__(self, message, items, long_text=''): |
| 58 | MockOutputApi.PresubmitResult.__init__(self, message, items, long_text) |
[email protected] | 120cf540d | 2012-12-10 17:55:53 | [diff] [blame] | 59 | self.type = 'warning' |
[email protected] | b8079ae4a | 2012-12-05 19:56:49 | [diff] [blame] | 60 | |
| 61 | class PresubmitNotifyResult(PresubmitResult): |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 62 | def __init__(self, message, items, long_text=''): |
| 63 | MockOutputApi.PresubmitResult.__init__(self, message, items, long_text) |
[email protected] | 120cf540d | 2012-12-10 17:55:53 | [diff] [blame] | 64 | self.type = 'notify' |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 65 | |
[email protected] | f7051d5 | 2013-04-02 18:31:42 | [diff] [blame] | 66 | class PresubmitPromptOrNotify(PresubmitResult): |
| 67 | def __init__(self, message, items, long_text=''): |
| 68 | MockOutputApi.PresubmitResult.__init__(self, message, items, long_text) |
| 69 | self.type = 'promptOrNotify' |
| 70 | |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 71 | |
| 72 | class MockFile(object): |
| 73 | def __init__(self, local_path, new_contents): |
| 74 | self._local_path = local_path |
| 75 | self._new_contents = new_contents |
[email protected] | 70ca7775 | 2012-11-20 03:45:03 | [diff] [blame] | 76 | self._changed_contents = [(i + 1, l) for i, l in enumerate(new_contents)] |
| 77 | |
| 78 | def ChangedContents(self): |
| 79 | return self._changed_contents |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 80 | |
| 81 | def NewContents(self): |
| 82 | return self._new_contents |
| 83 | |
| 84 | def LocalPath(self): |
| 85 | return self._local_path |
| 86 | |
| 87 | |
[email protected] | 751b05f | 2013-01-10 23:12:17 | [diff] [blame] | 88 | class MockChange(object): |
| 89 | def __init__(self, changed_files): |
| 90 | self._changed_files = changed_files |
| 91 | |
| 92 | def LocalPaths(self): |
| 93 | return self._changed_files |
| 94 | |
| 95 | |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 96 | class IncludeOrderTest(unittest.TestCase): |
| 97 | def testSystemHeaderOrder(self): |
| 98 | scope = [(1, '#include <csystem.h>'), |
| 99 | (2, '#include <cppsystem>'), |
| 100 | (3, '#include "acustom.h"')] |
| 101 | all_linenums = [linenum for (linenum, _) in scope] |
| 102 | mock_input_api = MockInputApi() |
| 103 | warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api, |
| 104 | '', all_linenums) |
| 105 | self.assertEqual(0, len(warnings)) |
| 106 | |
| 107 | def testSystemHeaderOrderMismatch1(self): |
| 108 | scope = [(10, '#include <cppsystem>'), |
| 109 | (20, '#include <csystem.h>'), |
| 110 | (30, '#include "acustom.h"')] |
| 111 | all_linenums = [linenum for (linenum, _) in scope] |
| 112 | mock_input_api = MockInputApi() |
| 113 | warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api, |
| 114 | '', all_linenums) |
| 115 | self.assertEqual(1, len(warnings)) |
| 116 | self.assertTrue('20' in warnings[0]) |
| 117 | |
| 118 | def testSystemHeaderOrderMismatch2(self): |
| 119 | scope = [(10, '#include <cppsystem>'), |
| 120 | (20, '#include "acustom.h"'), |
| 121 | (30, '#include <csystem.h>')] |
| 122 | all_linenums = [linenum for (linenum, _) in scope] |
| 123 | mock_input_api = MockInputApi() |
| 124 | warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api, |
| 125 | '', all_linenums) |
| 126 | self.assertEqual(1, len(warnings)) |
| 127 | self.assertTrue('30' in warnings[0]) |
| 128 | |
| 129 | def testSystemHeaderOrderMismatch3(self): |
| 130 | scope = [(10, '#include "acustom.h"'), |
| 131 | (20, '#include <csystem.h>'), |
| 132 | (30, '#include <cppsystem>')] |
| 133 | all_linenums = [linenum for (linenum, _) in scope] |
| 134 | mock_input_api = MockInputApi() |
| 135 | warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api, |
| 136 | '', all_linenums) |
| 137 | self.assertEqual(2, len(warnings)) |
| 138 | self.assertTrue('20' in warnings[0]) |
| 139 | self.assertTrue('30' in warnings[1]) |
| 140 | |
| 141 | def testAlphabeticalOrderMismatch(self): |
| 142 | scope = [(10, '#include <csystem.h>'), |
| 143 | (15, '#include <bsystem.h>'), |
| 144 | (20, '#include <cppsystem>'), |
| 145 | (25, '#include <bppsystem>'), |
| 146 | (30, '#include "bcustom.h"'), |
| 147 | (35, '#include "acustom.h"')] |
| 148 | all_linenums = [linenum for (linenum, _) in scope] |
| 149 | mock_input_api = MockInputApi() |
| 150 | warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api, |
| 151 | '', all_linenums) |
| 152 | self.assertEqual(3, len(warnings)) |
| 153 | self.assertTrue('15' in warnings[0]) |
| 154 | self.assertTrue('25' in warnings[1]) |
| 155 | self.assertTrue('35' in warnings[2]) |
| 156 | |
| 157 | def testSpecialFirstInclude1(self): |
| 158 | mock_input_api = MockInputApi() |
| 159 | contents = ['#include "some/path/foo.h"', |
| 160 | '#include "a/header.h"'] |
| 161 | mock_file = MockFile('some/path/foo.cc', contents) |
| 162 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 163 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 164 | self.assertEqual(0, len(warnings)) |
| 165 | |
| 166 | def testSpecialFirstInclude2(self): |
| 167 | mock_input_api = MockInputApi() |
| 168 | contents = ['#include "some/other/path/foo.h"', |
| 169 | '#include "a/header.h"'] |
| 170 | mock_file = MockFile('some/path/foo.cc', contents) |
| 171 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 172 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 173 | self.assertEqual(0, len(warnings)) |
| 174 | |
| 175 | def testSpecialFirstInclude3(self): |
| 176 | mock_input_api = MockInputApi() |
| 177 | contents = ['#include "some/path/foo.h"', |
| 178 | '#include "a/header.h"'] |
| 179 | mock_file = MockFile('some/path/foo_platform.cc', contents) |
| 180 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 181 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 182 | self.assertEqual(0, len(warnings)) |
| 183 | |
| 184 | def testSpecialFirstInclude4(self): |
| 185 | mock_input_api = MockInputApi() |
| 186 | contents = ['#include "some/path/bar.h"', |
| 187 | '#include "a/header.h"'] |
| 188 | mock_file = MockFile('some/path/foo_platform.cc', contents) |
| 189 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 190 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 191 | self.assertEqual(1, len(warnings)) |
| 192 | self.assertTrue('2' in warnings[0]) |
| 193 | |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 194 | def testSpecialFirstInclude5(self): |
| 195 | mock_input_api = MockInputApi() |
| 196 | contents = ['#include "some/other/path/foo.h"', |
| 197 | '#include "a/header.h"'] |
| 198 | mock_file = MockFile('some/path/foo-suffix.h', contents) |
| 199 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
| 200 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
| 201 | self.assertEqual(0, len(warnings)) |
| 202 | |
[email protected] | 3e83618c | 2013-10-09 22:32:33 | [diff] [blame] | 203 | def testSpecialFirstInclude6(self): |
| 204 | mock_input_api = MockInputApi() |
| 205 | contents = ['#include "some/other/path/foo_win.h"', |
| 206 | '#include <set>', |
| 207 | '#include "a/header.h"'] |
| 208 | mock_file = MockFile('some/path/foo_unittest_win.h', contents) |
| 209 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
| 210 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
| 211 | self.assertEqual(0, len(warnings)) |
| 212 | |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 213 | def testOrderAlreadyWrong(self): |
| 214 | scope = [(1, '#include "b.h"'), |
| 215 | (2, '#include "a.h"'), |
| 216 | (3, '#include "c.h"')] |
| 217 | mock_input_api = MockInputApi() |
| 218 | warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api, |
| 219 | '', [3]) |
| 220 | self.assertEqual(0, len(warnings)) |
| 221 | |
| 222 | def testConflictAdded1(self): |
| 223 | scope = [(1, '#include "a.h"'), |
| 224 | (2, '#include "c.h"'), |
| 225 | (3, '#include "b.h"')] |
| 226 | mock_input_api = MockInputApi() |
| 227 | warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api, |
| 228 | '', [2]) |
| 229 | self.assertEqual(1, len(warnings)) |
| 230 | self.assertTrue('3' in warnings[0]) |
| 231 | |
| 232 | def testConflictAdded2(self): |
| 233 | scope = [(1, '#include "c.h"'), |
| 234 | (2, '#include "b.h"'), |
| 235 | (3, '#include "d.h"')] |
| 236 | mock_input_api = MockInputApi() |
| 237 | warnings = PRESUBMIT._CheckIncludeOrderForScope(scope, mock_input_api, |
| 238 | '', [2]) |
| 239 | self.assertEqual(1, len(warnings)) |
| 240 | self.assertTrue('2' in warnings[0]) |
| 241 | |
[email protected] | 2309b0fa0 | 2012-11-16 12:18:27 | [diff] [blame] | 242 | def testIfElifElseEndif(self): |
| 243 | mock_input_api = MockInputApi() |
| 244 | contents = ['#include "e.h"', |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 245 | '#define foo', |
| 246 | '#include "f.h"', |
| 247 | '#undef foo', |
| 248 | '#include "e.h"', |
[email protected] | 2309b0fa0 | 2012-11-16 12:18:27 | [diff] [blame] | 249 | '#if foo', |
| 250 | '#include "d.h"', |
| 251 | '#elif bar', |
| 252 | '#include "c.h"', |
| 253 | '#else', |
| 254 | '#include "b.h"', |
| 255 | '#endif', |
| 256 | '#include "a.h"'] |
| 257 | mock_file = MockFile('', contents) |
| 258 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 259 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
[email protected] | 2309b0fa0 | 2012-11-16 12:18:27 | [diff] [blame] | 260 | self.assertEqual(0, len(warnings)) |
| 261 | |
[email protected] | 23093b6 | 2013-09-20 12:16:30 | [diff] [blame] | 262 | def testExcludedIncludes(self): |
[email protected] | 962f117e | 2012-11-22 18:11:56 | [diff] [blame] | 263 | # #include <sys/...>'s can appear in any order. |
| 264 | mock_input_api = MockInputApi() |
| 265 | contents = ['#include <sys/b.h>', |
| 266 | '#include <sys/a.h>'] |
| 267 | mock_file = MockFile('', contents) |
| 268 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 269 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
[email protected] | 962f117e | 2012-11-22 18:11:56 | [diff] [blame] | 270 | self.assertEqual(0, len(warnings)) |
| 271 | |
[email protected] | 23093b6 | 2013-09-20 12:16:30 | [diff] [blame] | 272 | contents = ['#include <atlbase.h>', |
| 273 | '#include <aaa.h>'] |
| 274 | mock_file = MockFile('', contents) |
| 275 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
| 276 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
| 277 | self.assertEqual(0, len(warnings)) |
| 278 | |
| 279 | contents = ['#include "build/build_config.h"', |
| 280 | '#include "aaa.h"'] |
| 281 | mock_file = MockFile('', contents) |
| 282 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
| 283 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
| 284 | self.assertEqual(0, len(warnings)) |
| 285 | |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 286 | def testCheckOnlyCFiles(self): |
| 287 | mock_input_api = MockInputApi() |
| 288 | mock_output_api = MockOutputApi() |
| 289 | contents = ['#include <b.h>', |
| 290 | '#include <a.h>'] |
| 291 | mock_file_cc = MockFile('something.cc', contents) |
| 292 | mock_file_h = MockFile('something.h', contents) |
| 293 | mock_file_other = MockFile('something.py', contents) |
| 294 | mock_input_api.files = [mock_file_cc, mock_file_h, mock_file_other] |
| 295 | warnings = PRESUBMIT._CheckIncludeOrder(mock_input_api, mock_output_api) |
| 296 | self.assertEqual(1, len(warnings)) |
| 297 | self.assertEqual(2, len(warnings[0].items)) |
[email protected] | f7051d5 | 2013-04-02 18:31:42 | [diff] [blame] | 298 | self.assertEqual('promptOrNotify', warnings[0].type) |
[email protected] | ac294a1 | 2012-12-06 16:38:43 | [diff] [blame] | 299 | |
[email protected] | 0e5c185 | 2012-12-18 20:17:11 | [diff] [blame] | 300 | def testUncheckableIncludes(self): |
| 301 | mock_input_api = MockInputApi() |
| 302 | contents = ['#include <windows.h>', |
[email protected] | 4436c9e | 2014-01-07 23:19:54 | [diff] [blame] | 303 | '#include "b.h"', |
[email protected] | 0e5c185 | 2012-12-18 20:17:11 | [diff] [blame] | 304 | '#include "a.h"'] |
| 305 | mock_file = MockFile('', contents) |
| 306 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
| 307 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
[email protected] | 4436c9e | 2014-01-07 23:19:54 | [diff] [blame] | 308 | self.assertEqual(1, len(warnings)) |
[email protected] | 0e5c185 | 2012-12-18 20:17:11 | [diff] [blame] | 309 | |
| 310 | contents = ['#include "gpu/command_buffer/gles_autogen.h"', |
[email protected] | 4436c9e | 2014-01-07 23:19:54 | [diff] [blame] | 311 | '#include "b.h"', |
[email protected] | 0e5c185 | 2012-12-18 20:17:11 | [diff] [blame] | 312 | '#include "a.h"'] |
| 313 | mock_file = MockFile('', contents) |
| 314 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
| 315 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
[email protected] | 4436c9e | 2014-01-07 23:19:54 | [diff] [blame] | 316 | self.assertEqual(1, len(warnings)) |
[email protected] | 0e5c185 | 2012-12-18 20:17:11 | [diff] [blame] | 317 | |
| 318 | contents = ['#include "gl_mock_autogen.h"', |
[email protected] | 4436c9e | 2014-01-07 23:19:54 | [diff] [blame] | 319 | '#include "b.h"', |
[email protected] | 0e5c185 | 2012-12-18 20:17:11 | [diff] [blame] | 320 | '#include "a.h"'] |
| 321 | mock_file = MockFile('', contents) |
| 322 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
| 323 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
[email protected] | 4436c9e | 2014-01-07 23:19:54 | [diff] [blame] | 324 | self.assertEqual(1, len(warnings)) |
[email protected] | 0e5c185 | 2012-12-18 20:17:11 | [diff] [blame] | 325 | |
| 326 | contents = ['#include "ipc/some_macros.h"', |
[email protected] | 4436c9e | 2014-01-07 23:19:54 | [diff] [blame] | 327 | '#include "b.h"', |
[email protected] | 0e5c185 | 2012-12-18 20:17:11 | [diff] [blame] | 328 | '#include "a.h"'] |
| 329 | mock_file = MockFile('', contents) |
| 330 | warnings = PRESUBMIT._CheckIncludeOrderInFile( |
| 331 | mock_input_api, mock_file, range(1, len(contents) + 1)) |
[email protected] | 4436c9e | 2014-01-07 23:19:54 | [diff] [blame] | 332 | self.assertEqual(1, len(warnings)) |
[email protected] | 0e5c185 | 2012-12-18 20:17:11 | [diff] [blame] | 333 | |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 334 | |
[email protected] | b00342e7f | 2013-03-26 16:21:54 | [diff] [blame] | 335 | class VersionControlConflictsTest(unittest.TestCase): |
[email protected] | 70ca7775 | 2012-11-20 03:45:03 | [diff] [blame] | 336 | def testTypicalConflict(self): |
| 337 | lines = ['<<<<<<< HEAD', |
| 338 | ' base::ScopedTempDir temp_dir_;', |
| 339 | '=======', |
| 340 | ' ScopedTempDir temp_dir_;', |
| 341 | '>>>>>>> master'] |
| 342 | errors = PRESUBMIT._CheckForVersionControlConflictsInFile( |
| 343 | MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) |
| 344 | self.assertEqual(3, len(errors)) |
| 345 | self.assertTrue('1' in errors[0]) |
| 346 | self.assertTrue('3' in errors[1]) |
| 347 | self.assertTrue('5' in errors[2]) |
| 348 | |
mcasas | 2ece5270 | 2014-12-02 15:37:23 | [diff] [blame] | 349 | class UmaHistogramChangeMatchedOrNotTest(unittest.TestCase): |
| 350 | def testTypicalNotMatchedChange(self): |
| 351 | diff = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)'] |
| 352 | mock_input_api = MockInputApi() |
| 353 | mock_input_api.files = [MockFile('some/path/foo.cc', diff)] |
| 354 | warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api, |
| 355 | MockOutputApi()) |
| 356 | self.assertEqual(1, len(warnings)) |
| 357 | self.assertEqual('warning', warnings[0].type) |
| 358 | |
| 359 | def testTypicalCorrectlyMatchedChange(self): |
| 360 | diff_cc = ['UMA_HISTOGRAM_BOOL("Bla.Foo.Dummy", true)'] |
| 361 | diff_xml = ['<histogram name="Bla.Foo.Dummy"> </histogram>'] |
| 362 | mock_input_api = MockInputApi() |
| 363 | mock_input_api.files = [ |
| 364 | MockFile('some/path/foo.cc', diff_cc), |
| 365 | MockFile('tools/metrics/histograms/histograms.xml', diff_xml), |
| 366 | ] |
| 367 | warnings = [] |
| 368 | warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api, |
| 369 | MockOutputApi()) |
| 370 | self.assertEqual(0, len(warnings)) |
[email protected] | 70ca7775 | 2012-11-20 03:45:03 | [diff] [blame] | 371 | |
[email protected] | b8079ae4a | 2012-12-05 19:56:49 | [diff] [blame] | 372 | class BadExtensionsTest(unittest.TestCase): |
| 373 | def testBadRejFile(self): |
| 374 | mock_input_api = MockInputApi() |
| 375 | mock_input_api.files = [ |
| 376 | MockFile('some/path/foo.cc', ''), |
| 377 | MockFile('some/path/foo.cc.rej', ''), |
| 378 | MockFile('some/path2/bar.h.rej', ''), |
| 379 | ] |
| 380 | |
| 381 | results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi()) |
| 382 | self.assertEqual(1, len(results)) |
| 383 | self.assertEqual(2, len(results[0].items)) |
| 384 | self.assertTrue('foo.cc.rej' in results[0].items[0]) |
| 385 | self.assertTrue('bar.h.rej' in results[0].items[1]) |
| 386 | |
| 387 | def testBadOrigFile(self): |
| 388 | mock_input_api = MockInputApi() |
| 389 | mock_input_api.files = [ |
| 390 | MockFile('other/path/qux.h.orig', ''), |
| 391 | MockFile('other/path/qux.h', ''), |
| 392 | MockFile('other/path/qux.cc', ''), |
| 393 | ] |
| 394 | |
| 395 | results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi()) |
| 396 | self.assertEqual(1, len(results)) |
| 397 | self.assertEqual(1, len(results[0].items)) |
| 398 | self.assertTrue('qux.h.orig' in results[0].items[0]) |
| 399 | |
| 400 | def testGoodFiles(self): |
| 401 | mock_input_api = MockInputApi() |
| 402 | mock_input_api.files = [ |
| 403 | MockFile('other/path/qux.h', ''), |
| 404 | MockFile('other/path/qux.cc', ''), |
| 405 | ] |
| 406 | results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi()) |
| 407 | self.assertEqual(0, len(results)) |
| 408 | |
[email protected] | 751b05f | 2013-01-10 23:12:17 | [diff] [blame] | 409 | def testOnlyOwnersFiles(self): |
| 410 | mock_change = MockChange([ |
| 411 | 'some/path/OWNERS', |
| 412 | 'A\Windows\Path\OWNERS', |
| 413 | ]) |
[email protected] | 7468ac52 | 2014-03-12 23:35:57 | [diff] [blame] | 414 | results = PRESUBMIT.GetPreferredTryMasters(None, mock_change) |
| 415 | self.assertEqual({}, results) |
[email protected] | 751b05f | 2013-01-10 23:12:17 | [diff] [blame] | 416 | |
[email protected] | b8079ae4a | 2012-12-05 19:56:49 | [diff] [blame] | 417 | |
[email protected] | b00342e7f | 2013-03-26 16:21:54 | [diff] [blame] | 418 | class InvalidOSMacroNamesTest(unittest.TestCase): |
| 419 | def testInvalidOSMacroNames(self): |
| 420 | lines = ['#if defined(OS_WINDOWS)', |
| 421 | ' #elif defined(OS_WINDOW)', |
| 422 | ' # if defined(OS_MACOSX) || defined(OS_CHROME)', |
| 423 | '# else // defined(OS_MAC)', |
| 424 | '#endif // defined(OS_MACOS)'] |
| 425 | errors = PRESUBMIT._CheckForInvalidOSMacrosInFile( |
| 426 | MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) |
| 427 | self.assertEqual(len(lines), len(errors)) |
| 428 | self.assertTrue(':1 OS_WINDOWS' in errors[0]) |
| 429 | self.assertTrue('(did you mean OS_WIN?)' in errors[0]) |
| 430 | |
| 431 | def testValidOSMacroNames(self): |
| 432 | lines = ['#if defined(%s)' % m for m in PRESUBMIT._VALID_OS_MACROS] |
| 433 | errors = PRESUBMIT._CheckForInvalidOSMacrosInFile( |
| 434 | MockInputApi(), MockFile('some/path/foo_platform.cc', lines)) |
| 435 | self.assertEqual(0, len(errors)) |
| 436 | |
| 437 | |
lliabraa | 35bab393 | 2014-10-01 12:16:44 | [diff] [blame] | 438 | class InvalidIfDefinedMacroNamesTest(unittest.TestCase): |
| 439 | def testInvalidIfDefinedMacroNames(self): |
| 440 | lines = ['#if defined(TARGET_IPHONE_SIMULATOR)', |
| 441 | '#if !defined(TARGET_IPHONE_SIMULATOR)', |
| 442 | '#elif defined(TARGET_IPHONE_SIMULATOR)', |
| 443 | '#ifdef TARGET_IPHONE_SIMULATOR', |
| 444 | ' # ifdef TARGET_IPHONE_SIMULATOR', |
| 445 | '# if defined(VALID) || defined(TARGET_IPHONE_SIMULATOR)', |
| 446 | '# else // defined(TARGET_IPHONE_SIMULATOR)', |
| 447 | '#endif // defined(TARGET_IPHONE_SIMULATOR)',] |
| 448 | errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile( |
| 449 | MockInputApi(), MockFile('some/path/source.mm', lines)) |
| 450 | self.assertEqual(len(lines), len(errors)) |
| 451 | |
| 452 | def testValidIfDefinedMacroNames(self): |
| 453 | lines = ['#if defined(FOO)', |
| 454 | '#ifdef BAR',] |
| 455 | errors = PRESUBMIT._CheckForInvalidIfDefinedMacrosInFile( |
| 456 | MockInputApi(), MockFile('some/path/source.cc', lines)) |
| 457 | self.assertEqual(0, len(errors)) |
| 458 | |
| 459 | |
[email protected] | f32e2d1e | 2013-07-26 21:39:08 | [diff] [blame] | 460 | class CheckAddedDepsHaveTetsApprovalsTest(unittest.TestCase): |
[email protected] | 14a6131c | 2014-01-08 01:15:41 | [diff] [blame] | 461 | def testFilesToCheckForIncomingDeps(self): |
[email protected] | f32e2d1e | 2013-07-26 21:39:08 | [diff] [blame] | 462 | changed_lines = [ |
| 463 | '"+breakpad",', |
| 464 | '"+chrome/installer",', |
| 465 | '"+chrome/plugin/chrome_content_plugin_client.h",', |
| 466 | '"+chrome/utility/chrome_content_utility_client.h",', |
| 467 | '"+chromeos/chromeos_paths.h",', |
philipj | 3f9d5bde | 2014-08-28 14:09:09 | [diff] [blame] | 468 | '"+components/crash",', |
[email protected] | f32e2d1e | 2013-07-26 21:39:08 | [diff] [blame] | 469 | '"+components/nacl/common",', |
| 470 | '"+content/public/browser/render_process_host.h",', |
[email protected] | 14a6131c | 2014-01-08 01:15:41 | [diff] [blame] | 471 | '"+jni/fooblat.h",', |
[email protected] | f32e2d1e | 2013-07-26 21:39:08 | [diff] [blame] | 472 | '"+grit", # For generated headers', |
| 473 | '"+grit/generated_resources.h",', |
| 474 | '"+grit/",', |
| 475 | '"+policy", # For generated headers and source', |
| 476 | '"+sandbox",', |
| 477 | '"+tools/memory_watcher",', |
| 478 | '"+third_party/lss/linux_syscall_support.h",', |
| 479 | ] |
[email protected] | 14a6131c | 2014-01-08 01:15:41 | [diff] [blame] | 480 | files_to_check = PRESUBMIT._FilesToCheckForIncomingDeps(re, changed_lines) |
[email protected] | f32e2d1e | 2013-07-26 21:39:08 | [diff] [blame] | 481 | expected = set([ |
| 482 | 'breakpad/DEPS', |
| 483 | 'chrome/installer/DEPS', |
[email protected] | 14a6131c | 2014-01-08 01:15:41 | [diff] [blame] | 484 | 'chrome/plugin/chrome_content_plugin_client.h', |
| 485 | 'chrome/utility/chrome_content_utility_client.h', |
| 486 | 'chromeos/chromeos_paths.h', |
Robert Sesek | abcd810 | 2014-08-27 16:12:44 | [diff] [blame] | 487 | 'components/crash/DEPS', |
[email protected] | f32e2d1e | 2013-07-26 21:39:08 | [diff] [blame] | 488 | 'components/nacl/common/DEPS', |
[email protected] | 14a6131c | 2014-01-08 01:15:41 | [diff] [blame] | 489 | 'content/public/browser/render_process_host.h', |
[email protected] | f32e2d1e | 2013-07-26 21:39:08 | [diff] [blame] | 490 | 'policy/DEPS', |
| 491 | 'sandbox/DEPS', |
| 492 | 'tools/memory_watcher/DEPS', |
[email protected] | 14a6131c | 2014-01-08 01:15:41 | [diff] [blame] | 493 | 'third_party/lss/linux_syscall_support.h', |
[email protected] | f32e2d1e | 2013-07-26 21:39:08 | [diff] [blame] | 494 | ]) |
| 495 | self.assertEqual(expected, files_to_check); |
| 496 | |
| 497 | |
[email protected] | 99171a9 | 2014-06-03 08:44:47 | [diff] [blame] | 498 | class JSONParsingTest(unittest.TestCase): |
| 499 | def testSuccess(self): |
| 500 | input_api = MockInputApi() |
| 501 | filename = 'valid_json.json' |
| 502 | contents = ['// This is a comment.', |
| 503 | '{', |
| 504 | ' "key1": ["value1", "value2"],', |
| 505 | ' "key2": 3 // This is an inline comment.', |
| 506 | '}' |
| 507 | ] |
| 508 | input_api.files = [MockFile(filename, contents)] |
| 509 | self.assertEqual(None, |
| 510 | PRESUBMIT._GetJSONParseError(input_api, filename)) |
| 511 | |
| 512 | def testFailure(self): |
| 513 | input_api = MockInputApi() |
| 514 | test_data = [ |
| 515 | ('invalid_json_1.json', |
| 516 | ['{ x }'], |
[email protected] | a334327 | 2014-06-17 11:41:53 | [diff] [blame] | 517 | 'Expecting property name:'), |
[email protected] | 99171a9 | 2014-06-03 08:44:47 | [diff] [blame] | 518 | ('invalid_json_2.json', |
| 519 | ['// Hello world!', |
| 520 | '{ "hello": "world }'], |
[email protected] | a334327 | 2014-06-17 11:41:53 | [diff] [blame] | 521 | 'Unterminated string starting at:'), |
[email protected] | 99171a9 | 2014-06-03 08:44:47 | [diff] [blame] | 522 | ('invalid_json_3.json', |
| 523 | ['{ "a": "b", "c": "d", }'], |
[email protected] | a334327 | 2014-06-17 11:41:53 | [diff] [blame] | 524 | 'Expecting property name:'), |
[email protected] | 99171a9 | 2014-06-03 08:44:47 | [diff] [blame] | 525 | ('invalid_json_4.json', |
| 526 | ['{ "a": "b" "c": "d" }'], |
[email protected] | a334327 | 2014-06-17 11:41:53 | [diff] [blame] | 527 | 'Expecting , delimiter:'), |
[email protected] | 99171a9 | 2014-06-03 08:44:47 | [diff] [blame] | 528 | ] |
| 529 | |
| 530 | input_api.files = [MockFile(filename, contents) |
| 531 | for (filename, contents, _) in test_data] |
| 532 | |
| 533 | for (filename, _, expected_error) in test_data: |
| 534 | actual_error = PRESUBMIT._GetJSONParseError(input_api, filename) |
[email protected] | a334327 | 2014-06-17 11:41:53 | [diff] [blame] | 535 | self.assertTrue(expected_error in str(actual_error), |
| 536 | "'%s' not found in '%s'" % (expected_error, actual_error)) |
[email protected] | 99171a9 | 2014-06-03 08:44:47 | [diff] [blame] | 537 | |
| 538 | def testNoEatComments(self): |
| 539 | input_api = MockInputApi() |
| 540 | file_with_comments = 'file_with_comments.json' |
| 541 | contents_with_comments = ['// This is a comment.', |
| 542 | '{', |
| 543 | ' "key1": ["value1", "value2"],', |
| 544 | ' "key2": 3 // This is an inline comment.', |
| 545 | '}' |
| 546 | ] |
| 547 | file_without_comments = 'file_without_comments.json' |
| 548 | contents_without_comments = ['{', |
| 549 | ' "key1": ["value1", "value2"],', |
| 550 | ' "key2": 3', |
| 551 | '}' |
| 552 | ] |
| 553 | input_api.files = [MockFile(file_with_comments, contents_with_comments), |
| 554 | MockFile(file_without_comments, |
| 555 | contents_without_comments)] |
| 556 | |
| 557 | self.assertEqual('No JSON object could be decoded', |
| 558 | str(PRESUBMIT._GetJSONParseError(input_api, |
| 559 | file_with_comments, |
| 560 | eat_comments=False))) |
| 561 | self.assertEqual(None, |
| 562 | PRESUBMIT._GetJSONParseError(input_api, |
| 563 | file_without_comments, |
| 564 | eat_comments=False)) |
| 565 | |
| 566 | |
| 567 | class IDLParsingTest(unittest.TestCase): |
| 568 | def testSuccess(self): |
| 569 | input_api = MockInputApi() |
| 570 | filename = 'valid_idl_basics.idl' |
| 571 | contents = ['// Tests a valid IDL file.', |
| 572 | 'namespace idl_basics {', |
| 573 | ' enum EnumType {', |
| 574 | ' name1,', |
| 575 | ' name2', |
| 576 | ' };', |
| 577 | '', |
| 578 | ' dictionary MyType1 {', |
| 579 | ' DOMString a;', |
| 580 | ' };', |
| 581 | '', |
| 582 | ' callback Callback1 = void();', |
| 583 | ' callback Callback2 = void(long x);', |
| 584 | ' callback Callback3 = void(MyType1 arg);', |
| 585 | ' callback Callback4 = void(EnumType type);', |
| 586 | '', |
| 587 | ' interface Functions {', |
| 588 | ' static void function1();', |
| 589 | ' static void function2(long x);', |
| 590 | ' static void function3(MyType1 arg);', |
| 591 | ' static void function4(Callback1 cb);', |
| 592 | ' static void function5(Callback2 cb);', |
| 593 | ' static void function6(Callback3 cb);', |
| 594 | ' static void function7(Callback4 cb);', |
| 595 | ' };', |
| 596 | '', |
| 597 | ' interface Events {', |
| 598 | ' static void onFoo1();', |
| 599 | ' static void onFoo2(long x);', |
| 600 | ' static void onFoo2(MyType1 arg);', |
| 601 | ' static void onFoo3(EnumType type);', |
| 602 | ' };', |
| 603 | '};' |
| 604 | ] |
| 605 | input_api.files = [MockFile(filename, contents)] |
| 606 | self.assertEqual(None, |
| 607 | PRESUBMIT._GetIDLParseError(input_api, filename)) |
| 608 | |
| 609 | def testFailure(self): |
| 610 | input_api = MockInputApi() |
| 611 | test_data = [ |
| 612 | ('invalid_idl_1.idl', |
| 613 | ['//', |
| 614 | 'namespace test {', |
| 615 | ' dictionary {', |
| 616 | ' DOMString s;', |
| 617 | ' };', |
| 618 | '};'], |
| 619 | 'Unexpected "{" after keyword "dictionary".\n'), |
| 620 | # TODO(yoz): Disabled because it causes the IDL parser to hang. |
| 621 | # See crbug.com/363830. |
| 622 | # ('invalid_idl_2.idl', |
| 623 | # (['namespace test {', |
| 624 | # ' dictionary MissingSemicolon {', |
| 625 | # ' DOMString a', |
| 626 | # ' DOMString b;', |
| 627 | # ' };', |
| 628 | # '};'], |
| 629 | # 'Unexpected symbol DOMString after symbol a.'), |
| 630 | ('invalid_idl_3.idl', |
| 631 | ['//', |
| 632 | 'namespace test {', |
| 633 | ' enum MissingComma {', |
| 634 | ' name1', |
| 635 | ' name2', |
| 636 | ' };', |
| 637 | '};'], |
| 638 | 'Unexpected symbol name2 after symbol name1.'), |
| 639 | ('invalid_idl_4.idl', |
| 640 | ['//', |
| 641 | 'namespace test {', |
| 642 | ' enum TrailingComma {', |
| 643 | ' name1,', |
| 644 | ' name2,', |
| 645 | ' };', |
| 646 | '};'], |
| 647 | 'Trailing comma in block.'), |
| 648 | ('invalid_idl_5.idl', |
| 649 | ['//', |
| 650 | 'namespace test {', |
| 651 | ' callback Callback1 = void(;', |
| 652 | '};'], |
| 653 | 'Unexpected ";" after "(".'), |
| 654 | ('invalid_idl_6.idl', |
| 655 | ['//', |
| 656 | 'namespace test {', |
| 657 | ' callback Callback1 = void(long );', |
| 658 | '};'], |
| 659 | 'Unexpected ")" after symbol long.'), |
| 660 | ('invalid_idl_7.idl', |
| 661 | ['//', |
| 662 | 'namespace test {', |
| 663 | ' interace Events {', |
| 664 | ' static void onFoo1();', |
| 665 | ' };', |
| 666 | '};'], |
| 667 | 'Unexpected symbol Events after symbol interace.'), |
| 668 | ('invalid_idl_8.idl', |
| 669 | ['//', |
| 670 | 'namespace test {', |
| 671 | ' interface NotEvent {', |
| 672 | ' static void onFoo1();', |
| 673 | ' };', |
| 674 | '};'], |
| 675 | 'Did not process Interface Interface(NotEvent)'), |
| 676 | ('invalid_idl_9.idl', |
| 677 | ['//', |
| 678 | 'namespace test {', |
| 679 | ' interface {', |
| 680 | ' static void function1();', |
| 681 | ' };', |
| 682 | '};'], |
| 683 | 'Interface missing name.'), |
| 684 | ] |
| 685 | |
| 686 | input_api.files = [MockFile(filename, contents) |
| 687 | for (filename, contents, _) in test_data] |
| 688 | |
| 689 | for (filename, _, expected_error) in test_data: |
| 690 | actual_error = PRESUBMIT._GetIDLParseError(input_api, filename) |
| 691 | self.assertTrue(expected_error in str(actual_error), |
| 692 | "'%s' not found in '%s'" % (expected_error, actual_error)) |
| 693 | |
| 694 | |
[email protected] | 0bb11236 | 2014-07-26 04:38:32 | [diff] [blame] | 695 | class TryServerMasterTest(unittest.TestCase): |
| 696 | def testTryServerMasters(self): |
| 697 | bots = { |
| 698 | 'tryserver.chromium.gpu': [ |
| 699 | 'mac_gpu', |
| 700 | 'mac_gpu_triggered_tests', |
| 701 | 'linux_gpu', |
| 702 | 'linux_gpu_triggered_tests', |
| 703 | 'win_gpu', |
| 704 | 'win_gpu_triggered_tests', |
| 705 | ], |
| 706 | 'tryserver.chromium.mac': [ |
| 707 | 'ios_dbg_simulator', |
| 708 | 'ios_rel_device', |
| 709 | 'ios_rel_device_ninja', |
| 710 | 'mac_asan', |
| 711 | 'mac_asan_64', |
| 712 | 'mac_chromium_compile_dbg', |
| 713 | 'mac_chromium_compile_rel', |
| 714 | 'mac_chromium_dbg', |
| 715 | 'mac_chromium_rel', |
[email protected] | 0bb11236 | 2014-07-26 04:38:32 | [diff] [blame] | 716 | 'mac_nacl_sdk', |
| 717 | 'mac_nacl_sdk_build', |
| 718 | 'mac_rel_naclmore', |
| 719 | 'mac_valgrind', |
| 720 | 'mac_x64_rel', |
| 721 | 'mac_xcodebuild', |
| 722 | ], |
| 723 | 'tryserver.chromium.linux': [ |
| 724 | 'android_aosp', |
| 725 | 'android_chromium_gn_compile_dbg', |
| 726 | 'android_chromium_gn_compile_rel', |
| 727 | 'android_clang_dbg', |
| 728 | 'android_dbg', |
| 729 | 'android_dbg_recipe', |
| 730 | 'android_dbg_triggered_tests', |
| 731 | 'android_dbg_triggered_tests_recipe', |
| 732 | 'android_fyi_dbg', |
| 733 | 'android_fyi_dbg_triggered_tests', |
| 734 | 'android_rel', |
| 735 | 'android_rel_triggered_tests', |
| 736 | 'android_x86_dbg', |
| 737 | 'blink_android_compile_dbg', |
| 738 | 'blink_android_compile_rel', |
| 739 | 'blink_presubmit', |
| 740 | 'chromium_presubmit', |
| 741 | 'linux_arm_cross_compile', |
| 742 | 'linux_arm_tester', |
[email protected] | 0bb11236 | 2014-07-26 04:38:32 | [diff] [blame] | 743 | 'linux_chromeos_asan', |
| 744 | 'linux_chromeos_browser_asan', |
| 745 | 'linux_chromeos_valgrind', |
[email protected] | 0bb11236 | 2014-07-26 04:38:32 | [diff] [blame] | 746 | 'linux_chromium_chromeos_dbg', |
| 747 | 'linux_chromium_chromeos_rel', |
[email protected] | 0bb11236 | 2014-07-26 04:38:32 | [diff] [blame] | 748 | 'linux_chromium_compile_dbg', |
| 749 | 'linux_chromium_compile_rel', |
| 750 | 'linux_chromium_dbg', |
| 751 | 'linux_chromium_gn_dbg', |
| 752 | 'linux_chromium_gn_rel', |
| 753 | 'linux_chromium_rel', |
[email protected] | 0bb11236 | 2014-07-26 04:38:32 | [diff] [blame] | 754 | 'linux_chromium_trusty32_dbg', |
| 755 | 'linux_chromium_trusty32_rel', |
| 756 | 'linux_chromium_trusty_dbg', |
| 757 | 'linux_chromium_trusty_rel', |
| 758 | 'linux_clang_tsan', |
| 759 | 'linux_ecs_ozone', |
| 760 | 'linux_layout', |
| 761 | 'linux_layout_asan', |
| 762 | 'linux_layout_rel', |
| 763 | 'linux_layout_rel_32', |
| 764 | 'linux_nacl_sdk', |
| 765 | 'linux_nacl_sdk_bionic', |
| 766 | 'linux_nacl_sdk_bionic_build', |
| 767 | 'linux_nacl_sdk_build', |
| 768 | 'linux_redux', |
| 769 | 'linux_rel_naclmore', |
| 770 | 'linux_rel_precise32', |
| 771 | 'linux_valgrind', |
| 772 | 'tools_build_presubmit', |
| 773 | ], |
| 774 | 'tryserver.chromium.win': [ |
| 775 | 'win8_aura', |
| 776 | 'win8_chromium_dbg', |
| 777 | 'win8_chromium_rel', |
| 778 | 'win_chromium_compile_dbg', |
| 779 | 'win_chromium_compile_rel', |
| 780 | 'win_chromium_dbg', |
| 781 | 'win_chromium_rel', |
| 782 | 'win_chromium_rel', |
[email protected] | 0bb11236 | 2014-07-26 04:38:32 | [diff] [blame] | 783 | 'win_chromium_x64_dbg', |
| 784 | 'win_chromium_x64_rel', |
| 785 | 'win_drmemory', |
| 786 | 'win_nacl_sdk', |
| 787 | 'win_nacl_sdk_build', |
| 788 | 'win_rel_naclmore', |
| 789 | ], |
| 790 | } |
| 791 | for master, bots in bots.iteritems(): |
| 792 | for bot in bots: |
| 793 | self.assertEqual(master, PRESUBMIT.GetTryServerMasterForBot(bot), |
| 794 | 'bot=%s: expected %s, computed %s' % ( |
| 795 | bot, master, PRESUBMIT.GetTryServerMasterForBot(bot))) |
| 796 | |
| 797 | |
[email protected] | 2299dcf | 2012-11-15 19:56:24 | [diff] [blame] | 798 | if __name__ == '__main__': |
| 799 | unittest.main() |