| 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 148 | 148 | 
| 149     def _test_is_slow(self, test_file): | 149     def _test_is_slow(self, test_file): | 
| 150         return test_expectations.SLOW in self._expectations.model().get_expectat
     ions(test_file) | 150         return test_expectations.SLOW in self._expectations.model().get_expectat
     ions(test_file) | 
| 151 | 151 | 
| 152     def needs_servers(self, test_names): | 152     def needs_servers(self, test_names): | 
| 153         return any(self._test_requires_lock(test_name) for test_name in test_nam
     es) | 153         return any(self._test_requires_lock(test_name) for test_name in test_nam
     es) | 
| 154 | 154 | 
| 155     def _rename_results_folder(self): | 155     def _rename_results_folder(self): | 
| 156         try: | 156         try: | 
| 157             timestamp = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(self._
     filesystem.mtime(self._filesystem.join(self._results_directory, "results.html"))
     )) | 157             timestamp = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(self._
     filesystem.mtime(self._filesystem.join(self._results_directory, "results.html"))
     )) | 
| 158         except OSError, e: | 158         except (IOError, OSError), e: | 
| 159             # It might be possible that results.html was not generated in previo
     us run, because the test | 159             # It might be possible that results.html was not generated in previo
     us run, because the test | 
| 160             # run was interrupted even before testing started. In those cases, d
     on't archive the folder. | 160             # run was interrupted even before testing started. In those cases, d
     on't archive the folder. | 
