Skip to content

Commit

Permalink
Merge pull request #7465 from fcollonval/fix-7462
Browse files Browse the repository at this point in the history
Test jupyter lab without nodeJS
  • Loading branch information
blink1073 committed Nov 15, 2019
2 parents b3177f5 + b36c643 commit 3b877b2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 14 deletions.
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Expand Up @@ -17,6 +17,8 @@ jobs:
testResultsFiles: 'junit.xml'
Usage:
group: 'usage'
UsageNoNodeJS:
group: 'nonode'
Docs:
group: 'docs'

Expand Down
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()
10 changes: 10 additions & 0 deletions scripts/ci_install.sh
Expand Up @@ -24,3 +24,13 @@ jupyter serverextension enable --py jupyterlab
if [[ $GROUP == integrity ]]; then
pip install notebook==4.3.1
fi

if [[ $GROUP == nonode ]]; then
# Build the wheel
pip install wheel
python setup.py bdist_wheel

# Remove NodeJS
sudo rm -rf $(which node)
! node
fi
21 changes: 20 additions & 1 deletion scripts/ci_script.sh
Expand Up @@ -6,7 +6,9 @@
set -ex
set -o pipefail

python -c "from jupyterlab.commands import build_check; build_check()"
if [[ $GROUP != nonode ]]; then
python -c "from jupyterlab.commands import build_check; build_check()"
fi


if [[ $GROUP == python ]]; then
Expand Down Expand Up @@ -229,3 +231,20 @@ if [[ $GROUP == usage ]]; then
kill $TASK_PID
wait $TASK_PID
fi

if [[ $GROUP == nonode ]]; then
# Make sure we can install the wheel
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 &
TASK_PID=$!
# Make sure the task is running
ps -p $TASK_PID || exit 1
sleep 5
kill $TASK_PID
wait $TASK_PID
fi

0 comments on commit 3b877b2

Please sign in to comment.