Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
f4bd5f7
Update action.yml
max-models Oct 24, 2025
62253e4
Update action.yml
max-models Oct 24, 2025
810916c
Merge branch 'devel' into 45-only-run-the-unit-tests-which-touch-chan…
max-models Oct 24, 2025
8843cac
Update action.yml
max-models Oct 25, 2025
4cdb2da
Added --testmon to unit tests
max-models Oct 25, 2025
7bdb667
Removed -k from unit tests
max-models Oct 26, 2025
5dbc99e
Put testmon data in cache
max-models Oct 26, 2025
03adb04
Continue if no testmondata is found
max-models Oct 26, 2025
20f978d
Added struphy_verification_tests/ to .gitignore
max-models Oct 26, 2025
6343bf3
--ignore=model/tests
max-models Oct 26, 2025
d5f638b
Check testmon from devel before any other branch.
max-models Oct 26, 2025
ca13950
Added TESTMON_DATAFILE to env
max-models Oct 26, 2025
ac2b016
Added caching of .testmondata at the end of the pipeline
max-models Oct 26, 2025
e033901
Set concurrency with cancel-in-progress: true
max-models Oct 26, 2025
ab9e96e
Moved verification tests into verification/
max-models Oct 26, 2025
0a72627
Specify tests with paths
max-models Oct 26, 2025
97ecf4c
FOrmatting
max-models Oct 26, 2025
d201a74
Moved one unit test
max-models Oct 26, 2025
4cf0c85
Formatting
max-models Oct 26, 2025
768bce9
Removed everything other than the unit test in the CI
max-models Oct 26, 2025
decfd63
Trigger CI
max-models Oct 26, 2025
c69b28c
Moved model tests to tests/model
max-models Oct 26, 2025
c396007
Moved verification tests to tests/verification
max-models Oct 26, 2025
0b82265
Moved all tests into tests/
max-models Oct 26, 2025
5cb8586
Moved the last test
max-models Oct 26, 2025
6a5f232
Fixed incorrect import
max-models Oct 26, 2025
d9a02e9
Removed duplicate testing
max-models Oct 26, 2025
91b8ab7
Cleanup test.py
max-models Oct 26, 2025
8405f95
Separate the cached testmondata depending on the test-type so we aren…
max-models Oct 26, 2025
0c620c4
Cleanup
max-models Oct 26, 2025
f4ce7f8
Fix imports
max-models Oct 26, 2025
1d2502f
Commented out MPI test with --testmon
max-models Oct 26, 2025
cb02222
Formatting
max-models Oct 26, 2025
6b27161
Fixed ls testmon*
max-models Oct 26, 2025
ba29fde
Split unit tests from unit-mpi
max-models Oct 26, 2025
c1f9931
Cleanup
max-models Oct 26, 2025
3de56a4
Run all unit tests
max-models Oct 26, 2025
0905d6e
Skip unit-mpi
max-models Oct 26, 2025
9a0f929
Added conftest.py to the package
max-models Oct 26, 2025
9fc5284
Uncommented MPI unit tests
max-models Oct 27, 2025
e80c507
only run tests/unit/bsplines/ in unit tests
max-models Oct 29, 2025
f4b1228
temp
max-models Oct 29, 2025
ff055b6
Merge branch 'devel' into 45-only-run-the-unit-tests-which-touch-chan…
max-models Oct 29, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/actions/compile/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ runs:
struphy compile -d -y &&
struphy compile -y --language ${{ matrix.compile-language }}
)
struphy compile --status
struphy --refresh-models

10 changes: 10 additions & 0 deletions .github/actions/tests/unit-mpi/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: "Run unit tests with MPI"

runs:
using: composite
steps:
- name: Run unit tests with MPI
shell: bash
run: |
pip install mpi4py
struphy test unit --mpi 2
16 changes: 7 additions & 9 deletions .github/actions/tests/unit/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ name: "Run unit tests"
runs:
using: composite
steps:
- name: Run unit tests with MPI
shell: bash
run: |
struphy compile --status
struphy --refresh-models
struphy test unit --mpi 2

- name: Run unit tests
- name: Uninstall MPI
shell: bash
run: |
struphy compile --status
struphy --refresh-models
pip show mpi4py
pip uninstall -y mpi4py
pip list

- name: Run unit tests without MPI
shell: bash
env:
TESTMON_DATAFILE: ${{ github.workspace }}/.testmondata-${{ matrix.test-type }}
run: |
struphy test unit
6 changes: 3 additions & 3 deletions .github/workflows/macos-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
# - main
# - devel

