From d3f59afc769a9a3da5505b3fddec6ea8b599118a Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Thu, 19 Sep 2019 23:29:56 +0200 Subject: [PATCH 1/2] Replace reframe_module configuration option with command line option - Use of 'reframe_module' configuration option is now ignored; a warning message is issued. - It is replaced by the `-u|--unload-module MOD` option. --- config/cscs-ci.py | 1 - config/cscs-pbs.py | 1 - config/cscs.py | 1 - reframe/frontend/cli.py | 56 ++++++++++++++++++++------------- reframe/settings.py | 1 - tutorial/config/settings.py | 1 - unittests/modules/testmod_bar | 2 +- unittests/modules/testmod_boo | 2 +- unittests/modules/testmod_foo | 2 +- unittests/resources/settings.py | 1 - unittests/test_cli.py | 22 +++++++++++++ 11 files changed, 59 insertions(+), 31 deletions(-) diff --git a/config/cscs-ci.py b/config/cscs-ci.py index cc3115efd9..58288775b9 100644 --- a/config/cscs-ci.py +++ b/config/cscs-ci.py @@ -4,7 +4,6 @@ class ReframeSettings: - reframe_module = 'reframe' job_poll_intervals = [1, 2, 3] job_submit_timeout = 60 checks_path = ['checks/'] diff --git a/config/cscs-pbs.py b/config/cscs-pbs.py index 87fe268565..8ece85d54e 100644 --- a/config/cscs-pbs.py +++ b/config/cscs-pbs.py @@ -4,7 +4,6 @@ class ReframeSettings: - reframe_module = 'reframe' job_poll_intervals = [1, 2, 3] job_submit_timeout = 60 checks_path = ['checks/'] diff --git a/config/cscs.py b/config/cscs.py index 5d47c56f6c..b93a7f4401 100644 --- a/config/cscs.py +++ b/config/cscs.py @@ -4,7 +4,6 @@ class ReframeSettings: - reframe_module = 'reframe' job_poll_intervals = [1, 2, 3] job_submit_timeout = 60 checks_path = ['checks/'] diff --git a/reframe/frontend/cli.py b/reframe/frontend/cli.py index e145218fe1..c11ab1db5d 100644 --- a/reframe/frontend/cli.py +++ b/reframe/frontend/cli.py @@ -53,8 +53,7 @@ def list_checks(checks, printer, detailed=False): def main(): # Setup command line options argparser = argparse.ArgumentParser() - output_options = argparser.add_argument_group( - 'Options controlling regression directories') + output_options = argparser.add_argument_group('Options controlling output') locate_options = argparser.add_argument_group( 'Options for locating checks') select_options = argparser.add_argument_group( @@ -63,18 +62,20 @@ def main(): 'Options controlling actions') run_options = argparser.add_argument_group( 'Options controlling execution of checks') + env_options = argparser.add_argument_group( + 'Options controlling environment') misc_options = argparser.add_argument_group('Miscellaneous options') # Output directory options output_options.add_argument( '--prefix', action='store', metavar='DIR', - help='Set regression prefix directory to DIR') + help='Set output directory prefix to DIR') output_options.add_argument( '-o', '--output', action='store', metavar='DIR', - help='Set regression output directory to DIR') + help='Set output directory to DIR') output_options.add_argument( '-s', '--stage', action='store', metavar='DIR', - help='Set regression stage directory to DIR') + help='Set stage directory to DIR') output_options.add_argument( '--perflogdir', action='store', metavar='DIR', help='Set directory prefix for the performance logs ' @@ -184,34 +185,39 @@ def main(): dest='flex_alloc_tasks', metavar='{all|idle|NUM}', default='idle', help="Strategy for flexible task allocation (default: 'idle').") - # Miscellaneous options - misc_options.add_argument( - '-C', '--config-file', action='store', dest='config_file', - metavar='FILE', default=os.path.join(reframe.INSTALL_PREFIX, - 'reframe/settings.py'), - help='Specify a custom config-file for the machine. ' - '(default: %s' % os.path.join(reframe.INSTALL_PREFIX, - 'reframe/settings.py')) - misc_options.add_argument( + env_options.add_argument( '-M', '--map-module', action='append', metavar='MAPPING', dest='module_mappings', default=[], help='Apply a single module mapping') - misc_options.add_argument( + env_options.add_argument( '-m', '--module', action='append', default=[], metavar='MOD', dest='user_modules', - help='Load module MOD before running the regression') - misc_options.add_argument( + help='Load module MOD before running the regression suite') + env_options.add_argument( '--module-mappings', action='store', metavar='FILE', dest='module_map_file', help='Apply module mappings defined in FILE') + env_options.add_argument( + '-u', '--unload-module', action='append', metavar='MOD', + dest='unload_modules', default=[], + help='Unload module MOD before running the regression suite') + env_options.add_argument( + '--purge-env', action='store_true', dest='purge_env', default=False, + help='Purge environment before running the regression suite') + + # Miscellaneous options + misc_options.add_argument( + '-C', '--config-file', action='store', dest='config_file', + metavar='FILE', default=os.path.join(reframe.INSTALL_PREFIX, + 'reframe/settings.py'), + help='Specify a custom config-file for the machine. ' + '(default: %s' % os.path.join(reframe.INSTALL_PREFIX, + 'reframe/settings.py')) misc_options.add_argument( '--nocolor', action='store_false', dest='colorize', default=True, help='Disable coloring of output') misc_options.add_argument('--performance-report', action='store_true', help='Print the performance report') - misc_options.add_argument( - '--purge-env', action='store_true', dest='purge_env', default=False, - help='Purge modules environment before running any tests') misc_options.add_argument( '--show-config', action='store_true', help='Print configuration of the current system and exit') @@ -488,11 +494,17 @@ def main(): # Act on checks # Unload regression's module and load user-specified modules - if settings.reframe_module: - rt.modules_system.unload_module(settings.reframe_module) + if hasattr(settings, 'reframe_module'): + printer.warning( + "the 'reframe_module' configuration option will be ignored; " + "please use the '-u' or '--unload-module' options" + ) if options.purge_env: rt.modules_system.unload_all() + else: + for m in options.unload_modules: + rt.modules_system.unload_module(m) # Load the environment for the current system try: diff --git a/reframe/settings.py b/reframe/settings.py index 09f6595082..08374061fb 100644 --- a/reframe/settings.py +++ b/reframe/settings.py @@ -4,7 +4,6 @@ class ReframeSettings: - reframe_module = None job_poll_intervals = [1, 2, 3] job_submit_timeout = 60 checks_path = ['checks/'] diff --git a/tutorial/config/settings.py b/tutorial/config/settings.py index 07286791c2..080271aa75 100644 --- a/tutorial/config/settings.py +++ b/tutorial/config/settings.py @@ -4,7 +4,6 @@ class ReframeSettings: - reframe_module = 'reframe' job_poll_intervals = [1, 2, 3] job_submit_timeout = 60 checks_path = ['checks/'] diff --git a/unittests/modules/testmod_bar b/unittests/modules/testmod_bar index 2ded5cd240..00d2094f04 100644 --- a/unittests/modules/testmod_bar +++ b/unittests/modules/testmod_bar @@ -3,7 +3,7 @@ proc ModulesHelp { } { Helper module for PyRegression unit tests } -module-whatis { Helper module for PyRegression unit tests } +module-whatis { Helper module for ReFrame unit tests } conflict testmod_bar conflict testmod_foo diff --git a/unittests/modules/testmod_boo b/unittests/modules/testmod_boo index c43923dd93..4352089bf5 100644 --- a/unittests/modules/testmod_boo +++ b/unittests/modules/testmod_boo @@ -3,7 +3,7 @@ proc ModulesHelp { } { Helper module for PyRegression unit tests } -module-whatis { Helper module for PyRegression unit tests } +module-whatis { Helper module for ReFrame unit tests } conflict testmod_boo conflict testmod_bar diff --git a/unittests/modules/testmod_foo b/unittests/modules/testmod_foo index 42514bfb97..0db9eb4ee2 100644 --- a/unittests/modules/testmod_foo +++ b/unittests/modules/testmod_foo @@ -3,7 +3,7 @@ proc ModulesHelp { } { Helper module for PyRegression unit tests } -module-whatis { Helper module for PyRegression unit tests } +module-whatis { Helper module for ReFrame unit tests } conflict testmod_foo conflict testmod_bar diff --git a/unittests/resources/settings.py b/unittests/resources/settings.py index 6046aebb9d..8cf599d1fa 100644 --- a/unittests/resources/settings.py +++ b/unittests/resources/settings.py @@ -4,7 +4,6 @@ class ReframeSettings: - reframe_module = None job_poll_intervals = [1, 2, 3] job_submit_timeout = 60 checks_path = ['checks/'] diff --git a/unittests/test_cli.py b/unittests/test_cli.py index 69ffb3c3f1..50483b681d 100644 --- a/unittests/test_cli.py +++ b/unittests/test_cli.py @@ -1,6 +1,7 @@ import copy import itertools import os +import pytest import re import sys import tempfile @@ -408,3 +409,24 @@ def test_verbosity(self): self.assertNotIn('Traceback', stdout) self.assertNotIn('Traceback', stderr) self.assertEqual(0, returncode) + + @fixtures.switch_to_user_runtime + def test_unload_module(self): + # This test is mostly for ensuring coverage. `_run_reframe()` restores + # the current environment, so it is not easy to verify that the modules + # are indeed unloaded. However, this functionality is tested elsewhere + # more exhaustively. + + ms = rt.runtime().modules_system + if ms.name == 'nomod': + pytest.skip('no modules system found') + + ms.searchpath_add('unittests/modules') + ms.load_module('testmod_foo') + self.more_options = ['-u testmod_foo'] + self.action = 'list' + returncode, stdout, stderr = self._run_reframe() + assert stdout != '' + assert 'Traceback' not in stdout + assert 'Traceback' not in stderr + assert returncode == 0 From db5749c0bc644ca61cbb2819afc96ab6818d3015 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Sat, 21 Sep 2019 13:29:03 +0200 Subject: [PATCH 2/2] Fix unit tests and add -u option to the CSCS execution modes --- config/cscs.py | 2 ++ unittests/test_cli.py | 1 + 2 files changed, 3 insertions(+) diff --git a/config/cscs.py b/config/cscs.py index b93a7f4401..4016a28a7b 100644 --- a/config/cscs.py +++ b/config/cscs.py @@ -481,6 +481,7 @@ class ReframeSettings: 'modes': { '*': { 'maintenance': [ + '--unload-module=reframe', '--exec-policy=async', '--strict', '--output=$APPS/UES/$USER/regression/maintenance', @@ -492,6 +493,7 @@ class ReframeSettings: '--timestamp=%F_%H-%M-%S' ], 'production': [ + '--unload-module=reframe', '--exec-policy=async', '--strict', '--output=$APPS/UES/$USER/regression/production', diff --git a/unittests/test_cli.py b/unittests/test_cli.py index 50483b681d..d99e37d07b 100644 --- a/unittests/test_cli.py +++ b/unittests/test_cli.py @@ -430,3 +430,4 @@ def test_unload_module(self): assert 'Traceback' not in stdout assert 'Traceback' not in stderr assert returncode == 0 + ms.unload_module('testmod_foo')