From f9ab03a968bd55225b812ea0f02213d19b724a30 Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Fri, 12 Mar 2021 11:05:43 +0100 Subject: [PATCH 1/3] Allow setting all variables from the class body --- reframe/core/pipeline.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 5cd02efe0a..07903f076d 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -234,7 +234,7 @@ def pipeline_hooks(cls): #: #: :type: :class:`str` #: :default: ``self.name`` - descr = variable(str) + descr = variable(str, type(None), value=None) #: The path to the source file or source directory of the test. #: @@ -329,7 +329,7 @@ def pipeline_hooks(cls): #: #: :type: :class:`str` #: :default: ``os.path.join('.', self.name)`` - executable = variable(str) + executable = variable(str, type(None), value=None) #: List of options to be passed to the :attr:`executable`. #: @@ -802,8 +802,12 @@ def _rfm_init(self, name=None, prefix=None): if name is not None: self.name = name - self.descr = self.name - self.executable = os.path.join('.', self.name) + if not self.descr: + self.descr = self.name + + if not self.executable: + self.executable = os.path.join('.', self.name) + self._perfvalues = {} # Static directories of the regression check From 5dc9d931d74a04731fd7c7a67879bdd5c3dc3b74 Mon Sep 17 00:00:00 2001 From: Javier Otero Date: Fri, 12 Mar 2021 11:51:22 +0100 Subject: [PATCH 2/3] Allow setting the executable as required --- reframe/core/pipeline.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 07903f076d..e12ff81067 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -802,11 +802,21 @@ def _rfm_init(self, name=None, prefix=None): if name is not None: self.name = name - if not self.descr: - self.descr = self.name + try: + if not self.descr: + self.descr = self.name + + except AttributeError: + # Pass if descr is a required variable. + pass - if not self.executable: - self.executable = os.path.join('.', self.name) + try: + if not self.executable: + self.executable = os.path.join('.', self.name) + + except AttributeError: + # Pass if the executable is a required variable. + pass self._perfvalues = {} From a38458d4f97416fa690e98fd9182456edc62e3b6 Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Fri, 12 Mar 2021 16:55:43 +0100 Subject: [PATCH 3/3] Minor implementation improvements - Use `contextlib.suppress` instead of `try/except/pass`. - Check explicitly for `None` so as to allow empty strings. --- reframe/core/pipeline.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index e12ff81067..f223455702 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -13,6 +13,7 @@ ] +import contextlib import functools import glob import inspect @@ -802,22 +803,16 @@ def _rfm_init(self, name=None, prefix=None): if name is not None: self.name = name - try: - if not self.descr: + # Pass if descr is a required variable. + with contextlib.suppress(AttributeError): + if self.descr is None: self.descr = self.name - except AttributeError: - # Pass if descr is a required variable. - pass - - try: - if not self.executable: + # Pass if the executable is a required variable. + with contextlib.suppress(AttributeError): + if self.executable is None: self.executable = os.path.join('.', self.name) - except AttributeError: - # Pass if the executable is a required variable. - pass - self._perfvalues = {} # Static directories of the regression check