diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 4748f00469..858bae8aac 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -158,7 +158,9 @@ class RegressionTest(metaclass=RegressionTestMeta): typ.List[str]) #: List of systems supported by this test. - #: The general syntax for systems is ``[:[:]``. + #: Both and accept the value ``*`` to mean any value. + #: ``*`` is an alias of ``*:*`` #: #: :type: :class:`List[str]` #: :default: ``[]`` @@ -949,19 +951,16 @@ def info(self): return ret - def supports_system(self, partition_name): - if '*' in self.valid_systems: - return True - - if self.current_system.name in self.valid_systems: - return True + def supports_system(self, name): + if name.find(':') != -1: + system, partition = name.split(':') + else: + system, partition = self.current_system.name, name - # Check if this is a relative name - if partition_name.find(':') == -1: - partition_name = '%s:%s' % (self.current_system.name, - partition_name) + valid_matches = ['*', '*:*', system, f'{system}:*', + f'*:{partition}', f'{system}:{partition}'] - return partition_name in self.valid_systems + return any(n in self.valid_systems for n in valid_matches) def supports_environ(self, env_name): if '*' in self.valid_prog_environs: diff --git a/unittests/test_pipeline.py b/unittests/test_pipeline.py index b5ce62c24f..e0c010921a 100644 --- a/unittests/test_pipeline.py +++ b/unittests/test_pipeline.py @@ -263,6 +263,12 @@ def test_supports_system(self): assert test.supports_system('testsys:gpu') assert test.supports_system('testsys:login') + test.valid_systems = ['*:*'] + assert test.supports_system('gpu') + assert test.supports_system('login') + assert test.supports_system('testsys:gpu') + assert test.supports_system('testsys:login') + test.valid_systems = ['testsys'] assert test.supports_system('gpu') assert test.supports_system('login') @@ -287,6 +293,17 @@ def test_supports_system(self): assert not test.supports_system('testsys:gpu') assert not test.supports_system('testsys:login') + test.valid_systems = ['*:gpu'] + assert test.supports_system('testsys:gpu') + assert test.supports_system('foo:gpu') + assert not test.supports_system('testsys:cpu') + assert not test.supports_system('testsys:login') + + test.valid_systems = ['testsys:*'] + assert test.supports_system('testsys:login') + assert test.supports_system('gpu') + assert not test.supports_system('foo:gpu') + def test_supports_environ(self): test = self.loader.load_from_file( 'unittests/resources/checks/hellocheck.py')[0]