From e2ab962005192e98160126f90065196a7c5970a7 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Fri, 2 Apr 2021 17:10:10 +0200 Subject: [PATCH] Fix crash when `sourcesdir` is set to `None` in class body Also changed the automatic assignment of `sourcesdir` to `None` so as to avoid setting it so, in cases that the user has explicitly passed a directory that does not exist. --- reframe/core/pipeline.py | 4 ++-- unittests/test_pipeline.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 017c029a8e..db0f66b349 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -845,8 +845,8 @@ def _rfm_init(self, name=None, prefix=None): # Static directories of the regression check self._prefix = os.path.abspath(prefix) - if (not os.path.isdir(os.path.join(self._prefix, self.sourcesdir)) and - not osext.is_url(self.sourcesdir)): + if (self.sourcesdir == 'src' and + not os.path.isdir(os.path.join(self._prefix, self.sourcesdir))): self.sourcesdir = None # Runtime information of the test diff --git a/unittests/test_pipeline.py b/unittests/test_pipeline.py index 1382772d6b..d15bcf8f46 100644 --- a/unittests/test_pipeline.py +++ b/unittests/test_pipeline.py @@ -272,6 +272,20 @@ def __init__(self): _run(test, *local_exec_ctx) +def test_run_only_srcdir_set_to_none(local_exec_ctx): + @fixtures.custom_prefix('foo/bar/') + class MyTest(rfm.RunOnlyRegressionTest): + executable = 'echo' + valid_prog_environs = ['*'] + valid_systems = ['*'] + sourcesdir = None + sanity_patterns = sn.assert_true(1) + + test = MyTest() + assert test.sourcesdir is None + _run(test, *local_exec_ctx) + + def test_compile_only_failure(local_exec_ctx): @fixtures.custom_prefix('unittests/resources/checks') class MyTest(rfm.CompileOnlyRegressionTest):