Skip to content

Commit 414e17b

Browse files
committed
New --table-hide-columns option
1 parent 320e69d commit 414e17b

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

docs/manpage.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ Miscellaneous options
11321132

11331133
.. option:: --table-format=csv|plain|pretty
11341134

1135-
Set the formatting of tabular output printed by options :option:`--performance-compare`, :option:`--performance-report` and the options controlling the stored sessions.
1135+
Set the formatting of tabular output printed by the options :option:`--performance-compare`, :option:`--performance-report` and the options controlling the stored sessions.
11361136

11371137
The acceptable values are the following:
11381138

@@ -1142,6 +1142,12 @@ Miscellaneous options
11421142

11431143
.. versionadded:: 4.7
11441144

1145+
.. option:: --table-hide-columns=COLUMNS
1146+
1147+
Hide the specified comma-separated list of columns from the tabular output printed by the options :option:`--performance-compare`, :option:`--performance-report` and the options controlling the stored sessions.
1148+
1149+
.. versionadded:: 4.7
1150+
11451151
.. option:: --upgrade-config-file=OLD[:NEW]
11461152

11471153
Convert the old-style configuration file ``OLD``, place it into the new file ``NEW`` and exit.

reframe/frontend/cli.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,11 @@ def main():
631631
help='Table formatting',
632632
envvar='RFM_TABLE_FORMAT', configvar='general/table_format'
633633
)
634+
misc_options.add_argument(
635+
'--table-hide-columns', metavar='COLS', action='store',
636+
help='Hide specific columns from the final table',
637+
envvar='RFM_TABLE_HIDE_COLUMNS', configvar='general/table_hide_columns'
638+
)
634639
misc_options.add_argument(
635640
'-v', '--verbose', action='count',
636641
help='Increase verbosity level of output',

reframe/frontend/printer.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,14 @@ def table(self, data, **kwargs):
276276

277277
kwargs.setdefault('headers', 'firstrow')
278278
kwargs.setdefault('tablefmt', tablefmt)
279-
self.info(tabulate(data, **kwargs))
279+
hide_columns = rt.runtime().get_option('general/0/table_hide_columns')
280+
if hide_columns and kwargs['headers'] == 'firstrow' and data:
281+
hide_columns = hide_columns.split(',')
282+
colidx = [i for i, col in enumerate(data[0])
283+
if col not in hide_columns]
284+
285+
tab_data = [[rec[col] for col in colidx] for rec in data]
286+
else:
287+
tab_data = data
288+
289+
self.info(tabulate(tab_data, **kwargs))

unittests/test_cli.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,6 +1298,15 @@ def assert_no_crash(returncode, stdout, stderr, exitcode=0):
12981298
*run_reframe2(action=f'--describe-stored-testcases={uuid}')
12991299
)
13001300

1301+
# Check hiding of table column
1302+
stdout = assert_no_crash(*run_reframe2(
1303+
action=f'--list-stored-testcases={uuid}',
1304+
more_options=['--table-hide-columns=SysEnv,Nodelist,UUID']
1305+
))[1]
1306+
assert 'SysEnv' not in stdout
1307+
assert 'Nodelist' not in stdout
1308+
assert 'UUID' not in stdout
1309+
13011310
# List test cases by time period
13021311
ts_start = session_json['session_info']['time_start']
13031312
assert_no_crash(

0 commit comments

Comments
 (0)