| OLD | NEW |
| 1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
| 2 # Copyright (C) 2010 Gabor Rapcsanyi (rgabor@inf.u-szeged.hu), University of Sze
ged | 2 # Copyright (C) 2010 Gabor Rapcsanyi (rgabor@inf.u-szeged.hu), University of Sze
ged |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 199 |
| 200 self._upload_json_files() | 200 self._upload_json_files() |
| 201 | 201 |
| 202 results_path = self._filesystem.join(self._results_directory, "resul
ts.html") | 202 results_path = self._filesystem.join(self._results_directory, "resul
ts.html") |
| 203 self._copy_results_html_file(results_path) | 203 self._copy_results_html_file(results_path) |
| 204 if initial_results.keyboard_interrupted: | 204 if initial_results.keyboard_interrupted: |
| 205 exit_code = test_run_results.INTERRUPTED_EXIT_STATUS | 205 exit_code = test_run_results.INTERRUPTED_EXIT_STATUS |
| 206 else: | 206 else: |
| 207 if initial_results.interrupted: | 207 if initial_results.interrupted: |
| 208 exit_code = test_run_results.EARLY_EXIT_STATUS | 208 exit_code = test_run_results.EARLY_EXIT_STATUS |
| 209 if self._options.show_results and (exit_code or (self._options.f
ull_results_html and initial_results.total_failures)): | 209 if self._options.show_results and ( |
| 210 exit_code or (self._options.full_results_html and initia
l_results.total_failures)): |
| 210 self._port.show_results_html_file(results_path) | 211 self._port.show_results_html_file(results_path) |
| 211 self._printer.print_results(time.time() - start_time, initial_re
sults, summarized_failing_results) | 212 self._printer.print_results(time.time() - start_time, initial_re
sults, summarized_failing_results) |
| 212 | 213 |
| 213 return test_run_results.RunDetails( | 214 return test_run_results.RunDetails( |
| 214 exit_code, summarized_full_results, summarized_failing_results, | 215 exit_code, summarized_full_results, summarized_failing_results, |
| 215 initial_results, all_retry_results, enabled_pixel_tests_in_retry) | 216 initial_results, all_retry_results, enabled_pixel_tests_in_retry) |
| 216 | 217 |
| 217 def _collect_tests(self, args): | 218 def _collect_tests(self, args): |
| 218 return self._finder.find_tests(args, test_list=self._options.test_list, | 219 return self._finder.find_tests(args, test_list=self._options.test_list, |
| 219 fastest_percentile=self._options.fastest) | 220 fastest_percentile=self._options.fastest) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 def _test_is_slow(self, test_file): | 287 def _test_is_slow(self, test_file): |
| 287 return test_expectations.SLOW in self._expectations.model().get_expectat
ions(test_file) | 288 return test_expectations.SLOW in self._expectations.model().get_expectat
ions(test_file) |
| 288 | 289 |
| 289 def _needs_servers(self, test_names): | 290 def _needs_servers(self, test_names): |
| 290 return any(self._test_requires_lock(test_name) for test_name in test_nam
es) | 291 return any(self._test_requires_lock(test_name) for test_name in test_nam
es) |
| 291 | 292 |
| 292 def _rename_results_folder(self): | 293 def _rename_results_folder(self): |
| 293 try: | 294 try: |
| 294 timestamp = time.strftime( | 295 timestamp = time.strftime( |
| 295 "%Y-%m-%d-%H-%M-%S", time.localtime(self._filesystem.mtime(self.
_filesystem.join(self._results_directory, "results.html")))) | 296 "%Y-%m-%d-%H-%M-%S", time.localtime(self._filesystem.mtime(self.
_filesystem.join(self._results_directory, "results.html")))) |
| 296 except (IOError, OSError), e: | 297 except (IOError, OSError) as e: |
| 297 # It might be possible that results.html was not generated in previo
us run, because the test | 298 # It might be possible that results.html was not generated in previo
us run, because the test |
| 298 # run was interrupted even before testing started. In those cases, d
on't archive the folder. | 299 # run was interrupted even before testing started. In those cases, d
on't archive the folder. |
| 299 # Simply override the current folder contents with new results. | 300 # Simply override the current folder contents with new results. |
| 300 import errno | 301 import errno |
| 301 if e.errno == errno.EEXIST or e.errno == errno.ENOENT: | 302 if e.errno == errno.EEXIST or e.errno == errno.ENOENT: |
| 302 self._printer.write_update("No results.html file found in previo
us run, skipping it.") | 303 self._printer.write_update("No results.html file found in previo
us run, skipping it.") |
| 303 return None | 304 return None |
| 304 archived_name = ''.join((self._filesystem.basename(self._results_directo
ry), "_", timestamp)) | 305 archived_name = ''.join((self._filesystem.basename(self._results_directo
ry), "_", timestamp)) |
| 305 archived_path = self._filesystem.join(self._filesystem.dirname(self._res
ults_directory), archived_name) | 306 archived_path = self._filesystem.join(self._filesystem.dirname(self._res
ults_directory), archived_name) |
| 306 self._filesystem.move(self._results_directory, archived_path) | 307 self._filesystem.move(self._results_directory, archived_path) |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 test_inputs.append(self._test_input_for_file(test)) | 367 test_inputs.append(self._test_input_for_file(test)) |
| 367 return self._runner.run_tests(self._expectations, test_inputs, | 368 return self._runner.run_tests(self._expectations, test_inputs, |
| 368 tests_to_skip, num_workers, retry_attempt) | 369 tests_to_skip, num_workers, retry_attempt) |
| 369 | 370 |
| 370 def _start_servers(self, tests_to_run): | 371 def _start_servers(self, tests_to_run): |
| 371 if self._port.is_wpt_enabled() and any(self._port.is_wpt_test(test) for
test in tests_to_run): | 372 if self._port.is_wpt_enabled() and any(self._port.is_wpt_test(test) for
test in tests_to_run): |
| 372 self._printer.write_update('Starting WPTServe ...') | 373 self._printer.write_update('Starting WPTServe ...') |
| 373 self._port.start_wptserve() | 374 self._port.start_wptserve() |
| 374 self._wptserve_started = True | 375 self._wptserve_started = True |
| 375 | 376 |
| 376 if self._port.requires_http_server() or any((self._is_http_test(test) or
self._is_inspector_test(test)) for test in tests_to_run): | 377 if self._port.requires_http_server() or any((self._is_http_test(test) or
self._is_inspector_test(test)) |
| 378 for test in tests_to_run): |
| 377 self._printer.write_update('Starting HTTP server ...') | 379 self._printer.write_update('Starting HTTP server ...') |
| 378 self._port.start_http_server(additional_dirs={}, number_of_drivers=s
elf._options.max_locked_shards) | 380 self._port.start_http_server(additional_dirs={}, number_of_drivers=s
elf._options.max_locked_shards) |
| 379 self._http_server_started = True | 381 self._http_server_started = True |
| 380 | 382 |
| 381 if any(self._is_websocket_test(test) for test in tests_to_run): | 383 if any(self._is_websocket_test(test) for test in tests_to_run): |
| 382 self._printer.write_update('Starting WebSocket server ...') | 384 self._printer.write_update('Starting WebSocket server ...') |
| 383 self._port.start_websocket_server() | 385 self._port.start_websocket_server() |
| 384 self._websockets_server_started = True | 386 self._websockets_server_started = True |
| 385 | 387 |
| 386 def _stop_servers(self): | 388 def _stop_servers(self): |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 if self._filesystem.isdir(file_path) and self._results_directory in
file_path: | 466 if self._filesystem.isdir(file_path) and self._results_directory in
file_path: |
| 465 results_directories.append(file_path) | 467 results_directories.append(file_path) |
| 466 self._delete_dirs(results_directories) | 468 self._delete_dirs(results_directories) |
| 467 | 469 |
| 468 # Port specific clean-up. | 470 # Port specific clean-up. |
| 469 self._port.clobber_old_port_specific_results() | 471 self._port.clobber_old_port_specific_results() |
| 470 | 472 |
| 471 def _tests_to_retry(self, run_results): | 473 def _tests_to_retry(self, run_results): |
| 472 # TODO(ojan): This should also check that result.type != test_expectatio
ns.MISSING since retrying missing expectations is silly. | 474 # TODO(ojan): This should also check that result.type != test_expectatio
ns.MISSING since retrying missing expectations is silly. |
| 473 # But that's a bit tricky since we only consider the last retry attempt
for the count of unexpected regressions. | 475 # But that's a bit tricky since we only consider the last retry attempt
for the count of unexpected regressions. |
| 474 return [result.test_name for result in run_results.unexpected_results_by
_name.values() if result.type != test_expectations.PASS] | 476 return [result.test_name for result in run_results.unexpected_results_by
_name.values( |
| 477 ) if result.type != test_expectations.PASS] |
| 475 | 478 |
| 476 def _write_json_files(self, summarized_full_results, summarized_failing_resu
lts, initial_results, running_all_tests): | 479 def _write_json_files(self, summarized_full_results, summarized_failing_resu
lts, initial_results, running_all_tests): |
| 477 _log.debug("Writing JSON files in %s." % self._results_directory) | 480 _log.debug("Writing JSON files in %s." % self._results_directory) |
| 478 | 481 |
| 479 # FIXME: Upload stats.json to the server and delete times_ms. | 482 # FIXME: Upload stats.json to the server and delete times_ms. |
| 480 times_trie = json_results_generator.test_timings_trie(initial_results.re
sults_by_name.values()) | 483 times_trie = json_results_generator.test_timings_trie(initial_results.re
sults_by_name.values()) |
| 481 times_json_path = self._filesystem.join(self._results_directory, "times_
ms.json") | 484 times_json_path = self._filesystem.join(self._results_directory, "times_
ms.json") |
| 482 json_results_generator.write_json(self._filesystem, times_trie, times_js
on_path) | 485 json_results_generator.write_json(self._filesystem, times_trie, times_js
on_path) |
| 483 | 486 |
| 484 # Save out the times data so we can use it for --fastest in the future. | 487 # Save out the times data so we can use it for --fastest in the future. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 uploader = FileUploader(url, 120) | 529 uploader = FileUploader(url, 120) |
| 527 try: | 530 try: |
| 528 response = uploader.upload_as_multipart_form_data(self._filesystem,
files, attrs) | 531 response = uploader.upload_as_multipart_form_data(self._filesystem,
files, attrs) |
| 529 if response: | 532 if response: |
| 530 if response.code == 200: | 533 if response.code == 200: |
| 531 _log.debug("JSON uploaded.") | 534 _log.debug("JSON uploaded.") |
| 532 else: | 535 else: |
| 533 _log.debug("JSON upload failed, %d: '%s'" % (response.code,
response.read())) | 536 _log.debug("JSON upload failed, %d: '%s'" % (response.code,
response.read())) |
| 534 else: | 537 else: |
| 535 _log.error("JSON upload failed; no response returned") | 538 _log.error("JSON upload failed; no response returned") |
| 536 except Exception, err: | 539 except Exception as err: |
| 537 _log.error("Upload failed: %s" % err) | 540 _log.error("Upload failed: %s" % err) |
| 538 | 541 |
| 539 def _copy_results_html_file(self, destination_path): | 542 def _copy_results_html_file(self, destination_path): |
| 540 base_dir = self._port.path_from_webkit_base('LayoutTests', 'fast', 'harn
ess') | 543 base_dir = self._port.path_from_webkit_base('LayoutTests', 'fast', 'harn
ess') |
| 541 results_file = self._filesystem.join(base_dir, 'results.html') | 544 results_file = self._filesystem.join(base_dir, 'results.html') |
| 542 # Note that the results.html template file won't exist when we're using
a MockFileSystem during unit tests, | 545 # Note that the results.html template file won't exist when we're using
a MockFileSystem during unit tests, |
| 543 # so make sure it exists before we try to copy it. | 546 # so make sure it exists before we try to copy it. |
| 544 if self._filesystem.exists(results_file): | 547 if self._filesystem.exists(results_file): |
| 545 self._filesystem.copyfile(results_file, destination_path) | 548 self._filesystem.copyfile(results_file, destination_path) |
| 546 | 549 |
| 547 def _stats_trie(self, initial_results): | 550 def _stats_trie(self, initial_results): |
| 548 def _worker_number(worker_name): | 551 def _worker_number(worker_name): |
| 549 return int(worker_name.split('/')[1]) if worker_name else -1 | 552 return int(worker_name.split('/')[1]) if worker_name else -1 |
| 550 | 553 |
| 551 stats = {} | 554 stats = {} |
| 552 for result in initial_results.results_by_name.values(): | 555 for result in initial_results.results_by_name.values(): |
| 553 if result.type != test_expectations.SKIP: | 556 if result.type != test_expectations.SKIP: |
| 554 stats[result.test_name] = {'results': (_worker_number(result.wor
ker_name), result.test_number, result.pid, int( | 557 stats[result.test_name] = {'results': (_worker_number(result.wor
ker_name), result.test_number, result.pid, int( |
| 555 result.test_run_time * 1000), int(result.total_run_time * 10
00))} | 558 result.test_run_time * 1000), int(result.total_run_time * 10
00))} |
| 556 stats_trie = {} | 559 stats_trie = {} |
| 557 for name, value in stats.iteritems(): | 560 for name, value in stats.iteritems(): |
| 558 json_results_generator.add_path_to_trie(name, value, stats_trie) | 561 json_results_generator.add_path_to_trie(name, value, stats_trie) |
| 559 return stats_trie | 562 return stats_trie |
| OLD | NEW |