Skip to content

Commit

Permalink
Add nox for running tests in an isolated environment
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanv committed Nov 9, 2023
1 parent 25c6117 commit 8b25bb7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ NORMAL="\033[0m"

prun() { echo -e "\n$RED\$ $@ $NORMAL\n" ; "$@" ; }

# Required for building example_pkg
pip install meson-python ninja

prun cd example_pkg

prun spin --version
Expand Down
22 changes: 5 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,19 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y gdb
- name: Install
run: |
pip install -e .
pip install pytest meson-python ninja build sphinx
- name: Library tests
env:
PYTHONPATH: "."
run: |
pytest --pyargs spin
- name: Functional tests (Linux)
if: matrix.os == 'ubuntu-latest'
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
env:
TERM: xterm-256color
run: |
source .github/workflows/test.sh
pipx run nox --forcecolor -s tests
spin gdb -c 'import example_pkg; example_pkg.echo("hi")' -- --eval "run" --batch
- name: Functional tests (MacOS)
if: matrix.os == 'macos-latest'
shell: bash
run: source .github/workflows/test.sh
run: |
pipx run nox --forcecolor -s tests
- name: Functional tests (Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: source .github/workflows/test.sh
run: |
pipx run nox --forcecolor -s tests
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ sudo pacman -S noto-fonts-emoji
fc-cache -f -v
```

## For contributors

`spin` development happens on GitHub at [scientific-python/spin](https://github.com/scientific-python/spin).
`spin` tests are invoked using:

```
nox -s tests
```

## History

The `dev.py` tool was [proposed for SciPy](https://github.com/scipy/scipy/issues/15489) by Ralf Gommers and [implemented](https://github.com/scipy/scipy/pull/15959) by Sayantika Banik, Eduardo Naufel Schettino, and Ralf Gommers (also see [Sayantika's blog post](https://labs.quansight.org/blog/the-evolution-of-the-scipy-developer-cli)).
Expand Down
11 changes: 11 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import nox


@nox.session
def tests(session: nox.Session) -> None:
"""
Run the unit and regular tests.
"""
session.install(".", "pytest", "build")
session.run("pytest", "spin", *session.posargs)
session.run("bash", ".github/workflows/test.sh", external=True)

0 comments on commit 8b25bb7

Please sign in to comment.