From e0346f08cf9b9beeb598133affad458838a6497d Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Sat, 11 Jul 2020 20:31:32 +0200 Subject: [PATCH] Fix unit test failure of the async execution policy --- unittests/fixtures.py | 3 ++ unittests/test_argparser.py | 95 +++++++++++++++++++------------------ 2 files changed, 52 insertions(+), 46 deletions(-) diff --git a/unittests/fixtures.py b/unittests/fixtures.py index 334813831b..b15fabfba1 100644 --- a/unittests/fixtures.py +++ b/unittests/fixtures.py @@ -24,6 +24,9 @@ os.path.dirname(os.path.realpath(__file__)), 'modules' ) +# Builtin configuration +BUILTIN_CONFIG_FILE = 'reframe/core/settings.py' + # Unit tests site configuration TEST_CONFIG_FILE = 'unittests/resources/settings.py' diff --git a/unittests/test_argparser.py b/unittests/test_argparser.py index 761cd67d45..48c2acdaed 100644 --- a/unittests/test_argparser.py +++ b/unittests/test_argparser.py @@ -123,55 +123,58 @@ def extended_parser(): def test_option_precedence(extended_parser): - with rt.temp_environment(variables={ - 'RFM_TIMESTAMP': '%F', - 'RFM_NON_DEFAULT_CRAYPE': 'yes', - 'RFM_MODULES_PRELOAD': 'a,b,c', - 'RFM_CHECK_SEARCH_PATH': 'x:y:z' - - }): - options = extended_parser.parse_args( - ['--timestamp=%FT%T', '--nocolor'] - ) - assert options.recursive is None - assert options.timestamp == '%FT%T' - assert options.non_default_craype is True - assert options.config_file is None - assert options.prefix is None - assert options.stagedir == '/foo' - assert options.module == ['a', 'b', 'c'] - assert options.check_path == ['x', 'y', 'z'] - assert options.colorize is False + with rt.temp_runtime(fixtures.BUILTIN_CONFIG_FILE): + with rt.temp_environment(variables={ + 'RFM_TIMESTAMP': '%F', + 'RFM_NON_DEFAULT_CRAYPE': 'yes', + 'RFM_MODULES_PRELOAD': 'a,b,c', + 'RFM_CHECK_SEARCH_PATH': 'x:y:z' + + }): + options = extended_parser.parse_args( + ['--timestamp=%FT%T', '--nocolor'] + ) + assert options.recursive is None + assert options.timestamp == '%FT%T' + assert options.non_default_craype is True + assert options.config_file is None + assert options.prefix is None + assert options.stagedir == '/foo' + assert options.module == ['a', 'b', 'c'] + assert options.check_path == ['x', 'y', 'z'] + assert options.colorize is False def test_option_with_config(extended_parser): - with rt.temp_environment(variables={ - 'RFM_TIMESTAMP': '%F', - 'RFM_NON_DEFAULT_CRAYPE': 'yes', - 'RFM_MODULES_PRELOAD': 'a,b,c', - 'RFM_KEEP_STAGE_FILES': 'no' - }): - site_config = rt.runtime().site_config - options = extended_parser.parse_args( - ['--timestamp=%FT%T', '--nocolor'] - ) - options.update_config(site_config) - assert site_config.get('general/0/check_search_recursive') is False - assert site_config.get('general/0/timestamp_dirs') == '%FT%T' - assert site_config.get('general/0/non_default_craype') is True - assert site_config.get('systems/0/prefix') == '.' - assert site_config.get('general/0/colorize') is False - assert site_config.get('general/0/keep_stage_files') is False - - # Defaults specified in parser override those in configuration file - assert site_config.get('systems/0/stagedir') == '/foo' + with rt.temp_runtime(fixtures.BUILTIN_CONFIG_FILE): + with rt.temp_environment(variables={ + 'RFM_TIMESTAMP': '%F', + 'RFM_NON_DEFAULT_CRAYPE': 'yes', + 'RFM_MODULES_PRELOAD': 'a,b,c', + 'RFM_KEEP_STAGE_FILES': 'no' + }): + site_config = rt.runtime().site_config + options = extended_parser.parse_args( + ['--timestamp=%FT%T', '--nocolor'] + ) + options.update_config(site_config) + assert site_config.get('general/0/check_search_recursive') is False + assert site_config.get('general/0/timestamp_dirs') == '%FT%T' + assert site_config.get('general/0/non_default_craype') is True + assert site_config.get('systems/0/prefix') == '.' + assert site_config.get('general/0/colorize') is False + assert site_config.get('general/0/keep_stage_files') is False + + # Defaults specified in parser override those in configuration file + assert site_config.get('systems/0/stagedir') == '/foo' def test_option_envvar_conversion_error(extended_parser): - with rt.temp_environment(variables={ - 'RFM_NON_DEFAULT_CRAYPE': 'foo', - }): - site_config = rt.runtime().site_config - options = extended_parser.parse_args(['--nocolor']) - errors = options.update_config(site_config) - assert len(errors) == 1 + with rt.temp_runtime(fixtures.BUILTIN_CONFIG_FILE): + with rt.temp_environment(variables={ + 'RFM_NON_DEFAULT_CRAYPE': 'foo', + }): + site_config = rt.runtime().site_config + options = extended_parser.parse_args(['--nocolor']) + errors = options.update_config(site_config) + assert len(errors) == 1