| 161             # Simply override the current folder contents with new results. | 161             # Simply override the current folder contents with new results. | 
| 162             import errno | 162             import errno | 
| 163             if e.errno == errno.EEXIST: | 163             if e.errno == errno.EEXIST or e.errno == errno.ENOENT: | 
| 164                 _log.warning("No results.html file found in previous run, skippi
     ng it.") | 164                 _log.warning("No results.html file found in previous run, skippi
     ng it.") | 
| 165             return None | 165             return None | 
| 166         archived_name = ''.join((self._filesystem.basename(self._results_directo
     ry), "_", timestamp)) | 166         archived_name = ''.join((self._filesystem.basename(self._results_directo
     ry), "_", timestamp)) | 
| 167         archived_path = self._filesystem.join(self._filesystem.dirname(self._res
     ults_directory), archived_name) | 167         archived_path = self._filesystem.join(self._filesystem.dirname(self._res
     ults_directory), archived_name) | 
| 168         self._filesystem.move(self._results_directory, archived_path) | 168         self._filesystem.move(self._results_directory, archived_path) | 
| 169 | 169 | 
| 170     def _clobber_old_archived_results(self): | 170     def _delete_dirs(self, dir_list): | 
|  | 171         for dir in dir_list: | 
|  | 172             self._filesystem.rmtree(dir) | 
|  | 173 | 
|  | 174     def _limit_archived_results_count(self): | 
| 171         results_directory_path = self._filesystem.dirname(self._results_director
     y) | 175         results_directory_path = self._filesystem.dirname(self._results_director
     y) | 
| 172         file_list = self._filesystem.listdir(results_directory_path) | 176         file_list = self._filesystem.listdir(results_directory_path) | 
| 173         results_directories = [] | 177         results_directories = [] | 
| 174         for dir in file_list: | 178         for dir in file_list: | 
| 175             file_path = self._filesystem.join(results_directory_path, dir) | 179             file_path = self._filesystem.join(results_directory_path, dir) | 
| 176             if self._filesystem.isdir(file_path): | 180             if self._filesystem.isdir(file_path) and self._results_directory in 
     file_path: | 
| 177                 results_directories.append(file_path) | 181                 results_directories.append(file_path) | 
| 178         results_directories.sort(key=lambda x: self._filesystem.mtime(x)) | 182         results_directories.sort(key=lambda x: self._filesystem.mtime(x)) | 
| 179         self._printer.write_update("Clobbering old archived results in %s" % res
     ults_directory_path) | 183         self._printer.write_update("Clobbering excess archived results in %s" % 
     results_directory_path) | 
| 180         for dir in results_directories[:-self.ARCHIVED_RESULTS_LIMIT]: | 184         self._delete_dirs(results_directories[:-self.ARCHIVED_RESULTS_LIMIT]) | 
| 181             self._filesystem.rmtree(dir) |  | 
| 182 | 185 | 
| 183     def _set_up_run(self, test_names): | 186     def _set_up_run(self, test_names): | 
| 184         self._printer.write_update("Checking build ...") | 187         self._printer.write_update("Checking build ...") | 
| 185         if self._options.build: | 188         if self._options.build: | 
| 186             exit_code = self._port.check_build(self.needs_servers(test_names), s
     elf._printer) | 189             exit_code = self._port.check_build(self.needs_servers(test_names), s
     elf._printer) | 
| 187             if exit_code: | 190             if exit_code: | 
| 188                 _log.error("Build check failed") | 191                 _log.error("Build check failed") | 
| 189                 return exit_code | 192                 return exit_code | 
| 190 | 193 | 
| 191         # This must be started before we check the system dependencies, | 194         # This must be started before we check the system dependencies, | 
| 192         # since the helper may do things to make the setup correct. | 195         # since the helper may do things to make the setup correct. | 
| 193         if self._options.pixel_tests: | 196         if self._options.pixel_tests: | 
| 194             self._printer.write_update("Starting pixel test helper ...") | 197             self._printer.write_update("Starting pixel test helper ...") | 
| 195             self._port.start_helper() | 198             self._port.start_helper() | 
| 196 | 199 | 
| 197         # Check that the system dependencies (themes, fonts, ...) are correct. | 200         # Check that the system dependencies (themes, fonts, ...) are correct. | 
| 198         if not self._options.nocheck_sys_deps: | 201         if not self._options.nocheck_sys_deps: | 
| 199             self._printer.write_update("Checking system dependencies ...") | 202             self._printer.write_update("Checking system dependencies ...") | 
| 200             exit_code = self._port.check_sys_deps(self.needs_servers(test_names)
     ) | 203             exit_code = self._port.check_sys_deps(self.needs_servers(test_names)
     ) | 
| 201             if exit_code: | 204             if exit_code: | 
| 202                 self._port.stop_helper() | 205                 self._port.stop_helper() | 
| 203                 return exit_code | 206                 return exit_code | 
| 204 | 207 | 
| 205         if self._options.enable_versioned_results and self._filesystem.exists(se
     lf._results_directory): | 208         if self._options.clobber_old_results: | 
| 206             if self._options.clobber_old_results: | 209             self._clobber_old_results() | 
| 207                 _log.warning("Flag --enable_versioned_results overrides --clobbe
     r-old-results.") | 210         elif self._filesystem.exists(self._results_directory): | 
| 208             self._clobber_old_archived_results() | 211             self._limit_archived_results_count() | 
| 209             # Rename the existing results folder for archiving. | 212             # Rename the existing results folder for archiving. | 
| 210             self._rename_results_folder() | 213             self._rename_results_folder() | 
| 211         elif self._options.clobber_old_results: |  | 
| 212             self._clobber_old_results() |  | 
| 213 | 214 | 
| 214         # Create the output directory if it doesn't already exist. | 215         # Create the output directory if it doesn't already exist. | 
| 215         self._port.host.filesystem.maybe_make_directory(self._results_directory) | 216         self._port.host.filesystem.maybe_make_directory(self._results_directory) | 
| 216 | 217 | 
| 217         self._port.setup_test_run() | 218         self._port.setup_test_run() | 
| 218         return test_run_results.OK_EXIT_STATUS | 219         return test_run_results.OK_EXIT_STATUS | 
| 219 | 220 | 
| 220     def run(self, args): | 221     def run(self, args): | 
| 221         """Run the tests and return a RunDetails object with the results.""" | 222         """Run the tests and return a RunDetails object with the results.""" | 
| 222         start_time = time.time() | 223         start_time = time.time() | 
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 388                 writer = TestResultWriter(self._port._filesystem, self._port, se
     lf._port.results_directory(), test) | 389                 writer = TestResultWriter(self._port._filesystem, self._port, se
     lf._port.results_directory(), test) | 
| 389                 writer.copy_sample_file(sample_file) | 390                 writer.copy_sample_file(sample_file) | 
| 390 | 391 | 
| 391         crash_logs = self._port.look_for_new_crash_logs(crashed_processes, start
     _time) | 392         crash_logs = self._port.look_for_new_crash_logs(crashed_processes, start
     _time) | 
| 392         if crash_logs: | 393         if crash_logs: | 
| 393             for test, crash_log in crash_logs.iteritems(): | 394             for test, crash_log in crash_logs.iteritems(): | 
| 394                 writer = TestResultWriter(self._port._filesystem, self._port, se
     lf._port.results_directory(), test) | 395                 writer = TestResultWriter(self._port._filesystem, self._port, se
     lf._port.results_directory(), test) | 
| 395                 writer.write_crash_log(crash_log) | 396                 writer.write_crash_log(crash_log) | 
| 396 | 397 | 
| 397     def _clobber_old_results(self): | 398     def _clobber_old_results(self): | 
| 398         # Just clobber the actual test results directories since the other | 399         dir_above_results_path = self._filesystem.dirname(self._results_director
     y) | 
| 399         # files in the results directory are explicitly used for cross-run | 400         self._printer.write_update("Clobbering old results in %s" % dir_above_re
     sults_path) | 
