From fade96420811fd65e3ca5fba687a4419b4bfef86 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Tue, 5 Feb 2019 15:04:50 +0100 Subject: [PATCH 1/2] Add support for directories in 'keep_files' * Support directories in the `keep_files` field of a `RegressionTest`. --- reframe/core/pipeline.py | 6 +++++- unittests/test_pipeline.py | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 0d7b188b73..a47b4f90c3 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -1158,10 +1158,14 @@ def _copy_to_outputdir(self): # Copy files specified by the user for f in self.keep_files: + filename = f if not os.path.isabs(f): f = os.path.join(self._stagedir, f) - shutil.copy(f, self.outputdir) + if os.path.isfile(f): + shutil.copy(f, self.outputdir) + elif os.path.isdir(f): + shutil.copytree(f, os.path.join(self.outputdir, filename)) def cleanup(self, remove_files=False, unload_env=True): """The cleanup phase of the regression test pipeline. diff --git a/unittests/test_pipeline.py b/unittests/test_pipeline.py index 3edbc3047e..b23a2b4050 100644 --- a/unittests/test_pipeline.py +++ b/unittests/test_pipeline.py @@ -117,9 +117,10 @@ def test_hellocheck_local(self): test.valid_prog_environs = [self.progenv.name] # Test also the prebuild/postbuild functionality - test.prebuild_cmd = ['touch prebuild'] - test.postbuild_cmd = ['touch postbuild'] - test.keep_files = ['prebuild', 'postbuild'] + test.prebuild_cmd = ['touch prebuild', 'mkdir prebuild_dir'] + test.postbuild_cmd = ['touch postbuild', 'mkdir postbuild_dir'] + test.keep_files = ['prebuild', 'postbuild', + 'prebuild_dir', 'postbuild_dir'] # Force local execution of the test test.local = True From c6f3f0627ec6ab052497ea9da9730b228306bb01 Mon Sep 17 00:00:00 2001 From: Theofilos Manitaras Date: Fri, 8 Feb 2019 11:41:58 +0100 Subject: [PATCH 2/2] Address PR comments --- reframe/core/pipeline.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index a47b4f90c3..4f017f50eb 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -1126,7 +1126,7 @@ def check_performance(self): for tag, expr in self.perf_patterns.items(): value = evaluate(expr) key = '%s:%s' % (self._current_partition.fullname, tag) - if not key in self.reference: + if key not in self.reference: raise SanityError( "tag `%s' not resolved in references for `%s'" % (tag, self._current_partition.fullname)) @@ -1158,14 +1158,14 @@ def _copy_to_outputdir(self): # Copy files specified by the user for f in self.keep_files: - filename = f + f_orig = f if not os.path.isabs(f): f = os.path.join(self._stagedir, f) if os.path.isfile(f): shutil.copy(f, self.outputdir) elif os.path.isdir(f): - shutil.copytree(f, os.path.join(self.outputdir, filename)) + shutil.copytree(f, os.path.join(self.outputdir, f_orig)) def cleanup(self, remove_files=False, unload_env=True): """The cleanup phase of the regression test pipeline.