diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 60463cd..8f66d3c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -17,29 +17,47 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Get number of CPU cores uses: SimenB/github-actions-cpu-cores@v1 - + + - name: apt-install + run: | + sudo apt-get update -y && sudo apt-get install -y \ + libwoff1 libvpx9 libevent-2.1-7t64 libopus0 libgstreamer-plugins-base1.0-0 \ + libgstreamer-gl1.0-0 \ + libgstreamer-plugins-bad1.0-0 \ + libflite1 \ + libavif16 \ + libharfbuzz-icu0 \ + libsecret-1-0 \ + libhyphen0 \ + libmanette-0.2-0 \ + libgles2 \ + gstreamer1.0-libav + - name: Install mamba - uses: mamba-org/provision-with-micromamba@main + uses: mamba-org/setup-micromamba@v2 with: environment-file: dev-env.yml environment-name: dev-env - micromamba-version: "1.4.1" - + init-shell: >- + bash + - name: Install Playwright + shell: bash -el {0} run: | playwright install - name: Install pyjs-code-runner + shell: bash -el {0} run: | - micromamba activate dev-env python -m pip install . --no-deps - name: Run Tests + shell: bash -el {0} run: | - micromamba activate dev-env - pytest -s + pytest -s -vvvvv test_with_pip: @@ -50,20 +68,34 @@ jobs: - name: Get number of CPU cores uses: SimenB/github-actions-cpu-cores@v1 + - name: apt-install + run: | + sudo apt-get update -y && sudo apt-get install -y \ + libwoff1 libvpx9 libevent-2.1-7t64 libopus0 libgstreamer-plugins-base1.0-0 \ + libgstreamer-gl1.0-0 \ + libgstreamer-plugins-bad1.0-0 \ + libflite1 \ + libavif16 \ + libharfbuzz-icu0 \ + libsecret-1-0 \ + libhyphen0 \ + libmanette-0.2-0 \ + libgles2 \ + gstreamer1.0-libav + - name: Install mamba - uses: mamba-org/provision-with-micromamba@main + uses: mamba-org/setup-micromamba@v2 with: environment-file: dev-env-pip.yml environment-name: dev-env - micromamba-version: "1.4.1" - name: Install pyjs-code-runner + shell: bash -el {0} run: | - micromamba activate dev-env python -m pip install . playwright install - + - name: Run Tests + shell: bash -el {0} run: | - micromamba activate dev-env - pytest -s + pytest -s -vvvvv diff --git a/dev-env-pip.yml b/dev-env-pip.yml index 5a9a416..657a9bd 100644 --- a/dev-env-pip.yml +++ b/dev-env-pip.yml @@ -4,5 +4,9 @@ channels: dependencies: - python - pip - - emsdk - - pytest \ No newline at end of file + - pytest + - pytest-sugar + - typer + - appdirs + - empack >=3,<4 + - rich diff --git a/dev-env.yml b/dev-env.yml index 5fc1183..97104d2 100644 --- a/dev-env.yml +++ b/dev-env.yml @@ -5,9 +5,10 @@ dependencies: - python - pip - pytest + - pytest-sugar - typer - appdirs - empack >=3,<4 - microsoft::playwright - emsdk - - rich \ No newline at end of file + - rich diff --git a/pyjs_code_runner/js/utils.js b/pyjs_code_runner/js/utils.js index ccb558d..b5ecdf7 100644 --- a/pyjs_code_runner/js/utils.js +++ b/pyjs_code_runner/js/utils.js @@ -39,7 +39,13 @@ function eval_main_script(pyjs, workdir, filename) { return 0; } catch (e) { - console.error("error while evaluating main file:", e) + if (typeof e === "number") { + const msg = get_exception_message(e); + console.error("error while evaluating main file:", msg) + } + else { + console.error("error while evaluating main file:", e) + } return 1; } return 0 diff --git a/test/conftest.py b/test/conftest.py index 2062967..5a6d201 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -6,30 +6,25 @@ from typer.testing import CliRunner import os -# @pytest.fixture(scope="session") -# def session_temp_path(tmp_path_factory): -# return tmp_path_factory.mktemp() - ON_GITHUB_ACTIONS = False if "GITHUB_ACTION" in os.environ: ON_GITHUB_ACTIONS = True @pytest.fixture(scope="session") -def env_prefix(): - env_root = Path(appdirs.user_data_dir("pytest_code_runner_tests", "DerThorsten")) - env_root.mkdir(exist_ok=True, parents=True) +def env_prefix(tmp_path_factory): + + env_root = tmp_path_factory.mktemp("pytest_code_runner_tests") env_prefix = Path(env_root) / "testenv" if env_prefix.exists(): shutil.rmtree(env_prefix) - print("prefix", env_prefix) channels = ( "-c https://repo.mamba.pm/emscripten-forge -c https://repo.mamba.pm/conda-forge" ) cmd = [ - f"""$MAMBA_EXE create {channels} --yes --prefix {env_prefix} --platform=emscripten-32 python numpy pyjs """ + f"""$MAMBA_EXE create {channels} --yes --prefix {env_prefix} --platform=emscripten-32 python numpy pyjs>=2.7.0""" ] ret = subprocess.run(cmd, shell=True) diff --git a/test/test_cli.py b/test/test_cli.py index 44b0381..1d8fb08 100644 --- a/test/test_cli.py +++ b/test/test_cli.py @@ -20,6 +20,7 @@ def test_help(self, runner): def test_sync_err( self, env_prefix, em_work_dir, backend_cli_settings, tmpdir, runner ): + backend_type, backend_args = backend_cli_settings to_mount_dir = tmpdir