Steven Silvester 6 роки тому
батько
коміт
4d30273303

+ 11 - 13
examples/example_check.py

@@ -25,17 +25,15 @@ from jupyterlab.browser_check import run_test
 here = osp.abspath(osp.dirname(__file__))
 
 
-# Load the main file and grab the example class so we can subclass
-example_dir = sys.argv.pop()
-mod_path = osp.abspath(osp.join(example_dir, 'main.py'))
-spec = importlib.util.spec_from_file_location("example", mod_path)
-mod = importlib.util.module_from_spec(spec)
-spec.loader.exec_module(mod)
+def main():
+    # Load the main file and grab the example class so we can subclass
+    example_dir = sys.argv.pop()
+    mod_path = osp.abspath(osp.join(example_dir, 'main.py'))
+    spec = importlib.util.spec_from_file_location("example", mod_path)
+    mod = importlib.util.module_from_spec(spec)
+    spec.loader.exec_module(mod)
 
-
-def factory(BaseClass):
-
-    class App(BaseClass):
+    class App(mod.ExampleApp):
         """An app that launches an example and waits for it to start up, checking for
         JS console errors, JS errors, and Python logged errors.
         """
@@ -49,7 +47,8 @@ def factory(BaseClass):
             super().start()
 
     App.__name__ = osp.basename(example_dir).capitalize() + 'Test'
-    return App
+    App.launch_instance()
+
 
 def run_browser(url):
     """Run the browser test and return an exit code.
@@ -64,5 +63,4 @@ def run_browser(url):
 
 
 if __name__ == '__main__':
-    cls = factory(mod.ExampleApp)
-    cls.launch_instance()
+    main()

+ 15 - 3
jupyterlab/browser_check.py

@@ -17,6 +17,7 @@ from notebook.notebookapp import flags, aliases
 from traitlets import Bool
 
 from .labapp import LabApp, get_app_dir
+from .tests.test_app import TestEnv
 
 
 here = osp.abspath(osp.dirname(__file__))
@@ -60,6 +61,9 @@ def run_test(app, func):
     """
     handler = LogErrorHandler()
 
+    env_patch = TestEnv()
+    app.env_patch.start()
+
     def finished(future):
         try:
             result = future.result()
@@ -69,13 +73,21 @@ def run_test(app, func):
         app.stop()
         if handler.errored:
             app.log.critical('Exiting with 1 due to errors')
-            sys.exit(1)
+            result = 1
         elif result != 0:
             app.log.critical('Exiting with %s due to errors' % result)
-            sys.exit(result)
         else:
             app.log.info('Exiting normally')
-            sys.exit()
+            result = 0
+
+        app.http_server.stop()
+        app.io_loop.stop()
+        env_patch.stop()
+        try:
+            os._exit(result)
+        except Exception as e:
+            self.log.error(str(e))
+            os._exit(1)
 
     app.log.addHandler(handler)
     pool = ThreadPoolExecutor()

+ 2 - 2
jupyterlab/tests/test_app.py

@@ -98,7 +98,7 @@ def _install_kernels():
     write_kernel_spec(ipykernel_dir)
 
 
-class _test_env(object):
+class TestEnv(object):
     """Set Jupyter path variables to a temporary directory
 
     Useful as a context manager or with explicit start/stop
@@ -148,7 +148,7 @@ class ProcessTestApp(ProcessApp):
     workspaces_dir = Unicode(_create_workspaces_dir())
 
     def __init__(self):
-        self.env_patch = _test_env()
+        self.env_patch = TestEnv()
         self.env_patch.start()
         ProcessApp.__init__(self)
 

+ 55 - 31
scripts/travis_script.sh

@@ -62,37 +62,6 @@ if [[ $GROUP == integrity ]]; then
     jlpm config set prefix ~/.yarn
     ~/.yarn/bin/postcss packages/**/style/*.css --dir /tmp
 
-    # Make sure we can successfully load the dev app.
-    python -m jupyterlab.browser_check --dev-mode
-
-    # Make sure core mode works
-    jlpm run build:core
-    python -m jupyterlab.browser_check --core-mode
-
-    # Make sure we can run the built app.
-    jupyter labextension install ./jupyterlab/tests/mock_packages/extension
-    python -m jupyterlab.browser_check
-    jupyter labextension list
-
-    # Make sure the deprecated `selenium_check` command still works
-    python -m jupyterlab.selenium_check
-
-    # Make sure we can non-dev install.
-    virtualenv -p $(which python3) test_install
-    ./test_install/bin/pip install -q ".[test]"  # this populates <sys_prefix>/share/jupyter/lab
-    ./test_install/bin/python -m jupyterlab.browser_check
-    # Make sure we can run the build
-    ./test_install/bin/jupyter lab build
-
-    # 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
-
     # Make sure we can bump the version
     # This must be done at the end so as not to interfere
     # with the other checks
@@ -102,23 +71,42 @@ if [[ $GROUP == integrity ]]; then
     git checkout -b commit_${BUILD_SOURCEVERSION}
     git clean -df
     jlpm bumpversion minor --force
+    git commit -a -m "minor"
     jlpm bumpversion major --force
+    git commit -a -m "major"
     jlpm bumpversion release --force # switch to rc
+    git commit -a -m "release"
     jlpm bumpversion build --force
+    git commit -a -m "build"
     VERSION=$(python setup.py --version)
     if [[ $VERSION != *rc1 ]]; then exit 1; fi
 
     # make sure we can patch release
     jlpm bumpversion release --force  # switch to final
+    git commit -a -m "release"
     jlpm patch:release --force
+    git commit -a -m "patched"
     jlpm patch:release console --force
+    git commit -a -m "patched single"
     jlpm patch:release filebrowser notebook --force
+    git commit -a -m "patched multiple"
 
     # make sure we can bump major JS releases
     jlpm bumpversion minor --force
+    git commit -a -m "minor"
     jlpm bump:js:major console --force
+    git commit -a -m "major single"
     jlpm bump:js:major console notebook --force
+    git commit -a -m "major multiple"
+
+    # Make sure that a prepublish would include the proper files.
+    jlpm run prepublish:check
 
+    # run twine check on the python build assets.
+    python setup.py sdist
+    python setup.py bdist_wheel
+    python -m pip install -U twine
+    twine check dist/*
 fi
 
 
@@ -197,4 +185,40 @@ if [[ $GROUP == usage ]]; then
     env JUPYTERLAB_DIR=./link_app_dir jupyter lab path | grep link_app_dir
     popd
 
+    # Build the examples.
+    jlpm run build:examples
+
+    # Test the examples
+    jlpm run test:examples
+
+    # Make sure we can successfully load the dev app.
+    python -m jupyterlab.browser_check --dev-mode
+
+    # Make sure core mode works
+    jlpm run build:core
+    python -m jupyterlab.browser_check --core-mode
+
+    # Make sure we can run the built app.
+    jupyter labextension install ./jupyterlab/tests/mock_packages/extension
+    python -m jupyterlab.browser_check
+    jupyter labextension list
+
+    # Make sure the deprecated `selenium_check` command still works
+    python -m jupyterlab.selenium_check
+
+    # Make sure we can non-dev install.
+    virtualenv -p $(which python3) test_install
+    ./test_install/bin/pip install -q ".[test]"  # this populates <sys_prefix>/share/jupyter/lab
+    ./test_install/bin/python -m jupyterlab.browser_check
+    # Make sure we can run the build
+    ./test_install/bin/jupyter lab build
+
+    # 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