##// END OF EJS Templates
Merge pull request #6751 from jdfreder/iptestgun...
Thomas Kluyver -
r18448:c9761991 merge
parent child Browse files
Show More
@@ -3,9 +3,9 b''
3 //
3 //
4 casper.get_notebook_server = function () {
4 casper.get_notebook_server = function () {
5 // Get the URL of a notebook server on which to run tests.
5 // Get the URL of a notebook server on which to run tests.
6 port = casper.cli.get("port");
6 var port = casper.cli.get("port");
7 port = (typeof port === 'undefined') ? '8888' : port;
7 port = (typeof port === 'undefined') ? '8888' : port;
8 return 'http://127.0.0.1:' + port;
8 return casper.cli.get("url") || ('http://127.0.0.1:' + port);
9 };
9 };
10
10
11 casper.open_new_notebook = function () {
11 casper.open_new_notebook = function () {
@@ -15,12 +15,13 b' import argparse'
15 import json
15 import json
16 import multiprocessing.pool
16 import multiprocessing.pool
17 import os
17 import os
18 import re
19 import requests
18 import shutil
20 import shutil
19 import signal
21 import signal
20 import sys
22 import sys
21 import subprocess
23 import subprocess
22 import time
24 import time
23 import re
24
25
25 from .iptest import (
26 from .iptest import (
26 have, test_group_names as py_test_group_names, test_sections, StreamCapturer,
27 have, test_group_names as py_test_group_names, test_sections, StreamCapturer,
@@ -220,16 +221,18 b' def all_js_groups():'
220
221
221 class JSController(TestController):
222 class JSController(TestController):
222 """Run CasperJS tests """
223 """Run CasperJS tests """
224
223 requirements = ['zmq', 'tornado', 'jinja2', 'casperjs', 'sqlite3',
225 requirements = ['zmq', 'tornado', 'jinja2', 'casperjs', 'sqlite3',
224 'jsonschema']
226 'jsonschema']
225 display_slimer_output = False
227 display_slimer_output = False
226
228
227 def __init__(self, section, xunit=True, engine='phantomjs'):
229 def __init__(self, section, xunit=True, engine='phantomjs', url=None):
228 """Create new test runner."""
230 """Create new test runner."""
229 TestController.__init__(self)
231 TestController.__init__(self)
230 self.engine = engine
232 self.engine = engine
231 self.section = section
233 self.section = section
232 self.xunit = xunit
234 self.xunit = xunit
235 self.url = url
233 self.slimer_failure = re.compile('^FAIL.*', flags=re.MULTILINE)
236 self.slimer_failure = re.compile('^FAIL.*', flags=re.MULTILINE)
234 js_test_dir = get_js_test_dir()
237 js_test_dir = get_js_test_dir()
235 includes = '--includes=' + os.path.join(js_test_dir,'util.js')
238 includes = '--includes=' + os.path.join(js_test_dir,'util.js')
@@ -247,14 +250,26 b' class JSController(TestController):'
247 if self.xunit:
250 if self.xunit:
248 self.add_xunit()
251 self.add_xunit()
249
252
250 # start the ipython notebook, so we get the port number
253 # If a url was specified, use that for the testing.
251 self.server_port = 0
254 if self.url:
252 self._init_server()
255 try:
253 if self.server_port:
256 alive = requests.get(self.url).status_code == 200
254 self.cmd.append("--port=%i" % self.server_port)
257 except:
258 alive = False
259
260 if alive:
261 self.cmd.append("--url=%s" % self.url)
262 else:
263 raise Exception('Could not reach "%s".' % self.url)
255 else:
264 else:
256 # don't launch tests if the server didn't start
265 # start the ipython notebook, so we get the port number
257 self.cmd = [sys.executable, '-c', 'raise SystemExit(1)']
266 self.server_port = 0
267 self._init_server()
268 if self.server_port:
269 self.cmd.append("--port=%i" % self.server_port)
270 else:
271 # don't launch tests if the server didn't start
272 self.cmd = [sys.executable, '-c', 'raise SystemExit(1)']
258
273
259 def add_xunit(self):
274 def add_xunit(self):
260 xunit_file = os.path.abspath(self.section.replace('/','.') + '.xunit.xml')
275 xunit_file = os.path.abspath(self.section.replace('/','.') + '.xunit.xml')
@@ -401,7 +416,7 b' def prepare_controllers(options):'
401 js_testgroups = all_js_groups()
416 js_testgroups = all_js_groups()
402
417
403 engine = 'slimerjs' if options.slimerjs else 'phantomjs'
418 engine = 'slimerjs' if options.slimerjs else 'phantomjs'
404 c_js = [JSController(name, xunit=options.xunit, engine=engine) for name in js_testgroups]
419 c_js = [JSController(name, xunit=options.xunit, engine=engine, url=options.url) for name in js_testgroups]
405 c_py = [PyTestController(name, options) for name in py_testgroups]
420 c_py = [PyTestController(name, options) for name in py_testgroups]
406
421
407 controllers = c_py + c_js
422 controllers = c_py + c_js
@@ -509,6 +524,9 b' def run_iptestall(options):'
509 slimerjs : bool
524 slimerjs : bool
510 Use slimerjs if it's installed instead of phantomjs for casperjs tests.
525 Use slimerjs if it's installed instead of phantomjs for casperjs tests.
511
526
527 url : unicode
528 Address:port to use when running the JS tests.
529
512 xunit : bool
530 xunit : bool
513 Produce Xunit XML output. This is written to multiple foo.xunit.xml files.
531 Produce Xunit XML output. This is written to multiple foo.xunit.xml files.
514
532
@@ -637,6 +655,7 b" argparser.add_argument('--all', action='store_true',"
637 help='Include slow tests not run by default.')
655 help='Include slow tests not run by default.')
638 argparser.add_argument('--slimerjs', action='store_true',
656 argparser.add_argument('--slimerjs', action='store_true',
639 help="Use slimerjs if it's installed instead of phantomjs for casperjs tests.")
657 help="Use slimerjs if it's installed instead of phantomjs for casperjs tests.")
658 argparser.add_argument('--url', help="URL to use for the JS tests.")
640 argparser.add_argument('-j', '--fast', nargs='?', const=None, default=1, type=int,
659 argparser.add_argument('-j', '--fast', nargs='?', const=None, default=1, type=int,
641 help='Run test sections in parallel. This starts as many '
660 help='Run test sections in parallel. This starts as many '
642 'processes as you have cores, or you can specify a number.')
661 'processes as you have cores, or you can specify a number.')
General Comments 0
You need to be logged in to leave comments. Login now