def run_browser(url):
    """Run the browser test and return an exit code.
    """
    target = osp.join(get_app_dir(), 'example_test')
    if not osp.exists(osp.join(target, 'node_modules')):
        os.makedirs(target)
        subprocess.call(["jlpm", "init", "-y"], cwd=target)
        subprocess.call(["jlpm", "add", "puppeteer@^2"], cwd=target)
    shutil.copy(osp.join(here, 'chrome-example-test.js'), osp.join(target, 'chrome-example-test.js'))
    return subprocess.check_call(["node", "chrome-example-test.js", url], cwd=target)
예제 #2
0
async def run_browser(url):
    """Run the browser test and return an exit code.
    """
    # Run the browser test and return an exit code.
    target = osp.join(get_app_dir(), 'example_test')
    if not osp.exists(osp.join(target, 'node_modules')):
        if not osp.exists(target):
            os.makedirs(osp.join(target))
        await run_async_process(["npm", "init", "-y"], cwd=target)
        await run_async_process(["npm", "install", "puppeteer@^4"], cwd=target)
    shutil.copy(osp.join(here, 'chrome-example-test.js'),
                osp.join(target, 'chrome-example-test.js'))
    await run_async_process(["node", "chrome-example-test.js", url],
                            cwd=target)
예제 #3
0
async def run_browser(url):
    """Run the browser test and return an exit code."""
    # Run the browser test and return an exit code.
    target = Path(get_app_dir()) / "example_test"
    if not (target / "node_modules").exists():
        if not target.exists():
            target.mkdir(parents=True, exist_ok=True)
        await run_async_process(["npm", "init", "-y"], cwd=str(target))
        await run_async_process(["npm", "install", "-D", "@playwright/test@^1"], cwd=str(target))
        await run_async_process(["npx", "playwright", "install", "chromium"], cwd=str(target))
    test_target = target / TEST_FILE.name

    shutil.copy(
        str(TEST_FILE),
        str(test_target),
    )

    current_env = os.environ.copy()
    current_env["BASE_URL"] = url
    await run_async_process(["npx", "playwright", "test"], env=current_env, cwd=str(target))
예제 #4
0
    if not os.path.isdir(kernel_dir):
        sys.exit(f'Could not find {kernel_dir} directory.')

    lib_copy = os.path.join(kernel_dir, 'sysml', search)
    shutil.copytree(match, lib_copy)
    try:
        result = subprocess.run(
            ['python', os.path.join(kernel_dir, 'install.py')] + sys.argv[1:],
            capture_output=True,
            cwd=kernel_dir)
        sys.stdout.buffer.write(result.stdout)
        sys.stderr.buffer.write(result.stderr)
        if result.returncode > 0:
            sys.exit(result.returncode)
    finally:
        shutil.rmtree(lib_copy)

    # Enable line numbers and code folding by default
    override_file = os.path.join(get_app_dir(), 'settings', 'overrides.json')
    settings = {
        '@jupyterlab/notebook-extension:tracker': {
            'codeCellConfig': {
                'lineNumbers': True,
                'codeFolding': True
            }
        }
    }
    os.makedirs(os.path.dirname(override_file), exist_ok=True)
    with open(override_file, 'w+') as f:
        f.write(json.dumps(settings))