Skip to content

Commit

Permalink
Run template test in docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
pvandyken committed Feb 1, 2024
1 parent 8477be6 commit 5acabfd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
3 changes: 2 additions & 1 deletion containers/test-template/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ ARG PYTHON_VERSION=3.11
FROM python:${PYTHON_VERSION}-slim

# Install and uninstall snakebids to cache it and it's dependences
RUN apt-get update && apt-get install -y gcc && \
RUN apt-get update && apt-get install -y gcc git && \
rm -rf /var/lib/apt/lists/* && \
git config --global --add safe.directory /src && \
python -m pip install pipx && \
pipx install poetry && \
pipx install hatch && \
Expand Down
3 changes: 3 additions & 0 deletions containers/test-template/test-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ case "$method" in
"setuptools" )
python -m venv .venv
.venv/bin/python -m pip install .
if [ -d /src ]; then
.venv/bin/python -m pip install /src
fi
PATH=".venv/bin:$PATH" eval "$script"
;;
"poetry" )
Expand Down
22 changes: 13 additions & 9 deletions snakebids/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ def test_template_dry_runs_successfully(tmp_path: Path, build: BuildBackend, ven
assert "All set" in cmd.stdout.decode()


def test_template_dry_runs_with_current_repository(tmp_path: Path):
def test_template_dry_runs_with_current_repository(
tmp_path: Path, request: pytest.FixtureRequest
):
app_name = "snakebids_app"
data = get_empty_data(app_name, "setuptools")

Expand All @@ -316,16 +318,18 @@ def test_template_dry_runs_with_current_repository(tmp_path: Path):
data=data,
unsafe=True,
)
app_path = tmp_path / app_name
cmd = sp.run(
[
sys.executable,
app_path / app_name / "run.py",
app_path / "tests/data",
app_path / "tests/results",
"participant",
"-c1",
"--skip-bids-validation",
"docker",
"run",
"-v",
f"{tmp_path / app_name}:/app",
"-v",
f"{request.config.rootpath}:/src",
"--rm",
f"snakebids/test-template:{platform.python_version()}",
"setuptools",
app_name,
],
capture_output=True,
check=False,
Expand Down

0 comments on commit 5acabfd

Please sign in to comment.