OLD | NEW |
1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
2 # Copyright 2013 Google Inc. All rights reserved. | 2 # Copyright 2013 Google Inc. All rights reserved. |
3 # | 3 # |
4 # Licensed under the Apache License, Version 2.0 (the "License"); | 4 # Licensed under the Apache License, Version 2.0 (the "License"); |
5 # you may not use this file except in compliance with the License. | 5 # you may not use this file except in compliance with the License. |
6 # You may obtain a copy of the License at | 6 # You may obtain a copy of the License at |
7 # | 7 # |
8 # http://www.apache.org/licenses/LICENSE-2.0 | 8 # http://www.apache.org/licenses/LICENSE-2.0 |
9 # | 9 # |
10 # Unless required by applicable law or agreed to in writing, software | 10 # Unless required by applicable law or agreed to in writing, software |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 def __init__(self, out_file): | 97 def __init__(self, out_file): |
98 self.__out_file = out_file | 98 self.__out_file = out_file |
99 self.__previous_line_was_transient = False | 99 self.__previous_line_was_transient = False |
100 self.__width = term_width(out_file) # Line width, or None if not a tty. | 100 self.__width = term_width(out_file) # Line width, or None if not a tty. |
101 def transient_line(self, msg): | 101 def transient_line(self, msg): |
102 if self.__width is None: | 102 if self.__width is None: |
103 self.__out_file.write(msg + "\n") | 103 self.__out_file.write(msg + "\n") |
104 else: | 104 else: |
105 self.__out_file.write("\r" + msg[:self.__width].ljust(self.__width)) | 105 self.__out_file.write("\r" + msg[:self.__width].ljust(self.__width)) |
106 self.__previous_line_was_transient = True | 106 self.__previous_line_was_transient = True |
107 def permanent_line(self, msg): | 107 def flush_transient_output(self): |
108 if self.__previous_line_was_transient: | 108 if self.__previous_line_was_transient: |
109 self.__out_file.write("\n") | 109 self.__out_file.write("\n") |
110 self.__previous_line_was_transient = False | 110 self.__previous_line_was_transient = False |
| 111 def permanent_line(self, msg): |
| 112 self.flush_transient_output() |
111 self.__out_file.write(msg + "\n") | 113 self.__out_file.write(msg + "\n") |
112 | 114 |
113 stdout_lock = threading.Lock() | 115 stdout_lock = threading.Lock() |
114 | 116 |
115 class FilterFormat: | 117 class FilterFormat: |
116 if sys.stdout.isatty(): | 118 if sys.stdout.isatty(): |
117 # stdout needs to be unbuffered since the output is interactive. | 119 # stdout needs to be unbuffered since the output is interactive. |
118 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) | 120 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) |
119 | 121 |
120 out = Outputter(sys.stdout) | 122 out = Outputter(sys.stdout) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 assert prefix[-1] == ':' | 164 assert prefix[-1] == ':' |
163 self.handle_meta(int(prefix[:-1]), output) | 165 self.handle_meta(int(prefix[:-1]), output) |
164 stdout_lock.release() | 166 stdout_lock.release() |
165 | 167 |
166 def end(self): | 168 def end(self): |
167 if self.failures: | 169 if self.failures: |
168 self.out.permanent_line("FAILED TESTS (%d/%d):" | 170 self.out.permanent_line("FAILED TESTS (%d/%d):" |
169 % (len(self.failures), self.total_tests)) | 171 % (len(self.failures), self.total_tests)) |
170 for (binary, test) in self.failures: | 172 for (binary, test) in self.failures: |
171 self.out.permanent_line(" " + binary + ": " + test) | 173 self.out.permanent_line(" " + binary + ": " + test) |
| 174 self.out.flush_transient_output() |
172 | 175 |
173 class RawFormat: | 176 class RawFormat: |
174 def log(self, line): | 177 def log(self, line): |
175 stdout_lock.acquire() | 178 stdout_lock.acquire() |
176 sys.stdout.write(line + "\n") | 179 sys.stdout.write(line + "\n") |
177 sys.stdout.flush() | 180 sys.stdout.flush() |
178 stdout_lock.release() | 181 stdout_lock.release() |
179 def logfile(self, job_id, name): | 182 def logfile(self, job_id, name): |
180 with open(self.outputs[job_id]) as f: | 183 with open(self.outputs[job_id]) as f: |
181 for line in f.readlines(): | 184 for line in f.readlines(): |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 [t.join() for t in workers] | 393 [t.join() for t in workers] |
391 logger.end() | 394 logger.end() |
392 times.write_to_file(save_file) | 395 times.write_to_file(save_file) |
393 if options.print_test_times: | 396 if options.print_test_times: |
394 ts = sorted((times.get_test_time(test_binary, test), test_binary, test) | 397 ts = sorted((times.get_test_time(test_binary, test), test_binary, test) |
395 for (_, test_binary, test, _) in tests | 398 for (_, test_binary, test, _) in tests |
396 if times.get_test_time(test_binary, test) is not None) | 399 if times.get_test_time(test_binary, test) is not None) |
397 for (time_ms, test_binary, test) in ts: | 400 for (time_ms, test_binary, test) in ts: |
398 print "%8s %s" % ("%dms" % time_ms, test) | 401 print "%8s %s" % ("%dms" % time_ms, test) |
399 sys.exit(-signal.SIGINT if sigint_handler.got_sigint() else exit_code) | 402 sys.exit(-signal.SIGINT if sigint_handler.got_sigint() else exit_code) |
OLD | NEW |