##// END OF EJS Templates
Separate out machinery for running JS tests
Thomas Kluyver -
Show More
@@ -164,7 +164,7 b" have['zmq'] = test_for('zmq.pyzmq_version_info', min_zmq, callback=lambda x: x()"
164
164
165 test_group_names = ['parallel', 'kernel', 'kernel.inprocess', 'config', 'core',
165 test_group_names = ['parallel', 'kernel', 'kernel.inprocess', 'config', 'core',
166 'extensions', 'lib', 'terminal', 'testing', 'utils',
166 'extensions', 'lib', 'terminal', 'testing', 'utils',
167 'nbformat', 'qt', 'html', 'js', 'nbconvert'
167 'nbformat', 'qt', 'html', 'nbconvert'
168 ]
168 ]
169
169
170 class TestSection(object):
170 class TestSection(object):
@@ -288,9 +288,6 b" if not have['jinja2']:"
288 if not have['azure']:
288 if not have['azure']:
289 sec.exclude('services.notebooks.azurenbmanager')
289 sec.exclude('services.notebooks.azurenbmanager')
290
290
291 sec = test_sections['js']
292 sec.requires('zmq', 'tornado', 'jinja2', 'casperjs')
293
294 # config:
291 # config:
295 # Config files aren't really importable stand-alone
292 # Config files aren't really importable stand-alone
296 test_sections['config'].exclude('profile')
293 test_sections['config'].exclude('profile')
@@ -28,7 +28,7 b' import sys'
28 import subprocess
28 import subprocess
29 import time
29 import time
30
30
31 from .iptest import have, test_group_names, test_sections
31 from .iptest import have, test_group_names as py_test_group_names, test_sections
32 from IPython.utils.py3compat import bytes_to_str
32 from IPython.utils.py3compat import bytes_to_str
33 from IPython.utils.sysinfo import sys_info
33 from IPython.utils.sysinfo import sys_info
34 from IPython.utils.tempdir import TemporaryDirectory
34 from IPython.utils.tempdir import TemporaryDirectory
@@ -56,14 +56,6 b' class TestController(object):'
56 self.cmd = []
56 self.cmd = []
57 self.env = {}
57 self.env = {}
58 self.dirs = []
58 self.dirs = []
59
60
61 @property
62 def will_run(self):
63 try:
64 return test_sections[self.section].will_run
65 except KeyError:
66 return True
67
59
68 def launch(self):
60 def launch(self):
69 # print('*** ENV:', self.env) # dbg
61 # print('*** ENV:', self.env) # dbg
@@ -102,13 +94,13 b' class TestController(object):'
102 if subp.poll() is None:
94 if subp.poll() is None:
103 # The process did not die...
95 # The process did not die...
104 print('... failed. Manual cleanup may be required.')
96 print('... failed. Manual cleanup may be required.')
105
97
106 def cleanup(self):
98 def cleanup(self):
107 "Kill process if it's still alive, and clean up temporary directories"
99 "Kill process if it's still alive, and clean up temporary directories"
108 self.cleanup_process()
100 self.cleanup_process()
109 for td in self.dirs:
101 for td in self.dirs:
110 td.cleanup()
102 td.cleanup()
111
103
112 __del__ = cleanup
104 __del__ = cleanup
113
105
114 class PyTestController(TestController):
106 class PyTestController(TestController):
@@ -132,6 +124,13 b' class PyTestController(TestController):'
132 # This means we won't get odd effects from our own matplotlib config
124 # This means we won't get odd effects from our own matplotlib config
133 self.env['MPLCONFIGDIR'] = workingdir.name
125 self.env['MPLCONFIGDIR'] = workingdir.name
134
126
127 @property
128 def will_run(self):
129 try:
130 return test_sections[self.section].will_run
131 except KeyError:
132 return True
133
135 def add_xunit(self):
134 def add_xunit(self):
136 xunit_file = os.path.abspath(self.section + '.xunit.xml')
135 xunit_file = os.path.abspath(self.section + '.xunit.xml')
137 self.cmd.extend(['--with-xunit', '--xunit-file', xunit_file])
136 self.cmd.extend(['--with-xunit', '--xunit-file', xunit_file])
@@ -170,6 +169,7 b' class JSController(TestController):'
170 self.dirs.append(self.ipydir)
169 self.dirs.append(self.ipydir)
171 self.env['IPYTHONDIR'] = self.ipydir.name
170 self.env['IPYTHONDIR'] = self.ipydir.name
172
171
172 def launch(self):
173 # start the ipython notebook, so we get the port number
173 # start the ipython notebook, so we get the port number
174 self._init_server()
174 self._init_server()
175
175
@@ -180,6 +180,11 b' class JSController(TestController):'
180 port = '--port=' + str(self.server_port)
180 port = '--port=' + str(self.server_port)
181 self.cmd = ['casperjs', 'test', port, includes, test_cases]
181 self.cmd = ['casperjs', 'test', port, includes, test_cases]
182
182
183 super(JSController, self).launch()
184
185 @property
186 def will_run(self):
187 return all(have[a] for a in ['zmq', 'tornado', 'jinja2', 'casperjs'])
183
188
184 def _init_server(self):
189 def _init_server(self):
185 "Start the notebook server in a separate process"
190 "Start the notebook server in a separate process"
@@ -193,6 +198,7 b' class JSController(TestController):'
193 self.server.join()
198 self.server.join()
194 TestController.cleanup(self)
199 TestController.cleanup(self)
195
200
201 js_test_group_names = {'js'}
196
202
197 def run_webapp(q, nbdir, loglevel=0):
203 def run_webapp(q, nbdir, loglevel=0):
198 """start the IPython Notebook, and pass port back to the queue"""
204 """start the IPython Notebook, and pass port back to the queue"""
@@ -212,17 +218,21 b' def prepare_controllers(options):'
212 not to run."""
218 not to run."""
213 testgroups = options.testgroups
219 testgroups = options.testgroups
214
220
215 if not testgroups:
221 if testgroups:
216 testgroups = test_group_names
222 py_testgroups = [g for g in testgroups if g in py_test_group_names]
223 js_testgroups = [g for g in testgroups if g in js_test_group_names]
224 else:
225 py_testgroups = py_test_group_names
226 js_testgroups = js_test_group_names
217 if not options.all:
227 if not options.all:
218 test_sections['parallel'].enabled = False
228 test_sections['parallel'].enabled = False
219
229
220 c_js = [JSController(name) for name in testgroups if 'js' in name]
230 c_js = [JSController(name) for name in js_testgroups]
221 c_py = [PyTestController(name) for name in testgroups if 'js' not in name]
231 c_py = [PyTestController(name) for name in py_testgroups]
222
232
223 configure_py_controllers(c_py, xunit=options.xunit,
233 configure_py_controllers(c_py, xunit=options.xunit,
224 coverage=options.coverage)
234 coverage=options.coverage)
225
235
226 controllers = c_py + c_js
236 controllers = c_py + c_js
227 to_run = [c for c in controllers if c.will_run]
237 to_run = [c for c in controllers if c.will_run]
228 not_run = [c for c in controllers if not c.will_run]
238 not_run = [c for c in controllers if not c.will_run]
@@ -245,10 +255,10 b' def do_run(controller):'
245 import traceback
255 import traceback
246 traceback.print_exc()
256 traceback.print_exc()
247 return controller, 1 # signal failure
257 return controller, 1 # signal failure
248
258
249 exitcode = controller.wait()
259 exitcode = controller.wait()
250 return controller, exitcode
260 return controller, exitcode
251
261
252 except KeyboardInterrupt:
262 except KeyboardInterrupt:
253 return controller, -signal.SIGINT
263 return controller, -signal.SIGINT
254 finally:
264 finally:
@@ -287,7 +297,7 b' def run_iptestall(options):'
287 modules and package and then runs each of them. This causes the modules
297 modules and package and then runs each of them. This causes the modules
288 and packages of IPython to be tested each in their own subprocess using
298 and packages of IPython to be tested each in their own subprocess using
289 nose.
299 nose.
290
300
291 Parameters
301 Parameters
292 ----------
302 ----------
293
303
@@ -359,7 +369,7 b' def run_iptestall(options):'
359 break
369 break
360 except KeyboardInterrupt:
370 except KeyboardInterrupt:
361 return
371 return
362
372
363 for controller in not_run:
373 for controller in not_run:
364 print(justify('IPython test group: ' + controller.section, 'NOT RUN'))
374 print(justify('IPython test group: ' + controller.section, 'NOT RUN'))
365
375
General Comments 0
You need to be logged in to leave comments. Login now