# # concurrency:
# # group: ${{ github.ref }}
# # cancel-in-progress: true
# concurrency:
# group: ${{ github.workflow }}-${{ github.ref }}
# cancel-in-progress: true

# jobs:
# macos-latest-build:
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/static_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ on:
- main
- devel

# concurrency:
# group: ${{ github.ref }}
# cancel-in-progress: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash
Expand Down
29 changes: 27 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.12"]
compile-language: ["fortran", "c"]
test-type: ["unit", "model", "quickstart", "tutorials"]
compile-language: ["fortran"] #, "c"]
test-type: ["unit"] #, "model", "quickstart", "tutorials"]

steps:
# Checkout the repository
Expand All @@ -43,7 +43,21 @@ jobs:
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-

- uses: actions/cache@v4
with:
path: .testmondata-${{ matrix.test-type }}
key: testmon-${{ matrix.test-type }}-${{ github.sha }}
restore-keys: |
testmon-${{ matrix.test-type }}-${{ github.ref }}-
testmon-${{ matrix.test-type }}-${{ github.ref_name }}-
testmon-${{ matrix.test-type }}-refs/heads/devel-
testmon-${{ matrix.test-type }}-devel-
testmon-${{ matrix.test-type }}-

- name: Check .testmondata
run: ls -la testmon* || echo "No .testmondata"

# Install prereqs
# I don't think it's possible to use a single action for this because
# we can't use ${inputs.os} in an if statement, so we have to use two different actions.
Expand Down Expand Up @@ -81,6 +95,10 @@ jobs:
- name: Run unit tests
if: matrix.test-type == 'unit'
uses: ./.github/actions/tests/unit

- name: Run unit tests with MPI
if: matrix.test-type == 'unit'
uses: ./.github/actions/tests/unit-mpi

- name: Run model tests
if: matrix.test-type == 'model'
Expand All @@ -93,3 +111,10 @@ jobs:
- name: Run tutorials
if: matrix.test-type == 'tutorials'
uses: ./.github/actions/tests/tutorials

# Upload .testmondata as cache for later tests
- uses: actions/cache/save@v4
if: always()
with:
path: .testmondata-${{ matrix.test-type }}
key: testmon-${{ matrix.test-type }}-${{ github.sha }}
6 changes: 3 additions & 3 deletions .github/workflows/ubuntu-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ on:
- main
- devel

# concurrency:
# group: ${{ github.ref }}
# cancel-in-progress: true
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
ubuntu-latest-build:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ code_analysis_report.html
src/struphy/io/out/
src/struphy/state.yml
src/struphy/io/inp/params_*
struphy_verification_tests/

# models list
src/struphy/models/models_list
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dependencies = [
'argcomplete',
'pytest',
'pytest-mpi',
'pytest-testmon',
'line_profiler',
]

Expand Down Expand Up @@ -133,6 +134,7 @@ kinetic-diagnostics = "struphy.diagnostics.console_diagn:main"
struphy = [
"compile_struphy.mk",
"psydac-2.5.0.dev0-py3-none-any.whl",
"conftest.py",
]

[tool.autopep8]
Expand Down Expand Up @@ -184,3 +186,5 @@ markers = [
"hybrid",
"single",
]


86 changes: 72 additions & 14 deletions src/struphy/console/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
import os
import pytest
import struphy
from struphy.utils.utils import subp_run

LIBPATH = struphy.__path__[0]

import pytest
from pathlib import Path

def collect_changed_tests(test_path):
"""Collect changed tests using pytest-testmon, returning full absolute nodeids."""

collected = []

class Collector:
def pytest_collection_modifyitems(self, session, config, items):
for item in items:
abs_path = Path(item.fspath).resolve()
# Keep the test name and parameters after '::'
node_suffix = item.nodeid.split("::", 1)[1] if "::" in item.nodeid else ""
if node_suffix:
full_nodeid = f"{abs_path}::{node_suffix}"
else:
full_nodeid = str(abs_path)
collected.append(full_nodeid)
# Stop after collection phase
raise pytest.UsageError("COLLECT_ONLY")

args = ["--testmon", "--collect-only", "-q", str(test_path)]
print(args)

try:
pytest.main(args, plugins=[Collector()])
except pytest.UsageError:
print('exit')
pass # Expected exit after collection

return collected

