Skip to content

Commit 8e653c8

Browse files
authored
Add nox for running tests in an isolated environment (#140)
* Add nox for running tests in an isolated environment * Locate build module on Windows
1 parent 25c6117 commit 8e653c8

File tree

5 files changed

+39
-28
lines changed

5 files changed

+39
-28
lines changed

.github/workflows/test.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
set -e
22

3+
PLATFORM=$(python -c 'import sys; print(sys.platform)')
4+
35
RED="\033[31;1m"
46
MAGENTA="\033[35m"
57
NORMAL="\033[0m"
@@ -9,6 +11,8 @@ prun() { echo -e "\n$RED\$ $@ $NORMAL\n" ; "$@" ; }
911
prun cd example_pkg
1012

1113
prun spin --version
14+
15+
pip install meson-python ninja
1216
prun spin build
1317

1418
# Test spin run
@@ -40,4 +44,16 @@ PYTHONPATH=./tmp spin test
4044

4145
prun spin sdist
4246
prun spin example
47+
48+
pip install sphinx
4349
prun spin docs
50+
51+
## Platform specialized tests
52+
53+
if [[ $PLATFORM == linux ]]; then
54+
prun spin gdb -c 'import example_pkg; example_pkg.echo("hi")' -- --eval "run" --batch
55+
fi
56+
57+
# if [[ $PLATFORM == darwin ]]; then
58+
59+
# if [[ $PLATFORM =~ ^win.* ]]; then

.github/workflows/test.yml

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,31 +29,6 @@ jobs:
2929
run: |
3030
sudo apt-get update
3131
sudo apt-get install -y gdb
32-
- name: Install
32+
- name: Tests
3333
run: |
34-
pip install -e .
35-
pip install pytest meson-python ninja build sphinx
36-
- name: Library tests
37-
env:
38-
PYTHONPATH: "."
39-
run: |
40-
pytest --pyargs spin
41-
42-
- name: Functional tests (Linux)
43-
if: matrix.os == 'ubuntu-latest'
44-
shell: 'script -q -e -c "bash --noprofile --norc -eo pipefail {0}"'
45-
env:
46-
TERM: xterm-256color
47-
run: |
48-
source .github/workflows/test.sh
49-
spin gdb -c 'import example_pkg; example_pkg.echo("hi")' -- --eval "run" --batch
50-
51-
- name: Functional tests (MacOS)
52-
if: matrix.os == 'macos-latest'
53-
shell: bash
54-
run: source .github/workflows/test.sh
55-
56-
- name: Functional tests (Windows)
57-
if: matrix.os == 'windows-latest'
58-
shell: bash
59-
run: source .github/workflows/test.sh
34+
pipx run nox --forcecolor -s tests

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,15 @@ sudo pacman -S noto-fonts-emoji
203203
fc-cache -f -v
204204
```
205205

206+
## For contributors
207+
208+
`spin` development happens on GitHub at [scientific-python/spin](https://github.com/scientific-python/spin).
209+
`spin` tests are invoked using:
210+
211+
```
212+
nox -s tests
213+
```
214+
206215
## History
207216

208217
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)).

noxfile.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import nox
2+
3+
4+
@nox.session
5+
def tests(session: nox.Session) -> None:
6+
"""
7+
Run the unit and regular tests.
8+
"""
9+
session.install(".", "pytest", "build")
10+
session.run("pytest", "spin", *session.posargs)
11+
session.run("bash", ".github/workflows/test.sh", external=True)

spin/cmds/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
@click.command()
77
def sdist():
88
"""📦 Build a source distribution in `dist/`"""
9-
run(["python", "-m", "build", ".", "--sdist"])
9+
run(["pyproject-build", ".", "--sdist"])

0 commit comments

Comments
 (0)