From 65b61be1aa761c80a3b9903bcf19ce488683dc8b Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Thu, 12 Sep 2024 09:25:35 +0200 Subject: [PATCH] Keep test path config when restoring environment in tests This fixes `test_toy_multi_deps` which restores the environment in the middle of the test and then misses the --sourcepath modification done at test setup. --- test/framework/utilities.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/framework/utilities.py b/test/framework/utilities.py index c20de50624..dac5cced2c 100644 --- a/test/framework/utilities.py +++ b/test/framework/utilities.py @@ -49,7 +49,7 @@ from easybuild.framework.easyblock import EasyBlock from easybuild.main import main from easybuild.tools import config -from easybuild.tools.config import GENERAL_CLASS, Singleton, module_classes, update_build_option +from easybuild.tools.config import GENERAL_CLASS, Singleton, module_classes from easybuild.tools.configobj import ConfigObj from easybuild.tools.environment import modify_env from easybuild.tools.filetools import copy_dir, mkdir, read_file, which @@ -106,8 +106,8 @@ def setUp(self): os.close(fd) self.cwd = os.getcwd() - # keep track of original environment to restore - self.orig_environ = copy.deepcopy(os.environ) + # keep track of original environment to restore after tests + self._initial_environ = copy.deepcopy(os.environ) # keep track of original environment/Python search path to restore self.orig_sys_path = sys.path[:] @@ -131,17 +131,19 @@ def setUp(self): if eb_path is not None: os.environ['EB_SCRIPT_PATH'] = eb_path + # disable progress bars when running the tests, + # since it messes with test suite progress output when test installations are performed + os.environ['EASYBUILD_DISABLE_SHOW_PROGRESS_BAR'] = '1' + + # Store the environment as setup (including the above paths) for tests to restore + self.orig_environ = copy.deepcopy(os.environ) + # make sure no deprecated behaviour is being triggered (unless intended by the test) self.orig_current_version = eb_build_log.CURRENT_VERSION self.disallow_deprecated_behaviour() init_config() - # disable progress bars when running the tests, - # since it messes with test suite progress output when test installations are performed - os.environ['EASYBUILD_DISABLE_SHOW_PROGRESS_BAR'] = '1' - update_build_option('show_progress_bar', False) - import easybuild # try to import easybuild.easyblocks(.generic) packages # it's OK if it fails here, but important to import first before fiddling with sys.path