Skip to content

Commit a793685

Browse files
authored
Merge pull request #1472 from CEED/jeremy/cgns-tol
junit - allow looser CGNS tol
2 parents 35bce4b + c0ad81e commit a793685

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

tests/junit_common.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ def get_output_path(self, test: str, output_file: str) -> Path:
9797
"""
9898
raise NotImplementedError
9999

100+
@property
101+
def cgns_tol(self):
102+
"""Absolute tolerance for CGNS diff"""
103+
return getattr(self, '_cgns_tol', 1.0e-12)
104+
105+
@cgns_tol.setter
106+
def cgns_tol(self, val):
107+
self._cgns_tol = val
108+
100109
def post_test_hook(self, test: str, spec: TestSpec) -> None:
101110
"""Function callback ran after each test case
102111
@@ -304,20 +313,20 @@ def diff_csv(test_csv: Path, true_csv: Path, zero_tol: float = 3e-10, rel_tol: f
304313
return '\n'.join(diff_lines)
305314

306315

307-
def diff_cgns(test_cgns: Path, true_cgns: Path, tolerance: float = 1e-12) -> str:
316+
def diff_cgns(test_cgns: Path, true_cgns: Path, cgns_tol: float = 1e-12) -> str:
308317
"""Compare CGNS results against an expected CGSN file with tolerance
309318
310319
Args:
311320
test_cgns (Path): Path to output CGNS file
312321
true_cgns (Path): Path to expected CGNS file
313-
tolerance (float, optional): Tolerance for comparing floating-point values
322+
cgns_tol (float, optional): Tolerance for comparing floating-point values
314323
315324
Returns:
316325
str: Diff output between result and expected CGNS files
317326
"""
318327
my_env: dict = os.environ.copy()
319328

320-
run_args: List[str] = ['cgnsdiff', '-d', '-t', f'{tolerance}', str(test_cgns), str(true_cgns)]
329+
run_args: List[str] = ['cgnsdiff', '-d', '-t', f'{cgns_tol}', str(test_cgns), str(true_cgns)]
321330
proc = subprocess.run(' '.join(run_args),
322331
shell=True,
323332
stdout=subprocess.PIPE,
@@ -487,7 +496,7 @@ def run_test(index: int, test: str, spec: TestSpec, backend: str,
487496
if not ref_cgn.is_file():
488497
test_case.add_failure_info('cgns', output=f'{ref_cgn} not found')
489498
else:
490-
diff = diff_cgns(Path.cwd() / cgn_name, ref_cgn)
499+
diff = diff_cgns(Path.cwd() / cgn_name, ref_cgn, cgns_tol=suite_spec.cgns_tol)
491500
if diff:
492501
test_case.add_failure_info('cgns', output=diff)
493502
else:

0 commit comments

Comments
 (0)