Skip to content

Commit 15c97c4

Browse files
authored
Merge pull request #1871 from CEED/zach/default-test-name
ci - add default test name (file name)
2 parents 65219c4 + 7b1ec88 commit 15c97c4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/junit_common.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def find_matching(line: str, open: str = '(', close: str = ')') -> Tuple[int, in
290290
return start, -1
291291

292292

293-
def parse_test_line(line: str) -> TestSpec:
293+
def parse_test_line(line: str, fallback_name: str = '') -> TestSpec:
294294
"""Parse a single line of TESTARGS and CLI arguments into a `TestSpec` object
295295
296296
Args:
@@ -341,6 +341,9 @@ def parse_test_line(line: str) -> TestSpec:
341341

342342
line = line[end + 1:]
343343

344+
if not 'name' in known.keys():
345+
known['name'] = fallback_name
346+
344347
args_pattern = re.compile(r'''
345348
\s+( # remove leading space
346349
(?:"[^"]+") # match quoted CLI option
@@ -377,9 +380,9 @@ def get_test_args(source_file: Path) -> List[TestSpec]:
377380
else:
378381
raise RuntimeError(f'Unrecognized extension for file: {source_file}')
379382

380-
return [parse_test_line(line.strip(comment_str).removeprefix("TESTARGS"))
383+
return [parse_test_line(line.strip(comment_str).removeprefix("TESTARGS"), source_file.stem)
381384
for line in source_file.read_text().splitlines()
382-
if line.startswith(f'{comment_str}TESTARGS')] or [TestSpec('', args=['{ceed_resource}'])]
385+
if line.startswith(f'{comment_str}TESTARGS')] or [TestSpec(source_file.stem, args=['{ceed_resource}'])]
383386

384387

385388
def diff_csv(test_csv: Path, true_csv: Path, zero_tol: float, rel_tol: float,

0 commit comments

Comments
 (0)