From e7295c44cda6db1fd2ef293215123dcfd54b411d Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Sun, 7 Apr 2019 22:28:15 +0200 Subject: [PATCH 1/2] Clone environments in test cases - This fixes the problem with the duplicate module commands - This commit removes also the stale `Sandbox` class. --- reframe/frontend/executors/__init__.py | 6 ++---- reframe/utility/sandbox.py | 8 -------- unittests/test_fields.py | 15 --------------- 3 files changed, 2 insertions(+), 27 deletions(-) delete mode 100644 reframe/utility/sandbox.py diff --git a/reframe/frontend/executors/__init__.py b/reframe/frontend/executors/__init__.py index 29b7d8dc58..97e551ca8a 100644 --- a/reframe/frontend/executors/__init__.py +++ b/reframe/frontend/executors/__init__.py @@ -10,7 +10,6 @@ ReframeFatalError, TaskExit) from reframe.frontend.printer import PrettyPrinter from reframe.frontend.statistics import TestStats -from reframe.utility.sandbox import Sandbox ABORT_REASONS = (KeyboardInterrupt, ReframeFatalError, AssertionError) @@ -23,10 +22,10 @@ class TestCase: def __init__(self, check, partition, environ): self.__check_orig = check self.__check = copy.deepcopy(check) + self.__environ = copy.deepcopy(environ) - # Environments and partitions are immutable; no need to clone them + # Partitions are immutable; no need to clone them self.__partition = partition - self.__environ = environ def __iter__(self): # Allow unpacking a test case with a single liner: @@ -220,7 +219,6 @@ def __init__(self, policy, printer=None, max_retries=0): self._stats = TestStats() self._policy.stats = self._stats self._policy.printer = self._printer - self._sandbox = Sandbox() self._environ_snapshot = EnvironmentSnapshot() def __repr__(self): diff --git a/reframe/utility/sandbox.py b/reframe/utility/sandbox.py deleted file mode 100644 index c3b300f486..0000000000 --- a/reframe/utility/sandbox.py +++ /dev/null @@ -1,8 +0,0 @@ -from reframe.core.fields import CopyOnWriteField - - -class Sandbox: - """Sandbox class for manipulating shared resources.""" - environ = CopyOnWriteField('environ') - system = CopyOnWriteField('system') - check = CopyOnWriteField('check') diff --git a/unittests/test_fields.py b/unittests/test_fields.py index 34e22acc74..15507efda2 100644 --- a/unittests/test_fields.py +++ b/unittests/test_fields.py @@ -108,21 +108,6 @@ class FieldTester: self.assertRaises(ValueError, exec, 'tester.field = (100, 3, 65)', globals(), locals()) - def test_sandbox(self): - from reframe.core.environments import Environment - from reframe.core.systems import System - from reframe.utility.sandbox import Sandbox - - environ = Environment('myenv') - system = System('mysystem') - - sandbox = Sandbox() - sandbox.environ = environ - sandbox.system = system - - self.assertIsNot(system, sandbox.system) - self.assertIsNot(environ, sandbox.environ) - def test_proxy_field(self): class Target: def __init__(self): From 7a28c9eac9871fe99aeec9e9f5a230633015bd2f Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Sun, 7 Apr 2019 23:14:15 +0200 Subject: [PATCH 2/2] Deep copy partitions as well - Partitions contain reference to their local environment, eventually making them mutable as well. --- reframe/frontend/executors/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/reframe/frontend/executors/__init__.py b/reframe/frontend/executors/__init__.py index 97e551ca8a..48d7f7e51c 100644 --- a/reframe/frontend/executors/__init__.py +++ b/reframe/frontend/executors/__init__.py @@ -23,9 +23,7 @@ def __init__(self, check, partition, environ): self.__check_orig = check self.__check = copy.deepcopy(check) self.__environ = copy.deepcopy(environ) - - # Partitions are immutable; no need to clone them - self.__partition = partition + self.__partition = copy.deepcopy(partition) def __iter__(self): # Allow unpacking a test case with a single liner: