Skip to content

Commit

Permalink
Launch with log capture
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Collonval committed Nov 14, 2019
1 parent 94450a1 commit b36c643
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
31 changes: 18 additions & 13 deletions jupyterlab/browser_check.py
Expand Up @@ -103,6 +103,18 @@ def finished(future):
IOLoop.current().add_future(future, finished)


def run_browser(url):
"""Run the browser test and return an exit code.
"""
target = osp.join(get_app_dir(), 'browser_test')
if not osp.exists(osp.join(target, 'node_modules')):
os.makedirs(target)
subprocess.call(["jlpm"], cwd=target)
subprocess.call(["jlpm", "add", "puppeteer"], cwd=target)
shutil.copy(osp.join(here, 'chrome-test.js'), osp.join(target, 'chrome-test.js'))
return subprocess.check_call(["node", "chrome-test.js", url], cwd=target)


class BrowserApp(LabApp):
"""An app the launches JupyterLab and waits for it to start up, checking for
JS console errors, JS errors, and Python logged errors.
Expand All @@ -112,27 +124,20 @@ class BrowserApp(LabApp):
ip = '127.0.0.1'
flags = test_flags
aliases = test_aliases
test_browser = True

def start(self):
web_app = self.web_app
web_app.settings.setdefault('page_config_data', dict())
web_app.settings['page_config_data']['browserTest'] = True
web_app.settings['page_config_data']['buildAvailable'] = False
run_test(self, run_browser)
run_test(self, run_browser if self.test_browser else lambda url: 0)
super().start()


def run_browser(url):
"""Run the browser test and return an exit code.
"""
target = osp.join(get_app_dir(), 'browser_test')
if not osp.exists(osp.join(target, 'node_modules')):
os.makedirs(target)
subprocess.call(["jlpm"], cwd=target)
subprocess.call(["jlpm", "add", "puppeteer"], cwd=target)
shutil.copy(osp.join(here, 'chrome-test.js'), osp.join(target, 'chrome-test.js'))
return subprocess.check_call(["node", "chrome-test.js", url], cwd=target)


if __name__ == '__main__':
skip_option = "--no-chrome-test"
if skip_option in sys.argv:
BrowserApp.test_browser = False
sys.argv.remove(skip_option)
BrowserApp.launch_instance()
1 change: 1 addition & 0 deletions scripts/ci_script.sh
Expand Up @@ -237,6 +237,7 @@ if [[ $GROUP == nonode ]]; then
virtualenv -p $(which python3) test_install
./test_install/bin/pip install -v --pre --no-cache-dir --no-deps jupyterlab --no-index --find-links=dist # Install latest jupyterlab
./test_install/bin/pip install jupyterlab # Install jupyterlab dependencies
./test_install/bin/python -m jupyterlab.browser_check --no-chrome-test

# Make sure we can start and kill the lab server
./test_install/bin/jupyter lab --no-browser &
Expand Down

0 comments on commit b36c643

Please sign in to comment.