Skip to content

Commit

Permalink
[bugfix] Fix error when more than one instance of the same fixture cl…
Browse files Browse the repository at this point in the history
…ass are specified
  • Loading branch information
tom91136 authored and vkarak committed Dec 5, 2024
1 parent 676aade commit 887b0c7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
4 changes: 3 additions & 1 deletion reframe/core/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,9 @@ def _resolve_fixtures(self):
# registered under the same fixture class. So the loop below must
# also inspect the fixture data the instance was registered with.
for fixt_name, fixt_data in registry[f.cls].items():
if f.scope != fixt_data.scope:
if fixt_data.variables != f.variables:
continue
elif f.scope != fixt_data.scope:
continue
elif fixt_data.variant_num not in target_variants:
continue
Expand Down
33 changes: 33 additions & 0 deletions unittests/resources/checks_unlisted/fixtures_same_class.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright 2016-2024 Swiss National Supercomputing Centre (CSCS/ETH Zurich)
# ReFrame Project Developers. See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: BSD-3-Clause

import reframe as rfm
import reframe.utility.sanity as sn


class HelloFixture(rfm.RunOnlyRegressionTest):
executable = 'echo hello from fixture'
myvar = variable(str)

@sanity_function
def assert_output(self):
return sn.assert_found(r'hello from fixture', self.stdout)


@rfm.simple_test
class TestA(rfm.RunOnlyRegressionTest):
valid_systems = ['*']
valid_prog_environs = ['*']

dep1 = fixture(HelloFixture, scope='environment', variables={'myvar': 'a'})
dep2 = fixture(HelloFixture, scope='environment', variables={'myvar': 'b'})

@run_after('setup')
def after_setup(self):
self.executable = f"echo {self.dep1.myvar} {self.dep2.myvar}"

@sanity_function
def validate(self):
return sn.assert_found(r'a b', self.stdout)
8 changes: 8 additions & 0 deletions unittests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,14 @@ def test_fixture_resolution(run_reframe, run_action):
)
assert returncode == 0

def test_fixture_resolution_same_class(run_reframe, run_action):
returncode, stdout, stderr = run_reframe(
system='sys1',
environs=[],
checkpath=['unittests/resources/checks_unlisted/fixtures_same_class.py'],
action=run_action
)
assert returncode == 0

def test_dynamic_tests(run_reframe, run_action):
returncode, stdout, _ = run_reframe(
Expand Down

0 comments on commit 887b0c7

Please sign in to comment.