| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import argparse | 5 import argparse |
| 6 import datetime | 6 import datetime |
| 7 import difflib |
| 7 import random | 8 import random |
| 8 import re | 9 import re |
| 9 import urllib | 10 import urllib |
| 10 | 11 |
| 11 from builders import iter_builders | 12 from builders import iter_builders |
| 12 from recipe_engine.types import freeze | 13 from recipe_engine.types import freeze |
| 13 from recipe_engine import recipe_api | 14 from recipe_engine import recipe_api |
| 14 from . import bisection | 15 from . import bisection |
| 15 from . import builders | 16 from . import builders |
| 16 from . import testing | 17 from . import testing |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 if tests_to_isolate: | 401 if tests_to_isolate: |
| 401 self.m.isolate.isolate_tests( | 402 self.m.isolate.isolate_tests( |
| 402 self.m.chromium.output_dir, | 403 self.m.chromium.output_dir, |
| 403 targets=sorted(list(set(tests_to_isolate))), | 404 targets=sorted(list(set(tests_to_isolate))), |
| 404 verbose=True, | 405 verbose=True, |
| 405 set_swarm_hashes=False, | 406 set_swarm_hashes=False, |
| 406 ) | 407 ) |
| 407 if self.should_upload_build: | 408 if self.should_upload_build: |
| 408 self.upload_isolated_json() | 409 self.upload_isolated_json() |
| 409 | 410 |
| 411 def _compare_gyp_defines(self, mb_output): |
| 412 """Compare infra gyp flags with client gyp flags. |
| 413 |
| 414 Returns the difference as a list of strings or an empty list if there is |
| 415 none. |
| 416 """ |
| 417 |
| 418 def gyp_defines_to_dict(gyp_defines): |
| 419 return dict(tuple(x.split('=', 1)) for x in gyp_defines.split()) |
| 420 |
| 421 infra_flags = gyp_defines_to_dict( |
| 422 self.m.chromium.c.gyp_env.as_jsonish()['GYP_DEFINES']) |
| 423 |
| 424 # Get the client's gyp flags from MB's output. |
| 425 match = re.search('^GYP_DEFINES=\'(.*)\'$', mb_output, re.M) |
| 426 |
| 427 # This won't match in the gn case. |
| 428 if match: |
| 429 client_flags = gyp_defines_to_dict(match.group(1)) |
| 430 |
| 431 # Tweak both dictionaries for known differences. |
| 432 if infra_flags.get('target_arch') == infra_flags.get('v8_target_arch'): |
| 433 # We drop the default case target_arch==v8_target_arch in MB and |
| 434 # only specify target_arch. |
| 435 infra_flags.pop('v8_target_arch') # pragma: no cover |
| 436 |
| 437 if 'jsfunfuzz' in infra_flags: |
| 438 # This is for runhooks only. Not used in MB. |
| 439 infra_flags.pop('jsfunfuzz') # pragma: no cover |
| 440 |
| 441 if not 'component' in infra_flags and 'component' in client_flags: |
| 442 # We make this explicit with MB but used the default without. Only |
| 443 # compare if we specified it explicitly in the infrastructure. |
| 444 client_flags.pop('component') # pragma: no cover |
| 445 |
| 446 if infra_flags != client_flags: |
| 447 to_str = lambda x: sorted('%s: %s' % kv for kv in x.iteritems()) |
| 448 return list(difflib.ndiff(to_str(infra_flags), to_str(client_flags))) |
| 449 return [] # pragma: no cover |
| 450 |
| 410 def compile(self, **kwargs): | 451 def compile(self, **kwargs): |
| 411 if self.m.chromium.c.project_generator.tool == 'mb': | 452 if self.m.chromium.c.project_generator.tool == 'mb': |
| 412 use_goma = (self.m.chromium.c.compile_py.compiler and | 453 use_goma = (self.m.chromium.c.compile_py.compiler and |
| 413 'goma' in self.m.chromium.c.compile_py.compiler) | 454 'goma' in self.m.chromium.c.compile_py.compiler) |
| 455 def step_test_data(): |
| 456 # Fake gyp flags. In the expectations, the flag comparison will |
| 457 # complain a lot because the fake data is different. |
| 458 return self.m.raw_io.test_api.stream_output( |
| 459 'some line\n' |
| 460 'GYP_DEFINES=\'target_arch=x64 cool_flag=a=1\'\n' |
| 461 'moar\n' |
| 462 ) |
| 414 self.m.chromium.run_mb( | 463 self.m.chromium.run_mb( |
| 415 self.m.properties['mastername'], | 464 self.m.properties['mastername'], |
| 416 self.m.properties['buildername'], | 465 self.m.properties['buildername'], |
| 417 use_goma=use_goma, | 466 use_goma=use_goma, |
| 418 mb_config_path=self.m.path['checkout'].join( | 467 mb_config_path=self.m.path['checkout'].join( |
| 419 'infra', 'mb', 'mb_config.pyl'), | 468 'infra', 'mb', 'mb_config.pyl'), |
| 420 gyp_script=self.m.path.join('gypfiles', 'gyp_v8'), | 469 gyp_script=self.m.path.join('gypfiles', 'gyp_v8'), |
| 470 # TODO(machenbach): Remove the comparison after the mb switch and |
| 471 # once all gyp flags have been verified. |
| 472 stdout=self.m.raw_io.output(), |
| 473 step_test_data=step_test_data, |
| 421 ) | 474 ) |
| 475 # Log captured output. |
| 476 self.m.step.active_result.presentation.logs['stdout'] = ( |
| 477 self.m.step.active_result.stdout.splitlines()) |
| 478 |
| 479 # Compare infra gyp flags with client gyp flags. |
| 480 diff = self._compare_gyp_defines(self.m.step.active_result.stdout) |
| 481 |
| 482 if diff: |
| 483 self.m.step.active_result.presentation.logs['diff'] = diff |
| 484 self.m.step.active_result.presentation.status = self.m.step.WARNING |
| 485 |
| 422 self.peek_gn() | 486 self.peek_gn() |
| 423 self.m.chromium.compile(**kwargs) | 487 self.m.chromium.compile(**kwargs) |
| 424 self.isolate_tests() | 488 self.isolate_tests() |
| 425 | 489 |
| 426 # TODO(machenbach): This should move to a dynamorio module as soon as one | 490 # TODO(machenbach): This should move to a dynamorio module as soon as one |
| 427 # exists. | 491 # exists. |
| 428 def dr_compile(self): | 492 def dr_compile(self): |
| 429 self.m.file.makedirs( | 493 self.m.file.makedirs( |
| 430 'Create Build Dir', | 494 'Create Build Dir', |
| 431 self.m.path['slave_build'].join('dynamorio', 'build')) | 495 self.m.path['slave_build'].join('dynamorio', 'build')) |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 def report_culprits(self, culprit_range): | 1244 def report_culprits(self, culprit_range): |
| 1181 assert culprit_range | 1245 assert culprit_range |
| 1182 if len(culprit_range) > 1: | 1246 if len(culprit_range) > 1: |
| 1183 text = 'Suspecting multiple commits' | 1247 text = 'Suspecting multiple commits' |
| 1184 else: | 1248 else: |
| 1185 text = 'Suspecting %s' % culprit_range[0][:8] | 1249 text = 'Suspecting %s' % culprit_range[0][:8] |
| 1186 | 1250 |
| 1187 step_result = self.m.step(text, cmd=None) | 1251 step_result = self.m.step(text, cmd=None) |
| 1188 for culprit in culprit_range: | 1252 for culprit in culprit_range: |
| 1189 step_result.presentation.links[culprit[:8]] = COMMIT_TEMPLATE % culprit | 1253 step_result.presentation.links[culprit[:8]] = COMMIT_TEMPLATE % culprit |
| OLD | NEW |