diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 0f865f9128..fd143a2d28 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -21,7 +21,7 @@ import reframe.utility.os_ext as os_ext from reframe.core.buildsystems import BuildSystem, BuildSystemField from reframe.core.deferrable import deferrable, _DeferredExpression, evaluate -from reframe.core.environments import Environment +from reframe.core.environments import Environment, EnvironmentSnapshot from reframe.core.exceptions import (BuildError, PipelineError, SanityError, user_deprecation_warning) from reframe.core.launchers.registry import getlauncher @@ -775,12 +775,16 @@ def _setup_environ(self, environ): for k, v in self.variables.items(): self._current_environ.set_variable(k, v) + # Temporarily load the test's environment to record the actual module + # load/unload sequence + environ_save = EnvironmentSnapshot() # First load the local environment of the partition self.logger.debug('loading environment for the current partition') self._current_partition.local_env.load() self.logger.debug("loading test's environment") self._current_environ.load() + environ_save.load() def _setup_paths(self): """Setup the check's dynamic paths.""" diff --git a/unittests/test_pipeline.py b/unittests/test_pipeline.py index 5024795d62..d0160f6c45 100644 --- a/unittests/test_pipeline.py +++ b/unittests/test_pipeline.py @@ -69,11 +69,9 @@ def test_environ_setup(self): test.local = True test.setup(self.partition, self.progenv) - for m in test.modules: - self.assertTrue(rt.runtime().modules_system.is_module_loaded(m)) - for k, v in test.variables.items(): - self.assertEqual(os.environ[k], v) + for k in test.variables.keys(): + self.assertNotIn(k, os.environ) # Manually unload the environment self.progenv.unload()