Skip to content

Commit 8426a0d

Browse files
authored
simplify test.py to only do regression tests (#117)
this also now returns the number of failures as the OS return code so this can be used via a github action
1 parent c964284 commit 8426a0d

11 files changed

+114
-110
lines changed

.github/workflows/regtest.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: regtest
2+
3+
on:
4+
# Trigger the workflow on push or pull request,
5+
# but only for the main branch
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
branches:
11+
- main
12+
13+
jobs:
14+
regresion-tests:
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
python-version: ["3.8", "3.9", "3.10"]
20+
21+
steps:
22+
- uses: actions/checkout@v3
23+
24+
- name: Install Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Cache pip
30+
uses: actions/cache@v3
31+
with:
32+
# this path is specific to Ubuntu
33+
path: ~/.cache/pip
34+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
35+
restore-keys: |
36+
${{ runner.os }}-pip-
37+
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install --upgrade pip
41+
pip install -r requirements.txt
42+
43+
- name: Install pyro
44+
run: python setup.py install --user
45+
46+
- name: Run tests via test.py
47+
run: PYTHONPATH=$GITHUB_WORKSPACE ./test.py
48+

README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
1+
[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
22
[![pylint](https://github.com/python-hydro/pyro2/actions/workflows/pylint.yml/badge.svg)](https://github.com/python-hydro/pyro2/actions/workflows/pylint.yml)
33
[![flake8](https://github.com/python-hydro/pyro2/actions/workflows/flake8.yml/badge.svg)](https://github.com/python-hydro/pyro2/actions/workflows/flake8.yml)
44
[![pytest-all](https://github.com/python-hydro/pyro2/actions/workflows/pytest.yml/badge.svg)](https://github.com/python-hydro/pyro2/actions/workflows/pytest.yml)
55

6-
[![Documentation Status](https://readthedocs.org/projects/pyro2/badge/?version=latest)](https://pyro2.readthedocs.io/en/latest/?badge=latest)
6+
[![Documentation Status](https://readthedocs.org/projects/pyro2/badge/?version=latest)](https://pyro2.readthedocs.io/en/latest/?badge=latest)
77

8-
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/python-hydro/pyro2/main?filepath=examples%2Fexamples.ipynb)
8+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/python-hydro/pyro2/main?filepath=examples%2Fexamples.ipynb)
99

10-
[![JOSS status](http://joss.theoj.org/papers/6d8b2f94e6d08a7b5d65e98a948dcad7/status.svg)](http://joss.theoj.org/papers/6d8b2f94e6d08a7b5d65e98a948dcad7)
10+
[![JOSS status](http://joss.theoj.org/papers/6d8b2f94e6d08a7b5d65e98a948dcad7/status.svg)](http://joss.theoj.org/papers/6d8b2f94e6d08a7b5d65e98a948dcad7)
1111
[![DOI](https://zenodo.org/badge/20570861.svg)](https://zenodo.org/badge/latestdoi/20570861)
1212

1313

@@ -246,15 +246,14 @@ with their data.
246246

247247
The `test.py` script will run several of the problems (as well as some
248248
stand-alone multigrid tests) and compare the solution to stored
249-
benchmarks (in each solver's `tests/` subdirectory).
249+
benchmarks (in each solver's `tests/` subdirectory). The return value
250+
of the script is the number of tests that failed.
250251

251-
It will also invoke the python `pytest` module to run the unit tests
252-
for the different modules in pyro.
253-
254-
Tests are run nightly and reported here:
255-
256-
http://bender.astro.sunysb.edu/hydro_by_example/download/_stage/pyro2/tests.out
252+
Unit tests are controlled by pytest and can be run simply via
257253

254+
```
255+
pytest .
256+
```
258257

259258
## Acknowledgements
260259

examples/multigrid/mg_test_general_alphabeta_only.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def f(x, y):
7070
16.0*np.pi**2 + 1.0)*np.sin(2*np.pi*x)*np.sin(2*np.pi*y)
7171

7272

73-
def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False,
73+
def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False, bench_dir="tests/",
7474
make_plot=False, verbose=1, rtol=1.e-12):
7575
"""
7676
test the general MG solver. The return value
@@ -173,7 +173,6 @@ def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False,
173173

174174
# store the output for later comparison
175175
bench = "mg_general_poisson_dirichlet"
176-
bench_dir = os.environ["PYRO_HOME"] + "/multigrid/tests/"
177176

178177
my_data = a.get_solution_object()
179178

examples/multigrid/mg_test_general_beta_only.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def f(x, y):
7070
np.sin(2*np.pi*x)*np.sin(2*np.pi*y)
7171

7272

73-
def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False,
73+
def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False, bench_dir="tests/",
7474
make_plot=False, verbose=1, rtol=1.e-12):
7575
"""
7676
test the general MG solver. The return value
@@ -173,7 +173,6 @@ def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False,
173173

174174
# store the output for later comparison
175175
bench = "mg_general_poisson_dirichlet"
176-
bench_dir = os.environ["PYRO_HOME"] + "/multigrid/tests/"
177176

178177
my_data = a.get_solution_object()
179178

examples/multigrid/mg_test_general_constant.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def f(x, y):
5656
return -2.0*((1.0-6.0*x**2)*y**2*(1.0-y**2) + (1.0-6.0*y**2)*x**2*(1.0-x**2))
5757

5858

59-
def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False,
59+
def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False, bench_dir="tests/",
6060
make_plot=False, verbose=1, rtol=1.e-12):
6161
"""
6262
test the general MG solver. The return value
@@ -159,7 +159,6 @@ def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False,
159159

160160
# store the output for later comparison
161161
bench = "mg_general_poisson_dirichlet"
162-
bench_dir = os.environ["PYRO_HOME"] + "/multigrid/tests/"
163162

164163
my_data = a.get_solution_object()
165164

examples/multigrid/mg_test_general_dirichlet.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def f(x, y):
7575
16.0*np.pi**2 + 1.0)*np.sin(2*np.pi*x)*np.sin(2*np.pi*y)
7676

7777

78-
def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False,
78+
def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False, bench_dir="tests/",
7979
make_plot=False, verbose=1, rtol=1.e-12):
8080
"""
8181
test the general MG solver. The return value
@@ -178,7 +178,6 @@ def test_general_poisson_dirichlet(N, store_bench=False, comp_bench=False,
178178

179179
# store the output for later comparison
180180
bench = "mg_general_poisson_dirichlet"
181-
bench_dir = os.environ["PYRO_HOME"] + "/multigrid/tests/"
182181

183182
my_data = a.get_solution_object()
184183

examples/multigrid/mg_test_general_inhomogeneous.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def yl_func(x):
8989
return np.cos(np.pi*x/2.0)
9090

9191

92-
def test_general_poisson_inhomogeneous(N, store_bench=False, comp_bench=False,
92+
def test_general_poisson_inhomogeneous(N, store_bench=False, comp_bench=False, bench_dir="tests/",
9393
make_plot=False, verbose=1, rtol=1.e-12):
9494
"""
9595
test the general MG solver. The return value
@@ -196,7 +196,6 @@ def test_general_poisson_inhomogeneous(N, store_bench=False, comp_bench=False,
196196

197197
# store the output for later comparison
198198
bench = "mg_general_poisson_inhomogeneous"
199-
bench_dir = os.environ["PYRO_HOME"] + "/multigrid/tests/"
200199

201200
my_data = a.get_solution_object()
202201

examples/multigrid/mg_test_simple.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def f(x, y):
3636
return -2.0*((1.0-6.0*x**2)*y**2*(1.0-y**2) + (1.0-6.0*y**2)*x**2*(1.0-x**2))
3737

3838

39-
def test_poisson_dirichlet(N, store_bench=False, comp_bench=False,
39+
def test_poisson_dirichlet(N, store_bench=False, comp_bench=False, bench_dir="tests/",
4040
make_plot=False, verbose=1, rtol=1e-12):
4141

4242
# test the multigrid solver
@@ -89,7 +89,6 @@ def test_poisson_dirichlet(N, store_bench=False, comp_bench=False,
8989

9090
# store the output for later comparison
9191
bench = "mg_poisson_dirichlet"
92-
bench_dir = os.environ["PYRO_HOME"] + "/multigrid/tests/"
9392

9493
my_data = a.get_solution_object()
9594

examples/multigrid/mg_test_vc_dirichlet.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def f(x, y):
5656
np.sin(2*np.pi*x)*np.sin(2*np.pi*y)
5757

5858

59-
def test_vc_poisson_dirichlet(N, store_bench=False, comp_bench=False,
59+
def test_vc_poisson_dirichlet(N, store_bench=False, comp_bench=False, bench_dir="tests/",
6060
make_plot=False, verbose=1, rtol=1.e-12):
6161
"""
6262
test the variable-coefficient MG solver. The return value
@@ -147,7 +147,6 @@ def test_vc_poisson_dirichlet(N, store_bench=False, comp_bench=False,
147147

148148
# store the output for later comparison
149149
bench = "mg_vc_poisson_dirichlet"
150-
bench_dir = os.environ["PYRO_HOME"] + "/multigrid/tests/"
151150

152151
my_data = a.get_solution_object()
153152

examples/multigrid/mg_test_vc_periodic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def f(x, y):
5656
np.sin(2*np.pi*x)*np.sin(2*np.pi*y)
5757

5858

59-
def test_vc_poisson_periodic(N, store_bench=False, comp_bench=False,
59+
def test_vc_poisson_periodic(N, store_bench=False, comp_bench=False, bench_dir="tests/",
6060
make_plot=False, verbose=1, rtol=1.e-12):
6161
"""
6262
test the variable-coefficient MG solver. The return value
@@ -157,7 +157,6 @@ def test_vc_poisson_periodic(N, store_bench=False, comp_bench=False,
157157

158158
# store the output for later comparison
159159
bench = "mg_vc_poisson_periodic"
160-
bench_dir = os.environ["PYRO_HOME"] + "/multigrid/tests/"
161160

162161
my_data = a.get_solution_object()
163162

0 commit comments

Comments
 (0)