def struphy_test(
group: str,
Expand Down Expand Up @@ -35,30 +72,43 @@ def struphy_test(
"""

if "unit" in group:

tests = collect_changed_tests(
f"{LIBPATH}/tests/unit/bsplines/"
)

print(f"{tests = }")

if len(tests) == 0:
print("No changed tests detected!")
return

if mpi > 1:
cmd = [
"mpirun",
"-n",
str(mpi),
"pytest",
"-k",
"not _models and not _tutorial and not pproc",
# "--testmon",
"--with-mpi",
]
else:
cmd = [
"pytest",
"-k",
"not _models and not _tutorial and not pproc",
"--testmon",
]

cmd += tests

if with_desc:
cmd += ["--with-desc"]
if vrbose:
cmd += ["--vrbose"]
if show_plots:
cmd += ["--show-plots"]

# Run in the current directory
cwd = os.getcwd()
subp_run(cmd)

elif group in {"models", "fluid", "kinetic", "hybrid", "toy"}:
Expand All @@ -69,21 +119,21 @@ def struphy_test(
"-n",
str(mpi),
"pytest",
"-k",
"_models",
"-m",
group,
"-s",
# "--testmon",
"--with-mpi",
f"{LIBPATH}/tests/models/",
]
else:
cmd = [
"pytest",
"-k",
"_models",
"-m",
group,
"-s",
"--testmon",
f"{LIBPATH}/tests/models/",
]

if vrbose:
Expand All @@ -92,6 +142,9 @@ def struphy_test(
cmd += ["--nclones", f"{nclones}"]
if show_plots:
cmd += ["--show-plots"]

# Run in the current directory
cwd = os.getcwd()
subp_run(cmd)

elif "verification" in group:
Expand All @@ -102,17 +155,17 @@ def struphy_test(
"-n",
str(mpi),
"pytest",
"-k",
"_verif_",
"-s",
# "--testmon",
"--with-mpi",
f"{LIBPATH}/tests/verification/",
]
else:
cmd = [
"pytest",
"-k",
"_verif_",
"-s",
"--testmon",
f"{LIBPATH}/models/tests/verification/",
]

if vrbose:
Expand All @@ -121,6 +174,9 @@ def struphy_test(
cmd += ["--nclones", f"{nclones}"]
if show_plots:
cmd += ["--show-plots"]

# Run in the current directory
cwd = os.getcwd()
subp_run(cmd)

else:
Expand All @@ -130,11 +186,10 @@ def struphy_test(
"-n",
str(mpi),
"pytest",
"-k",
"_models",
"-m",
"single",
"-s",
# "--testmon",
"--with-mpi",
"--model-name",
group,
Expand All @@ -145,4 +200,7 @@ def struphy_test(
cmd += ["--nclones", f"{nclones}"]
if show_plots:
cmd += ["--show-plots"]

# Run in the current directory
cwd = os.getcwd()
subp_run(cmd)
4 changes: 4 additions & 0 deletions src/struphy/feec/psydac_derham.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ def __init__(
local_projectors: bool = False,
domain: Domain = None,
):




# number of elements, spline degrees and kind of splines in each direction (periodic vs. clamped)
assert len(Nel) == 3
assert len(p) == 3
Expand Down
2 changes: 1 addition & 1 deletion src/struphy/linear_algebra/saddle_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from psydac.linalg.direct_solvers import SparseSolver
from psydac.linalg.solvers import inverse

from struphy.linear_algebra.tests.test_saddlepoint_massmatrices import _plot_residual_norms
from struphy.tests.unit.linear_algebra.test_saddlepoint_massmatrices import _plot_residual_norms
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it a bit odd to import a plotting function from a testing file, should it not be the opposite way around?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes i agree, please correct.



class SaddlePointSolver:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def test_bsplines_span_and_basis(Nel, p, spl_kind):
from struphy.feec.psydac_derham import Derham
from struphy.feec.utilities import create_equal_random_arrays as cera




comm = MPI.COMM_WORLD
rank = comm.Get_rank()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def pc_lin_mhd_6d_step_ph_full(Nel, p, spl_kind, mapping, Np, verbose=False):
from struphy.pic.accumulation import accum_kernels
from struphy.pic.accumulation.particles_to_grid import Accumulator
from struphy.pic.particles import Particles6D
from struphy.pic.tests.test_pic_legacy_files.accumulation_kernels_3d import kernel_step_ph_full
from struphy.pic.utilities import BoundaryParameters, LoadingParameters, WeightsParameters
from struphy.tests.unit.pic.test_pic_legacy_files.accumulation_kernels_3d import kernel_step_ph_full

if isinstance(MPI.COMM_WORLD, MockComm):
mpi_comm = None
Expand Down
Loading
Loading