OLD | NEW |
1 # Copyright 2012 the V8 project authors. All rights reserved. | 1 # Copyright 2012 the V8 project authors. All rights reserved. |
2 # Redistribution and use in source and binary forms, with or without | 2 # Redistribution and use in source and binary forms, with or without |
3 # modification, are permitted provided that the following conditions are | 3 # modification, are permitted provided that the following conditions are |
4 # met: | 4 # met: |
5 # | 5 # |
6 # * Redistributions of source code must retain the above copyright | 6 # * Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # * Redistributions in binary form must reproduce the above | 8 # * Redistributions in binary form must reproduce the above |
9 # copyright notice, this list of conditions and the following | 9 # copyright notice, this list of conditions and the following |
10 # disclaimer in the documentation and/or other materials provided | 10 # disclaimer in the documentation and/or other materials provided |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 output = commands.Execute(job.command, job.verbose, job.timeout) | 57 output = commands.Execute(job.command, job.verbose, job.timeout) |
58 return (job.id, output, time.time() - start_time) | 58 return (job.id, output, time.time() - start_time) |
59 | 59 |
60 class Runner(object): | 60 class Runner(object): |
61 | 61 |
62 def __init__(self, suites, progress_indicator, context): | 62 def __init__(self, suites, progress_indicator, context): |
63 datapath = os.path.join("out", "testrunner_data") | 63 datapath = os.path.join("out", "testrunner_data") |
64 self.perf_data_manager = perfdata.PerfDataManager(datapath) | 64 self.perf_data_manager = perfdata.PerfDataManager(datapath) |
65 self.perfdata = self.perf_data_manager.GetStore(context.arch, context.mode) | 65 self.perfdata = self.perf_data_manager.GetStore(context.arch, context.mode) |
66 self.tests = [ t for s in suites for t in s.tests ] | 66 self.tests = [ t for s in suites for t in s.tests ] |
67 for t in self.tests: | 67 if not context.no_sorting: |
68 t.duration = self.perfdata.FetchPerfData(t) or 1.0 | 68 for t in self.tests: |
| 69 t.duration = self.perfdata.FetchPerfData(t) or 1.0 |
| 70 self.tests.sort(key=lambda t: t.duration, reverse=True) |
69 self._CommonInit(len(self.tests), progress_indicator, context) | 71 self._CommonInit(len(self.tests), progress_indicator, context) |
70 | 72 |
71 def _CommonInit(self, num_tests, progress_indicator, context): | 73 def _CommonInit(self, num_tests, progress_indicator, context): |
72 self.indicator = progress_indicator | 74 self.indicator = progress_indicator |
73 progress_indicator.runner = self | 75 progress_indicator.runner = self |
74 self.context = context | 76 self.context = context |
75 self.succeeded = 0 | 77 self.succeeded = 0 |
76 self.total = num_tests | 78 self.total = num_tests |
77 self.remaining = num_tests | 79 self.remaining = num_tests |
78 self.failed = [] | 80 self.failed = [] |
79 self.crashed = 0 | 81 self.crashed = 0 |
80 | 82 |
81 def Run(self, jobs): | 83 def Run(self, jobs): |
82 self.indicator.Starting() | 84 self.indicator.Starting() |
83 self._RunInternal(jobs) | 85 self._RunInternal(jobs) |
84 self.indicator.Done() | 86 self.indicator.Done() |
85 if self.failed or self.remaining: | 87 if self.failed or self.remaining: |
86 return 1 | 88 return 1 |
87 return 0 | 89 return 0 |
88 | 90 |
89 def _RunInternal(self, jobs): | 91 def _RunInternal(self, jobs): |
90 pool = Pool(jobs) | 92 pool = Pool(jobs) |
91 test_map = {} | 93 test_map = {} |
92 # TODO(machenbach): Instead of filling the queue completely before | 94 # TODO(machenbach): Instead of filling the queue completely before |
93 # pool.imap_unordered, make this a generator that already starts testing | 95 # pool.imap_unordered, make this a generator that already starts testing |
94 # while the queue is filled. | 96 # while the queue is filled. |
95 queue = [] | 97 queue = [] |
96 queued_exception = None | 98 queued_exception = None |
97 if not self.context.no_sorting: | |
98 self.tests = sorted(self.tests, key=lambda t: t.duration, reverse=True) | |
99 for test in self.tests: | 99 for test in self.tests: |
100 assert test.id >= 0 | 100 assert test.id >= 0 |
101 test_map[test.id] = test | 101 test_map[test.id] = test |
102 try: | 102 try: |
103 command = self.GetCommand(test) | 103 command = self.GetCommand(test) |
104 except Exception, e: | 104 except Exception, e: |
105 # If this failed, save the exception and re-raise it later (after | 105 # If this failed, save the exception and re-raise it later (after |
106 # all other tests have had a chance to run). | 106 # all other tests have had a chance to run). |
107 queued_exception = e | 107 queued_exception = e |
108 continue | 108 continue |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 test.suite.GetFlagsForTestCase(test, self.context) + | 159 test.suite.GetFlagsForTestCase(test, self.context) + |
160 self.context.extra_flags) | 160 self.context.extra_flags) |
161 return cmd | 161 return cmd |
162 | 162 |
163 | 163 |
164 class BreakNowException(Exception): | 164 class BreakNowException(Exception): |
165 def __init__(self, value): | 165 def __init__(self, value): |
166 self.value = value | 166 self.value = value |
167 def __str__(self): | 167 def __str__(self): |
168 return repr(self.value) | 168 return repr(self.value) |
OLD | NEW |