Skip to content

[feat] Include description (descr) in detailed listing #3513

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions examples/tutorial/stream/stream_runonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class stream_test(rfm.RunOnlyRegressionTest):
valid_systems = ['*']
valid_prog_environs = ['*']
executable = 'stream.x'
descr = 'Run the STREAM memory bandwidth benchmark.'

@sanity_function
def validate(self):
Expand Down
17 changes: 14 additions & 3 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,13 @@ def dep_lines(u, *, prefix, depth=0, lines=None, printed=None,

location = inspect.getfile(type(u.check))
if detailed:
details = (f' [variant: {u.check.variant_num}, '
f'file: {location!r}]')
details_fields = [
f'variant: {u.check.variant_num}',
f'file: {location!r}'
]
if hasattr(u.check, 'descr') and u.check.descr:
details_fields.append(f'description: {u.check.descr}')
details = '\n' + '\n'.join(f'{prefix} {field}' for field in details_fields)

lines.append(f'{prefix}^{name_info}{tc_info}{details}')

Expand All @@ -115,7 +120,13 @@ def dep_lines(u, *, prefix, depth=0, lines=None, printed=None,

location = inspect.getfile(type(t.check))
if detailed:
details = f' [variant: {t.check.variant_num}, file: {location!r}]'
details_fields = [
f'variant: {t.check.variant_num}',
f'file: {location!r}'
]
if hasattr(t.check, 'descr') and t.check.descr:
details_fields.append(f'description: {t.check.descr}')
details = '\n' + '\n'.join(f' {field}' for field in details_fields)

if concretized or (not concretized and
t.check.unique_name not in unique_checks):
Expand Down
44 changes: 44 additions & 0 deletions unittests/resources/checks/descr_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import reframe as rfm
import reframe.utility.sanity as sn


@rfm.simple_test
class TestWithDescription(rfm.RegressionTest):
descr = 'Test with meaningful description'

valid_systems = ['*']
valid_prog_environs = ['*']
executable = 'echo'
executable_opts = ['Hello with description']

@sanity_function
def validate(self):
return sn.assert_found(r'Hello', self.stdout)


@rfm.simple_test
class TestWithoutDescription(rfm.RegressionTest):
# No descr attribute

valid_systems = ['*']
valid_prog_environs = ['*']
executable = 'echo'
executable_opts = ['Hello without description']

@sanity_function
def validate(self):
return sn.assert_found(r'Hello', self.stdout)


@rfm.simple_test
class TestWithEmptyDescription(rfm.RegressionTest):
descr = '' # Empty description

valid_systems = ['*']
valid_prog_environs = ['*']
executable = 'echo'
executable_opts = ['Hello with empty description']

@sanity_function
def validate(self):
return sn.assert_found(r'Hello', self.stdout)
57 changes: 57 additions & 0 deletions unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,63 @@ def test_list_with_details(run_reframe):
assert returncode == 0


def test_list_with_details_with_descr(run_reframe):
returncode, stdout, stderr = run_reframe(
checkpath=['unittests/resources/checks/descr_test.py'],
action='list_detailed',
more_options=['-n', 'TestWithDescription']
)
assert 'Traceback' not in stdout
assert 'Traceback' not in stderr
assert returncode == 0
# Check that the description is shown for tests that have it
assert 'description: Test with meaningful description' in stdout


def test_list_with_details_with_empty_descr(run_reframe):
returncode, stdout, stderr = run_reframe(
checkpath=['unittests/resources/checks/descr_test.py'],
action='list_detailed',
more_options=['-n', 'TestWithEmptyDescription']
)
assert 'Traceback' not in stdout
assert 'Traceback' not in stderr
assert returncode == 0
# Check that empty descr doesn't show a description line
assert 'TestWithEmptyDescription' in stdout
assert 'description:' not in stdout


def test_list_with_details_without_descr(run_reframe):
returncode, stdout, stderr = run_reframe(
checkpath=['unittests/resources/checks/descr_test.py'],
action='list_detailed',
more_options=['-n', 'TestWithoutDescription']
)
assert 'Traceback' not in stdout
assert 'Traceback' not in stderr
assert returncode == 0
# Check that no description line appears for tests without description
assert 'TestWithoutDescription' in stdout
assert 'description:' not in stdout


def test_list_without_details_no_descr(run_reframe):
returncode, stdout, stderr = run_reframe(
checkpath=['unittests/resources/checks/descr_test.py'],
action='list'
)
assert 'Traceback' not in stdout
assert 'Traceback' not in stderr
assert returncode == 0
# Check that descriptions are not shown in non-detailed listing
assert 'description:' not in stdout
# But the test names should still be there
assert 'TestWithDescription' in stdout
assert 'TestWithoutDescription' in stdout
assert 'TestWithEmptyDescription' in stdout


def test_list_concretized(run_reframe):
returncode, stdout, stderr = run_reframe(
checkpath=['unittests/resources/checks/frontend_checks.py'],
Expand Down
Loading