Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

junit - handle tests without names #1419

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
14 changes: 8 additions & 6 deletions tests/junit_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,16 @@ def diff_cgns(test_cgns: Path, true_cgns: Path, tolerance: float = 1e-12) -> str

def test_case_output_string(test_case: TestCase, spec: TestSpec, mode: RunMode,
backend: str, test: str, index: int) -> str:
output_str = ''
output_str: str = ''
if mode is RunMode.TAP:
# print incremental output if TAP mode
test_name_str: str = f'{spec.name}, ' if spec.name else ''
if test_case.is_skipped():
output_str += f' ok {index} - {spec.name}, {backend} # SKIP {test_case.skipped[0]["message"]}\n'
output_str += f' ok {index} - {test_name_str}{backend} # SKIP {test_case.skipped[0]["message"]}\n'
elif test_case.is_failure() or test_case.is_error():
output_str += f' not ok {index} - {spec.name}, {backend}\n'
output_str += f' not ok {index} - {test_name_str}{backend}\n'
else:
output_str += f' ok {index} - {spec.name}, {backend}\n'
output_str += f' ok {index} - {test_name_str}{backend}\n'
output_str += f' ---\n'
if spec.only:
output_str += f' only: {",".join(spec.only)}\n'
Expand Down Expand Up @@ -384,8 +385,9 @@ def run_test(index: int, test: str, spec: TestSpec, backend: str,

# run test
skip_reason: str = suite_spec.check_pre_skip(test, spec, backend, nproc)
test_name_str: str = f'"{spec.name}", ' if spec.name else ''
Copy link
Member

Choose a reason for hiding this comment

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

Should we require that all tests be named (many testing frameworks do), or perhaps automatically assign them names?

Copy link
Member Author

Choose a reason for hiding this comment

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

Adding names would be a lot of changes to almost every test file. I'm not opposed, but its also another thing to manually change every time we make a new test. I could go either way

Copy link
Member

Choose a reason for hiding this comment

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

It looks like every file with more than one test names them. We could assert that (if you have multiple tests they all need names), but I feel like the sed operation to add name="default", to all the unnamed ones in t*.c files is also fine. One thing I've considered is using libtest-mimic to support using cargo test to run these tests, and if I do that, I'll need to name them all (either explicitly or programmatically).

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm good with either approach

if skip_reason:
test_case: TestCase = TestCase(f'{test}, "{spec.name}", n{nproc}, {backend}',
test_case: TestCase = TestCase(f'{test}, {test_name_str}n{nproc}, {backend}',
elapsed_sec=0,
timestamp=time.strftime('%Y-%m-%d %H:%M:%S %Z', time.localtime()),
stdout='',
Expand All @@ -400,7 +402,7 @@ def run_test(index: int, test: str, spec: TestSpec, backend: str,
stderr=subprocess.PIPE,
env=my_env)

test_case = TestCase(f'{test}, "{spec.name}", n{nproc}, {backend}',
test_case = TestCase(f'{test}, {test_name_str}n{nproc}, {backend}',
classname=source_path.parent,
elapsed_sec=time.time() - start,
timestamp=time.strftime('%Y-%m-%d %H:%M:%S %Z', time.localtime(start)),
Expand Down