Skip to content
Merged
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
26 changes: 16 additions & 10 deletions reframe/frontend/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,16 +737,22 @@ def restrict_logging():

# Update options from the selected execution mode
if options.mode:
mode_args = site_config.get(f'modes/@{options.mode}/options')

# We lexically split the mode options, because otherwise spaces
# will be treated as part of the option argument; see GH bug #1554
mode_args = list(itertools.chain.from_iterable(shlex.split(m)
for m in mode_args))
# Parse the mode's options and reparse the command-line
options = argparser.parse_args(mode_args)
options = argparser.parse_args(namespace=options.cmd_options)
options.update_config(site_config)
mode = site_config.get(f'modes/@{options.mode}')
if mode is None:
printer.warning(f'invalid mode: {options.mode!r}; ignoring...')
else:
mode_args = site_config.get(f'modes/@{options.mode}/options')

# We lexically split the mode options, because otherwise spaces
# will be treated as part of the option argument;
# see GH bug #1554
mode_args = list(
itertools.chain.from_iterable(shlex.split(m)
for m in mode_args))
# Parse the mode's options and reparse the command-line
options = argparser.parse_args(mode_args)
options = argparser.parse_args(namespace=options.cmd_options)
options.update_config(site_config)

logging.configure_logging(site_config)
except (OSError, errors.ConfigError) as e:
Expand Down
14 changes: 14 additions & 0 deletions unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,20 @@ def test_execution_modes(run_reframe):
assert 'Ran 2/2 test case' in stdout


def test_invalid_mode_warning(run_reframe):
mode = 'invalid'
returncode, stdout, stderr = run_reframe(
action='list',
checkpath=[],
environs=[],
local=False,
mode=mode
)
assert 'Traceback' not in stdout
assert 'Traceback' not in stderr
assert f'invalid mode: {mode!r}; ignoring' in stdout


def test_timestamp_option(run_reframe):
timefmt = time.strftime('xxx_%F')
returncode, stdout, _ = run_reframe(
Expand Down