flow
1.3.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
test_no_env_knobs.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
"""QUALITY_PLAN decision D3 guard: no environment variable in `src/` may change a result.
3
4
Package E (2026-09-08) turned every numerics-changing / algorithm-selecting `PECLET_FLOW_*` read
5
into a solver setter or deleted it with the ablation it served. What is still allowed to be read
6
from the environment is instrumentation only -- `*_DEBUG`, `*_VERBOSE`, `*_PROFILE*`, `*_TIMEOUT`,
7
`GPU_AWARE_MPI` -- because none of it touches an arithmetic path. This test fails if a new
8
`getenv` appears in `src/` outside that allow-list, which is the whole point: the next knob has to
9
be a setter.
10
"""
11
import
pathlib
12
import
re
13
import
sys
14
15
ALLOWED = re.compile(
r"_DEBUG(_[A-Z0-9_]+)?$|_VERBOSE$|_PROFILE|_TIMEOUT$|^GPU_AWARE_MPI$"
)
16
GETENV = re.compile(
r'getenv\(\s*"([A-Za-z0-9_]+)"'
)
17
18
SRC = pathlib.Path(__file__).resolve().parents[2] /
"src"
19
20
21
def
test_no_numerics_env_knobs
():
22
offenders = []
23
for
path
in
sorted(SRC.rglob(
"*"
)):
24
if
path.suffix
not
in
(
".hpp"
,
".cpp"
,
".h"
):
25
continue
26
for
lineno, line
in
enumerate(path.read_text().splitlines(), 1):
27
for
name
in
GETENV.findall(line):
28
if
not
ALLOWED.search(name):
29
offenders.append(f
"{path.relative_to(SRC.parent)}:{lineno}: {name}"
)
30
assert
not
offenders, (
31
"environment variables that can change a result found in src/ (QUALITY_PLAN D3 -- make it "
32
"a setter):\n "
+
"\n "
.join(offenders)
33
)
34
35
36
if
__name__ ==
"__main__"
:
37
try
:
38
test_no_numerics_env_knobs
()
39
except
AssertionError
as
e:
40
print(e)
41
sys.exit(1)
42
print(
"no numerics-changing environment reads in src/ [OK]"
)
test_no_env_knobs.test_no_numerics_env_knobs
test_no_numerics_env_knobs()
Definition
test_no_env_knobs.py:21
tests
python
test_no_env_knobs.py
Generated by
1.9.8