Skip to content

Commit a99eeb9

Browse files
authored
Merge branch 'master' into enhancement/warn_invalid_mode
2 parents e48f904 + ec6acac commit a99eeb9

File tree

5 files changed

+82
-5
lines changed

5 files changed

+82
-5
lines changed

reframe/frontend/loader.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,23 @@ def load_from_module(self, module):
177177
if not self._validate_check(c):
178178
continue
179179

180-
testfile = module.__file__
180+
# Get the original filename in case of a different module name
181+
if module.__name__ == c.__module__:
182+
testfile = module.__file__
183+
else:
184+
testfile = inspect.getfile(c.__class__)
185+
181186
try:
182187
conflicted = self._loaded[c.unique_name]
183188
except KeyError:
184189
self._loaded[c.unique_name] = testfile
185190
final_tests.append(c)
186191
else:
187-
raise NameConflictError(
188-
f'test {c.unique_name!r} from {testfile!r} '
189-
f'is already defined in {conflicted!r}'
190-
)
192+
if not c.is_fixture():
193+
raise NameConflictError(
194+
f'test {c.unique_name!r} from {testfile!r} '
195+
f'is already defined in {conflicted!r}'
196+
)
191197

192198
getlogger().debug(f' > Loaded {len(final_tests)} test(s)')
193199
return final_tests
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2016-2023 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
2+
# ReFrame Project Developers. See the top-level LICENSE file for details.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
import reframe as rfm
7+
8+
from testlib.simple import simple_echo_check
9+
10+
11+
@rfm.simple_test
12+
class HelloBar(simple_echo_check):
13+
message = 'Bar'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2016-2023 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
2+
# ReFrame Project Developers. See the top-level LICENSE file for details.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
import reframe as rfm
7+
8+
from testlib.simple import simple_echo_check
9+
10+
11+
@rfm.simple_test
12+
class HelloFoo(simple_echo_check):
13+
message = 'Foo'
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright 2016-2023 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
2+
# ReFrame Project Developers. See the top-level LICENSE file for details.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
import reframe as rfm
7+
import reframe.utility.sanity as sn
8+
9+
10+
class dummy_fixture(rfm.RunOnlyRegressionTest, pin_prefix=True):
11+
executable = 'echo'
12+
sanity_patterns = sn.assert_true(1)
13+
14+
15+
@rfm.simple_test
16+
class simple_echo_check(rfm.RunOnlyRegressionTest):
17+
descr = 'Simple Echo Test'
18+
valid_systems = ['*']
19+
valid_prog_environs = ['builtin']
20+
executable = 'echo'
21+
executable_opts = ['Hello']
22+
message = variable(str, value='World')
23+
dummy = fixture(dummy_fixture, scope='environment')
24+
25+
@run_before('run')
26+
def set_executable_opts(self):
27+
self.executable_opts += [self.message]
28+
29+
@sanity_function
30+
def assert_sanity(self):
31+
return sn.assert_found(rf'Hello {self.message}', self.stdout)

unittests/test_cli.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,3 +1059,17 @@ def test_dynamic_tests_filtering(run_reframe, tmp_path):
10591059
assert returncode == 0
10601060
assert 'Ran 7/7 test case(s)' in stdout
10611061
assert 'FAILED' not in stdout
1062+
1063+
1064+
def test_testlib_inherit_fixture_in_different_files(run_reframe, monkeypatch):
1065+
monkeypatch.syspath_prepend('unittests/resources')
1066+
returncode, stdout, _ = run_reframe(
1067+
checkpath=[
1068+
'unittests/resources/checks_unlisted/testlib_inheritance_foo.py',
1069+
'unittests/resources/checks_unlisted/testlib_inheritance_bar.py'
1070+
],
1071+
action='run',
1072+
)
1073+
assert returncode == 0
1074+
assert 'Ran 3/3 test case(s)' in stdout
1075+
assert 'FAILED' not in stdout

0 commit comments

Comments
 (0)