From c831bae150376581da343fd4214015e352e27588 Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Mon, 2 Aug 2021 15:06:29 +0200 Subject: [PATCH 1/6] Fix default executable assignment --- reframe/core/pipeline.py | 9 +++++---- unittests/test_pipeline.py | 11 ++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 571e6e0a3a..8e1c7cf78d 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -861,10 +861,6 @@ def __rfm_init__(self, *args, name=None, prefix=None, **kwargs): if not hasattr(self, 'descr'): self.descr = self.name - # Pass if the executable is a required variable. - if not hasattr(self, 'executable'): - self.executable = os.path.join('.', self.name) - self._perfvalues = {} # Static directories of the regression check @@ -1319,6 +1315,11 @@ def compile(self): self.build_system = 'SingleSource' self.build_system.srcfile = self.sourcepath + + # Set executable (only if hasn't been provided) + if not hasattr(self, 'executable'): + self.executable = os.path.join('.', self.name) + self.build_system.executable = self.executable user_environ = env.Environment(type(self).__name__, diff --git a/unittests/test_pipeline.py b/unittests/test_pipeline.py index 20030a2ab6..73ede68969 100644 --- a/unittests/test_pipeline.py +++ b/unittests/test_pipeline.py @@ -302,6 +302,15 @@ class MyTest(rfm.RunOnlyRegressionTest): _run(test, *local_exec_ctx) +def test_executable_is_required(local_exec_ctx): + class MyTest(rfm.RunOnlyRegressionTest): + valid_prog_environs = ['*'] + valid_systems = ['*'] + + with pytest.raises(AttributeError, match="'executable' has not been set"): + _run(MyTest(), *local_exec_ctx) + + def test_compile_only_failure(local_exec_ctx): @test_util.custom_prefix('unittests/resources/checks') class MyTest(rfm.CompileOnlyRegressionTest): @@ -319,7 +328,7 @@ def __init__(self): def test_compile_only_warning(local_exec_ctx): @test_util.custom_prefix('unittests/resources/checks') - class MyTest(rfm.RunOnlyRegressionTest): + class MyTest(rfm.CompileOnlyRegressionTest): def __init__(self): self.build_system = 'SingleSource' self.build_system.srcfile = 'compiler_warning.c' From 833e20ed36c321fce653621d54dee14f76395b35 Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Mon, 2 Aug 2021 16:17:07 +0200 Subject: [PATCH 2/6] Fix policies unit tests --- reframe/core/pipeline.py | 9 ++++----- unittests/test_policies.py | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 8e1c7cf78d..74d44773c6 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -1283,6 +1283,10 @@ def compile(self): self._copy_to_stagedir(os.path.join(self._prefix, self.sourcesdir)) + # Set executable (only if hasn't been provided) + if not hasattr(self, 'executable'): + self.executable = os.path.join('.', self.name) + # Verify the sourcepath and determine the sourcepath in the stagedir if (os.path.isabs(self.sourcepath) or os.path.normpath(self.sourcepath).startswith('..')): @@ -1315,11 +1319,6 @@ def compile(self): self.build_system = 'SingleSource' self.build_system.srcfile = self.sourcepath - - # Set executable (only if hasn't been provided) - if not hasattr(self, 'executable'): - self.executable = os.path.join('.', self.name) - self.build_system.executable = self.executable user_environ = env.Environment(type(self).__name__, diff --git a/unittests/test_policies.py b/unittests/test_policies.py index 9e92b24997..5baf9ff94a 100644 --- a/unittests/test_policies.py +++ b/unittests/test_policies.py @@ -139,6 +139,7 @@ def check_and_skip(self): class _T1(rfm.RunOnlyRegressionTest): valid_systems = ['*'] valid_prog_environs = ['*'] + executable = 'echo' sanity_patterns = sn.assert_true(1) def __init__(self): From 8d7fdea4f3efb6f8c3079e2f4646de4eb1d5e630 Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Mon, 2 Aug 2021 17:06:47 +0200 Subject: [PATCH 3/6] Update docs for executable var --- reframe/core/pipeline.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 74d44773c6..5b1a79274a 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -349,7 +349,12 @@ def pipeline_hooks(cls): #: The name of the executable to be launched during the run phase. #: #: :type: :class:`str` - #: :default: ``os.path.join('.', self.name)`` + #: :default: :class:`required` + #: + #: .. versionchanged:: 3.8 + #: If this variable is still undefined during the execution of the + #: compilation stage, it will be set to + #: ``os.path.join('.', self.name)``. executable = variable(str) #: List of options to be passed to the :attr:`executable`. From f20baa6938260516580b64937b631b79e315e77a Mon Sep 17 00:00:00 2001 From: Javier Otero <71280927+jjotero@users.noreply.github.com> Date: Fri, 6 Aug 2021 11:37:13 +0200 Subject: [PATCH 4/6] Improve executable-related docs --- docs/tutorial_advanced.rst | 2 +- reframe/core/pipeline.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/tutorial_advanced.rst b/docs/tutorial_advanced.rst index ea3c1b1ede..f7c2225632 100644 --- a/docs/tutorial_advanced.rst +++ b/docs/tutorial_advanced.rst @@ -261,7 +261,7 @@ Here is the full regression test: :lines: 6- :emphasize-lines: 6 -There is nothing special for this test compared to those presented so far except that it derives from the :class:`~reframe.core.pipeline.RunOnlyRegressionTest`. +There is nothing special for this test compared to those presented so far except that it derives from the :class:`~reframe.core.pipeline.RunOnlyRegressionTest` class, and setting the :attr:`~reframe.core.pipeline.RegressionTest.executable` in this type of test is always required. Run-only regression tests may also have resources, as for instance a pre-compiled executable or some input data. These resources may reside under the ``src/`` directory or under any directory specified in the :attr:`~reframe.core.pipeline.RegressionTest.sourcesdir` attribute. These resources will be copied to the stage directory at the beginning of the run phase. diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 5b1a79274a..fcbdf419de 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -348,13 +348,16 @@ def pipeline_hooks(cls): #: The name of the executable to be launched during the run phase. #: + #: If this variable is undefined when entering the compile pipeline + #: stage, it will be set to ``os.path.join('.', self.name)``. Classes + #: that override the compile stage may leave this variable undefined. + #: #: :type: :class:`str` #: :default: :class:`required` #: #: .. versionchanged:: 3.8 - #: If this variable is still undefined during the execution of the - #: compilation stage, it will be set to - #: ``os.path.join('.', self.name)``. + #: Default value changed from ``os.path.join('.', self.name)`` to + #: :class:`required`. executable = variable(str) #: List of options to be passed to the :attr:`executable`. From 2a7379dbd18a7b185342b73686cd77a6f4a06724 Mon Sep 17 00:00:00 2001 From: Javier Otero <71280927+jjotero@users.noreply.github.com> Date: Fri, 6 Aug 2021 11:38:42 +0200 Subject: [PATCH 5/6] Update versionchanged --- reframe/core/pipeline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index fcbdf419de..250e61d6be 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -355,7 +355,7 @@ def pipeline_hooks(cls): #: :type: :class:`str` #: :default: :class:`required` #: - #: .. versionchanged:: 3.8 + #: .. versionchanged:: 3.7.3 #: Default value changed from ``os.path.join('.', self.name)`` to #: :class:`required`. executable = variable(str) From 8b55bb92cfe77cd3ab6f9c1c0cd5de4740b85e8a Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Fri, 6 Aug 2021 13:39:22 +0200 Subject: [PATCH 6/6] Minor rephrase in documentation --- docs/tutorial_advanced.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/tutorial_advanced.rst b/docs/tutorial_advanced.rst index f7c2225632..a5c72b97d8 100644 --- a/docs/tutorial_advanced.rst +++ b/docs/tutorial_advanced.rst @@ -261,7 +261,8 @@ Here is the full regression test: :lines: 6- :emphasize-lines: 6 -There is nothing special for this test compared to those presented so far except that it derives from the :class:`~reframe.core.pipeline.RunOnlyRegressionTest` class, and setting the :attr:`~reframe.core.pipeline.RegressionTest.executable` in this type of test is always required. +There is nothing special for this test compared to those presented so far except that it derives from the :class:`~reframe.core.pipeline.RunOnlyRegressionTest` class. +Note that setting the :attr:`~reframe.core.pipeline.RegressionTest.executable` in this type of test is always required. Run-only regression tests may also have resources, as for instance a pre-compiled executable or some input data. These resources may reside under the ``src/`` directory or under any directory specified in the :attr:`~reframe.core.pipeline.RegressionTest.sourcesdir` attribute. These resources will be copied to the stage directory at the beginning of the run phase.