def RunCmd(command, flunk_on_failure=True, halt_on_failure=False, warning_code=constants.WARNING_EXIT_CODE, stdout=None, cwd=CHROME_SRC): """Run a command relative to the chrome source root.""" code = SpawnCmd(command, stdout, cwd).wait() print '<', CommandToString(command) if code != 0: print 'ERROR: process exited with code %d' % code if code != warning_code and flunk_on_failure: bb_annotations.PrintError() else: bb_annotations.PrintWarning() # Allow steps to have both halting (i.e. 1) and non-halting exit codes. if code != warning_code and halt_on_failure: print 'FATAL %d != %d' % (code, warning_code) sys.exit(1) return code
def RunWebkitLayoutTests(options): """Run layout tests on an actual device.""" bb_annotations.PrintNamedStep('webkit_tests') cmd_args = [ '--no-show-results', '--no-new-test-results', '--full-results-html', '--clobber-old-results', '--exit-after-n-failures', '5000', '--exit-after-n-crashes-or-timeouts', '100', '--debug-rwt-logging', '--results-directory', '../layout-test-results', '--target', options.target, '--builder-name', options.build_properties.get('buildername', ''), '--build-number', str(options.build_properties.get('buildnumber', '')), '--master-name', 'ChromiumWebkit', # TODO: Get this from the cfg. '--build-name', options.build_properties.get('buildername', ''), '--platform=android' ] for flag in 'test_results_server', 'driver_name', 'additional_drt_flag': if flag in options.factory_properties: cmd_args.extend([ '--%s' % flag.replace('_', '-'), options.factory_properties.get(flag) ]) for f in options.factory_properties.get('additional_expectations', []): cmd_args.extend([ '--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f) ]) # TODO(dpranke): Remove this block after # https://codereview.chromium.org/12927002/ lands. for f in options.factory_properties.get('additional_expectations_files', []): cmd_args.extend([ '--additional-expectations=%s' % os.path.join(CHROME_SRC_DIR, *f) ]) exit_code = RunCmd( [SrcPath(os.path.join(BLINK_SCRIPTS_DIR, 'run-webkit-tests'))] + cmd_args) if exit_code == 255: # test_run_results.UNEXPECTED_ERROR_EXIT_STATUS bb_annotations.PrintMsg('?? (crashed or hung)') elif exit_code == 254: # test_run_results.NO_DEVICES_EXIT_STATUS bb_annotations.PrintMsg('?? (no devices found)') elif exit_code == 253: # test_run_results.NO_TESTS_EXIT_STATUS bb_annotations.PrintMsg('?? (no tests found)') else: full_results_path = os.path.join('..', 'layout-test-results', 'full_results.json') if os.path.exists(full_results_path): full_results = json.load(open(full_results_path)) unexpected_passes, unexpected_failures, unexpected_flakes = ( _ParseLayoutTestResults(full_results)) if unexpected_failures: _PrintDashboardLink('failed', unexpected_failures, max_tests=25) elif unexpected_passes: _PrintDashboardLink('unexpected passes', unexpected_passes, max_tests=10) if unexpected_flakes: _PrintDashboardLink('unexpected flakes', unexpected_flakes, max_tests=10) if exit_code == 0 and (unexpected_passes or unexpected_flakes): # If exit_code != 0, RunCmd() will have already printed an error. bb_annotations.PrintWarning() else: bb_annotations.PrintError() bb_annotations.PrintMsg('?? (results missing)') if options.factory_properties.get('archive_webkit_results', False): bb_annotations.PrintNamedStep('archive_webkit_results') base = 'https://storage.googleapis.com/chromium-layout-test-archives' builder_name = options.build_properties.get('buildername', '') build_number = str(options.build_properties.get('buildnumber', '')) results_link = '%s/%s/%s/layout-test-results/results.html' % ( base, EscapeBuilderName(builder_name), build_number) bb_annotations.PrintLink('results', results_link) bb_annotations.PrintLink( '(zip)', '%s/%s/%s/layout-test-results.zip' % (base, EscapeBuilderName(builder_name), build_number)) gs_bucket = 'gs://chromium-layout-test-archives' RunCmd([ os.path.join(SLAVE_SCRIPTS_DIR, 'chromium', 'archive_layout_test_results.py'), '--results-dir', '../../layout-test-results', '--build-number', build_number, '--builder-name', builder_name, '--gs-bucket', gs_bucket ], cwd=DIR_BUILD_ROOT)