Run everything from WSL via tools/mrun. This folder assumes MATLAB R2024a
on the Windows side (see ../tools/mrun and the FlowSim vectorization project
AEGIS policy at <axon>/my-axon/dev-projects/flowsim-vectorize/_policy.md).
π§π· Versao em portugues:
tests/LEIAME.md
tests/
βββ README.md # this file
βββ run_all.m # top-level runner β invokes smoke/*, unit/*, prints report
βββ run_smoke.m # only the smoke tests (fast: env sanity, class loads)
βββ run_unit.m # only the unit tests (medium: per-function oracle diffs)
βββ helpers/ # test infrastructure β assertions, oracle-diff, fixtures
β βββ fs_expect.m # simple assertion (fs_expect(cond, msg))
β βββ fs_reltol.m # relative-tolerance comparator
β βββ fs_frob.m # Frobenius relative diff on sparse/dense matrices
β βββ fs_setup.m # standard test setup: addpath, seed rng, capture t0
β βββ fs_teardown.m # cleanup: report elapsed, restore rng
β βββ fs_load_mesh.m # load a canonical mesh by name (M8, HermelineQuad_12, ...)
βββ smoke/ # fast (seconds) β sanity checks, no numerical claims
β βββ smoke_env.m # MATLAB version, WSL cwd, paths configured
β βββ smoke_class_hierarchy.m # verify OOP hierarchy state (which classes load)
β βββ smoke_mesh_load.m # every .msh in meshes/ loads and reports node/elem counts
β βββ smoke_startdat.m # Start.dat parses; report numcase, pmethod, phasekey
βββ unit/ # medium (10-60 s per test) β per-function correctness
β βββ unit_preprocessormod.m # mesh build produces expected shapes/counts
β βββ unit_lpew2_reference.m # baseline LPEW2 output on a small mesh β captures in golden/
β βββ unit_assembly_mpfad.m # MPFA-D assembly nnz, condest, first-5 pressure values
β βββ unit_richards_caso439.m # one Picard iteration of Caso439 completes + numerical fingerprint
βββ golden/ # captured baseline outputs (committed; regenerated with --update)
β βββ (populated by unit tests on first run)
βββ data/ # small test fixtures (tiny meshes, canned Start.dat variants)
βββ (empty until tests need them)
# Full harness (smoke + unit)
tools/mrun -c $(pwd) tests/run_all.m
# Just smoke tests (fast, ~1 min total)
tools/mrun -c $(pwd) tests/run_smoke.m
# One specific test
tools/mrun -c $(pwd) tests/smoke/smoke_env.m
# One unit test with auto-log
tools/mrun -L -c $(pwd) tests/unit/unit_lpew2_reference.mEach test script:
- Calls
fs_setupat the start (paths, rng seed, timer). - Uses
fs_expect(cond, msg)for assertions β first failure prints then continues; final summary reports pass/fail count. - Ends with
fs_teardownwhich printsTEST OKorTEST FAIL: N failuresand exits with 0 or 1. - Numerical unit tests read/write baselines in
golden/<test-name>.mat. On first run they capture. On subsequent runs they compare within tolerance.
Default per fs_frob.m:
- Sparse-matrix Frobenius relative:
1e-12 - Dense-vector L2 relative:
1e-10 - Scalar relative:
1e-10 condestallowed drift:10Γ ratio
Override per-call via fs_frob(A, B, tol).
- No third-party test framework β MATLAB has
matlab.unittestbut adds overhead; for a code-dev study harness, plain scripts +fs_expectare simpler and diff cleanly under version control. - Golden files are
.mat(binary) β deterministic, small, git-friendly for scalars but ignored for large fields via.gitignore(see next section). - Tests are runnable one-at-a-time so a failing unit doesn't halt the batch.
- No side-effects outside
tests/β every test creates its scratch intests/data/tmp/and cleans up infs_teardown.
Add to .gitignore:
tests/data/tmp/
tests/golden/*.big.mat # over-100KB baselines stay local