| 400         # tracking. | 401         if not self._filesystem.exists(dir_above_results_path): | 
| 401         self._printer.write_update("Clobbering old results in %s" % | 402             return | 
| 402                                    self._results_directory) | 403         file_list = self._filesystem.listdir(dir_above_results_path) | 
| 403         layout_tests_dir = self._port.layout_tests_dir() | 404         results_directories = [] | 
| 404         possible_dirs = self._port.test_dirs() | 405         for dir in file_list: | 
| 405         for dirname in possible_dirs: | 406             file_path = self._filesystem.join(dir_above_results_path, dir) | 
| 406             if self._filesystem.isdir(self._filesystem.join(layout_tests_dir, di
     rname)): | 407             if self._filesystem.isdir(file_path) and self._results_directory in 
     file_path: | 
| 407                 self._filesystem.rmtree(self._filesystem.join(self._results_dire
     ctory, dirname)) | 408                 results_directories.append(file_path) | 
|  | 409         self._delete_dirs(results_directories) | 
| 408 | 410 | 
| 409         # Port specific clean-up. | 411         # Port specific clean-up. | 
| 410         self._port.clobber_old_port_specific_results() | 412         self._port.clobber_old_port_specific_results() | 
| 411 | 413 | 
| 412     def _tests_to_retry(self, run_results): | 414     def _tests_to_retry(self, run_results): | 
| 413         return [result.test_name for result in run_results.unexpected_results_by
     _name.values() if result.type != test_expectations.PASS] | 415         return [result.test_name for result in run_results.unexpected_results_by
     _name.values() if result.type != test_expectations.PASS] | 
| 414 | 416 | 
| 415     def _write_json_files(self, summarized_full_results, summarized_failing_resu
     lts, initial_results): | 417     def _write_json_files(self, summarized_full_results, summarized_failing_resu
     lts, initial_results): | 
| 416         _log.debug("Writing JSON files in %s." % self._results_directory) | 418         _log.debug("Writing JSON files in %s." % self._results_directory) | 
| 417 | 419 | 
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 477             return int(worker_name.split('/')[1]) if worker_name else -1 | 479             return int(worker_name.split('/')[1]) if worker_name else -1 | 
| 478 | 480 | 
| 479         stats = {} | 481         stats = {} | 
| 480         for result in initial_results.results_by_name.values(): | 482         for result in initial_results.results_by_name.values(): | 
| 481             if result.type != test_expectations.SKIP: | 483             if result.type != test_expectations.SKIP: | 
| 482                 stats[result.test_name] = {'results': (_worker_number(result.wor
     ker_name), result.test_number, result.pid, int(result.test_run_time * 1000), int
     (result.total_run_time * 1000))} | 484                 stats[result.test_name] = {'results': (_worker_number(result.wor
     ker_name), result.test_number, result.pid, int(result.test_run_time * 1000), int
     (result.total_run_time * 1000))} | 
| 483         stats_trie = {} | 485         stats_trie = {} | 
| 484         for name, value in stats.iteritems(): | 486         for name, value in stats.iteritems(): | 
| 485             json_results_generator.add_path_to_trie(name, value, stats_trie) | 487             json_results_generator.add_path_to_trie(name, value, stats_trie) | 
| 486         return stats_trie | 488         return stats_trie | 
| OLD | NEW | 
|---|