Show More
@@ -4,7 +4,7 b'' | |||
|
4 | 4 | |
|
5 | 5 | // Get the URL of a notebook server on which to run tests. |
|
6 | 6 | casper.getNotebookServer = function () { |
|
7 |
return 'http://127.0.0.1: |
|
|
7 | return 'http://127.0.0.1:' + casper.cli.get("port"); | |
|
8 | 8 | }; |
|
9 | 9 | |
|
10 | 10 | // Create and open a new notebook. |
@@ -20,6 +20,7 b' from __future__ import print_function' | |||
|
20 | 20 | |
|
21 | 21 | import argparse |
|
22 | 22 | import multiprocessing.pool |
|
23 | from multiprocessing import Process, Queue | |
|
23 | 24 | import os |
|
24 | 25 | import shutil |
|
25 | 26 | import signal |
@@ -164,13 +165,40 b' class JSController(TestController):' | |||
|
164 | 165 | """Create new test runner.""" |
|
165 | 166 | TestController.__init__(self) |
|
166 | 167 | self.section = section |
|
167 | ||
|
168 | ||
|
169 | # start the ipython notebook, so we get the port number | |
|
170 | self._init_server() | |
|
171 | ||
|
168 | 172 | import IPython.html.tests as t |
|
169 | 173 | test_dir = os.path.join(os.path.dirname(t.__file__), 'casperjs') |
|
170 | 174 | includes = '--includes=' + os.path.join(test_dir,'util.js') |
|
171 | 175 | test_cases = os.path.join(test_dir, 'test_cases') |
|
172 | self.cmd = ['casperjs', 'test', includes, test_cases] | |
|
176 | port = '--port=' + str(self.server_port) | |
|
177 | self.cmd = ['casperjs', 'test', port, includes, test_cases] | |
|
178 | ||
|
173 | 179 | |
|
180 | def _init_server(self): | |
|
181 | "Start the notebook server in a separate process" | |
|
182 | self.queue = q = Queue() | |
|
183 | self.server = server = Process(target=run_webapp, args=(q,)) | |
|
184 | server.start() | |
|
185 | self.server_port = q.get() | |
|
186 | ||
|
187 | def cleanup(self): | |
|
188 | self.server.terminate() | |
|
189 | TestController.cleanup(self) | |
|
190 | ||
|
191 | ||
|
192 | def run_webapp(q): | |
|
193 | """start the IPython Notebook, and pass port back to the queue""" | |
|
194 | import IPython.html.notebookapp as nbapp | |
|
195 | # get rid of command line flags used to launch the testing framework | |
|
196 | sys.argv = [sys.executable] | |
|
197 | server = nbapp.NotebookApp() | |
|
198 | server.initialize() | |
|
199 | # communicate the port number to the parent process | |
|
200 | q.put(server.port) | |
|
201 | server.start() | |
|
174 | 202 | |
|
175 | 203 | def prepare_controllers(options): |
|
176 | 204 | """Returns two lists of TestController instances, those to run, and those |
General Comments 0
You need to be logged in to leave comments.
Login now