##// END OF EJS Templates
Improve test output
Thomas Kluyver -
Show More
@@ -77,23 +77,13 b' class IPTestController(object):'
77 env = os.environ.copy()
77 env = os.environ.copy()
78 env.update(self.env)
78 env.update(self.env)
79 output = subprocess.PIPE if self.buffer_output else None
79 output = subprocess.PIPE if self.buffer_output else None
80 stdout = subprocess.STDOUT if self.buffer_output else None
80 self.process = subprocess.Popen(self.cmd, stdout=output,
81 self.process = subprocess.Popen(self.cmd, stdout=output,
81 stderr=output, env=env)
82 stderr=stdout, env=env)
82
83
83 def run(self):
84 def wait(self):
84 """Run the stored commands"""
85 self.stdout, _ = self.process.communicate()
85 try:
86 return self.process.returncode
86 retcode = self._run_cmd()
87 except KeyboardInterrupt:
88 return -signal.SIGINT
89 except:
90 import traceback
91 traceback.print_exc()
92 return 1 # signal failure
93
94 if self.coverage_xml:
95 subprocess.call(["coverage", "xml", "-o", self.coverage_xml])
96 return retcode
97
87
98 def cleanup_process(self):
88 def cleanup_process(self):
99 """Cleanup on exit by killing any leftover processes."""
89 """Cleanup on exit by killing any leftover processes."""
@@ -132,6 +122,7 b' def test_controllers_to_run(inc_slow=False):'
132 res = []
122 res = []
133 if not inc_slow:
123 if not inc_slow:
134 test_sections['parallel'].enabled = False
124 test_sections['parallel'].enabled = False
125
135 for name in test_group_names:
126 for name in test_group_names:
136 if test_sections[name].will_run:
127 if test_sections[name].will_run:
137 res.append(IPTestController(name))
128 res.append(IPTestController(name))
@@ -146,13 +137,13 b' def do_run(controller):'
146 traceback.print_exc()
137 traceback.print_exc()
147 return controller, 1 # signal failure
138 return controller, 1 # signal failure
148
139
149 exitcode = controller.process.wait()
140 exitcode = controller.wait()
150 controller.cleanup()
151 return controller, exitcode
141 return controller, exitcode
152
142
153 except KeyboardInterrupt:
143 except KeyboardInterrupt:
154 controller.cleanup()
155 return controller, -signal.SIGINT
144 return controller, -signal.SIGINT
145 finally:
146 controller.cleanup()
156
147
157 def report():
148 def report():
158 """Return a string with a summary report of test-related variables."""
149 """Return a string with a summary report of test-related variables."""
@@ -199,7 +190,6 b' def run_iptestall(inc_slow=False, jobs=1, xunit=False, coverage=False):'
199 Run the test suite in parallel, if True, using as many threads as there
190 Run the test suite in parallel, if True, using as many threads as there
200 are processors
191 are processors
201 """
192 """
202 pool = multiprocessing.pool.ThreadPool(jobs)
203 if jobs != 1:
193 if jobs != 1:
204 IPTestController.buffer_output = True
194 IPTestController.buffer_output = True
205
195
@@ -210,23 +200,39 b' def run_iptestall(inc_slow=False, jobs=1, xunit=False, coverage=False):'
210 t_start = time.time()
200 t_start = time.time()
211
201
212 print('*'*70)
202 print('*'*70)
203 if jobs == 1:
204 for controller in controllers:
205 print('IPython test group:', controller.section)
206 controller, res = do_run(controller)
207 if res:
208 failed.append(controller)
209 if res == -signal.SIGINT:
210 print("Interrupted")
211 break
212 print()
213
214 else:
215 try:
216 pool = multiprocessing.pool.ThreadPool(jobs)
213 for (controller, res) in pool.imap_unordered(do_run, controllers):
217 for (controller, res) in pool.imap_unordered(do_run, controllers):
214 tgroup = 'IPython test group: ' + controller.section
218 tgroup = 'IPython test group: ' + controller.section + ' '
215 res_string = 'OK' if res == 0 else 'FAILED'
219 res_string = ' OK' if res == 0 else ' FAILED'
216 res_string = res_string.rjust(70 - len(tgroup), '.')
220 res_string = res_string.rjust(70 - len(tgroup), '.')
217 print(tgroup + res_string)
221 print(tgroup + res_string)
218 if res:
222 if res:
223 print(controller.stdout)
219 failed.append(controller)
224 failed.append(controller)
220 if res == -signal.SIGINT:
225 if res == -signal.SIGINT:
221 print("Interrupted")
226 print("Interrupted")
222 break
227 break
228 except KeyboardInterrupt:
229 return
223
230
224 t_end = time.time()
231 t_end = time.time()
225 t_tests = t_end - t_start
232 t_tests = t_end - t_start
226 nrunners = len(controllers)
233 nrunners = len(controllers)
227 nfail = len(failed)
234 nfail = len(failed)
228 # summarize results
235 # summarize results
229 print()
230 print('*'*70)
236 print('*'*70)
231 print('Test suite completed for system with the following information:')
237 print('Test suite completed for system with the following information:')
232 print(report())
238 print(report())
General Comments 0
You need to be logged in to leave comments. Login now