Skip to content

Commit e1d6cb7

Browse files
authored
translate exception (#16)
* translate exception
1 parent 0d36f65 commit e1d6cb7

File tree

6 files changed

+65
-26
lines changed

6 files changed

+65
-26
lines changed

.github/workflows/main.yaml

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,47 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v2
1919

20+
2021
- name: Get number of CPU cores
2122
uses: SimenB/github-actions-cpu-cores@v1
22-
23+
24+
- name: apt-install
25+
run: |
26+
sudo apt-get update -y && sudo apt-get install -y \
27+
libwoff1 libvpx9 libevent-2.1-7t64 libopus0 libgstreamer-plugins-base1.0-0 \
28+
libgstreamer-gl1.0-0 \
29+
libgstreamer-plugins-bad1.0-0 \
30+
libflite1 \
31+
libavif16 \
32+
libharfbuzz-icu0 \
33+
libsecret-1-0 \
34+
libhyphen0 \
35+
libmanette-0.2-0 \
36+
libgles2 \
37+
gstreamer1.0-libav
38+
2339
- name: Install mamba
24-
uses: mamba-org/provision-with-micromamba@main
40+
uses: mamba-org/setup-micromamba@v2
2541
with:
2642
environment-file: dev-env.yml
2743
environment-name: dev-env
28-
micromamba-version: "1.4.1"
29-
44+
init-shell: >-
45+
bash
46+
3047
- name: Install Playwright
48+
shell: bash -el {0}
3149
run: |
3250
playwright install
3351
3452
- name: Install pyjs-code-runner
53+
shell: bash -el {0}
3554
run: |
36-
micromamba activate dev-env
3755
python -m pip install . --no-deps
3856
3957
- name: Run Tests
58+
shell: bash -el {0}
4059
run: |
41-
micromamba activate dev-env
42-
pytest -s
60+
pytest -s -vvvvv
4361
4462
4563
test_with_pip:
@@ -50,20 +68,34 @@ jobs:
5068
- name: Get number of CPU cores
5169
uses: SimenB/github-actions-cpu-cores@v1
5270

71+
- name: apt-install
72+
run: |
73+
sudo apt-get update -y && sudo apt-get install -y \
74+
libwoff1 libvpx9 libevent-2.1-7t64 libopus0 libgstreamer-plugins-base1.0-0 \
75+
libgstreamer-gl1.0-0 \
76+
libgstreamer-plugins-bad1.0-0 \
77+
libflite1 \
78+
libavif16 \
79+
libharfbuzz-icu0 \
80+
libsecret-1-0 \
81+
libhyphen0 \
82+
libmanette-0.2-0 \
83+
libgles2 \
84+
gstreamer1.0-libav
85+
5386
- name: Install mamba
54-
uses: mamba-org/provision-with-micromamba@main
87+
uses: mamba-org/setup-micromamba@v2
5588
with:
5689
environment-file: dev-env-pip.yml
5790
environment-name: dev-env
58-
micromamba-version: "1.4.1"
5991

6092
- name: Install pyjs-code-runner
93+
shell: bash -el {0}
6194
run: |
62-
micromamba activate dev-env
6395
python -m pip install .
6496
playwright install
65-
97+
6698
- name: Run Tests
99+
shell: bash -el {0}
67100
run: |
68-
micromamba activate dev-env
69-
pytest -s
101+
pytest -s -vvvvv

dev-env-pip.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@ channels:
44
dependencies:
55
- python
66
- pip
7-
- emsdk
8-
- pytest
7+
- pytest
8+
- pytest-sugar
9+
- typer
10+
- appdirs
11+
- empack >=3,<4
12+
- rich

dev-env.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ dependencies:
55
- python
66
- pip
77
- pytest
8+
- pytest-sugar
89
- typer
910
- appdirs
1011
- empack >=3,<4
1112
- microsoft::playwright
1213
- emsdk
13-
- rich
14+
- rich

pyjs_code_runner/js/utils.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ function eval_main_script(pyjs, workdir, filename) {
3939
return 0;
4040
}
4141
catch (e) {
42-
console.error("error while evaluating main file:", e)
42+
if (typeof e === "number") {
43+
const msg = get_exception_message(e);
44+
console.error("error while evaluating main file:", msg)
45+
}
46+
else {
47+
console.error("error while evaluating main file:", e)
48+
}
4349
return 1;
4450
}
4551
return 0

test/conftest.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,25 @@
66
from typer.testing import CliRunner
77
import os
88

9-
# @pytest.fixture(scope="session")
10-
# def session_temp_path(tmp_path_factory):
11-
# return tmp_path_factory.mktemp()
12-
139
ON_GITHUB_ACTIONS = False
1410
if "GITHUB_ACTION" in os.environ:
1511
ON_GITHUB_ACTIONS = True
1612

1713

1814
@pytest.fixture(scope="session")
19-
def env_prefix():
20-
env_root = Path(appdirs.user_data_dir("pytest_code_runner_tests", "DerThorsten"))
21-
env_root.mkdir(exist_ok=True, parents=True)
15+
def env_prefix(tmp_path_factory):
16+
17+
env_root = tmp_path_factory.mktemp("pytest_code_runner_tests")
2218
env_prefix = Path(env_root) / "testenv"
2319

2420
if env_prefix.exists():
2521
shutil.rmtree(env_prefix)
2622

27-
print("prefix", env_prefix)
2823
channels = (
2924
"-c https://repo.mamba.pm/emscripten-forge -c https://repo.mamba.pm/conda-forge"
3025
)
3126
cmd = [
32-
f"""$MAMBA_EXE create {channels} --yes --prefix {env_prefix} --platform=emscripten-32 python numpy pyjs """
27+
f"""$MAMBA_EXE create {channels} --yes --prefix {env_prefix} --platform=emscripten-32 python numpy pyjs>=2.7.0"""
3328
]
3429

3530
ret = subprocess.run(cmd, shell=True)

test/test_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def test_help(self, runner):
2020
def test_sync_err(
2121
self, env_prefix, em_work_dir, backend_cli_settings, tmpdir, runner
2222
):
23+
2324
backend_type, backend_args = backend_cli_settings
2425

2526
to_mount_dir = tmpdir

0 commit comments

Comments
 (0)