Skip to content

Commit e8f98e5

Browse files
authored
Merge branch 'master' into ci/publish_pypi_release_v1
2 parents c49ef62 + 77b163c commit e8f98e5

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

reframe/frontend/cli.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -737,16 +737,22 @@ def restrict_logging():
737737

738738
# Update options from the selected execution mode
739739
if options.mode:
740-
mode_args = site_config.get(f'modes/@{options.mode}/options')
741-
742-
# We lexically split the mode options, because otherwise spaces
743-
# will be treated as part of the option argument; see GH bug #1554
744-
mode_args = list(itertools.chain.from_iterable(shlex.split(m)
745-
for m in mode_args))
746-
# Parse the mode's options and reparse the command-line
747-
options = argparser.parse_args(mode_args)
748-
options = argparser.parse_args(namespace=options.cmd_options)
749-
options.update_config(site_config)
740+
mode = site_config.get(f'modes/@{options.mode}')
741+
if mode is None:
742+
printer.warning(f'invalid mode: {options.mode!r}; ignoring...')
743+
else:
744+
mode_args = site_config.get(f'modes/@{options.mode}/options')
745+
746+
# We lexically split the mode options, because otherwise spaces
747+
# will be treated as part of the option argument;
748+
# see GH bug #1554
749+
mode_args = list(
750+
itertools.chain.from_iterable(shlex.split(m)
751+
for m in mode_args))
752+
# Parse the mode's options and reparse the command-line
753+
options = argparser.parse_args(mode_args)
754+
options = argparser.parse_args(namespace=options.cmd_options)
755+
options.update_config(site_config)
750756

751757
logging.configure_logging(site_config)
752758
except (OSError, errors.ConfigError) as e:

unittests/test_cli.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,20 @@ def test_execution_modes(run_reframe):
478478
assert 'Ran 2/2 test case' in stdout
479479

480480

481+
def test_invalid_mode_warning(run_reframe):
482+
mode = 'invalid'
483+
returncode, stdout, stderr = run_reframe(
484+
action='list',
485+
checkpath=[],
486+
environs=[],
487+
local=False,
488+
mode=mode
489+
)
490+
assert 'Traceback' not in stdout
491+
assert 'Traceback' not in stderr
492+
assert f'invalid mode: {mode!r}; ignoring' in stdout
493+
494+
481495
def test_timestamp_option(run_reframe):
482496
timefmt = time.strftime('xxx_%F')
483497
returncode, stdout, _ = run_reframe(

0 commit comments

Comments
 (0)