From d680e755c2427fd7fc217bed87812431b32d85ae Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Sat, 17 Dec 2022 11:06:33 +0100 Subject: [PATCH 1/2] Fix test hash calculation for parameterised tests --- reframe/core/pipeline.py | 2 +- unittests/test_pipeline.py | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/reframe/core/pipeline.py b/reframe/core/pipeline.py index 6ef5dc1e64..0deb82e6ff 100644 --- a/reframe/core/pipeline.py +++ b/reframe/core/pipeline.py @@ -1194,7 +1194,7 @@ def hashcode(self): return self._rfm_hashcode m = hashlib.sha256() - if self.is_fixture: + if self.is_fixture(): m.update(self.unique_name.encode('utf-8')) else: basename, *params = self.display_name.split(' %') diff --git a/unittests/test_pipeline.py b/unittests/test_pipeline.py index 8d666453e9..1332a59147 100644 --- a/unittests/test_pipeline.py +++ b/unittests/test_pipeline.py @@ -1902,6 +1902,33 @@ def set_defaults(self): assert x.bar == 100 +def test_hashcode(): + # We always redefine _X0 here so that the test gets always the same base + # name (class name) and only the parameter values should change. We then + # use aliases to access the various definitions for our assertions. + + class _X0(rfm.RunOnlyRegressionTest): + p = parameter([1]) + + class _X0(rfm.RunOnlyRegressionTest): + p = parameter([2]) + + _X1 = _X0 + + class _X0(rfm.RunOnlyRegressionTest): + p = parameter([1, 2]) + + _X2 = _X0 + + t0 = _X0(variant_num=0) + t1 = _X1(variant_num=0) + t2, t3 = (_X2(variant_num=i) for i in range(_X2.num_variants)) + + assert t0.hashcode != t1.hashcode + assert t2.hashcode == t0.hashcode + assert t3.hashcode == t1.hashcode + + def test_variables_deprecation(): with pytest.warns(ReframeDeprecationWarning): class _X(rfm.RunOnlyRegressionTest): From 4ab7308a474feb5706f9771db16885c19f053dfd Mon Sep 17 00:00:00 2001 From: Vasileios Karakasis Date: Sat, 17 Dec 2022 11:35:16 +0100 Subject: [PATCH 2/2] Fix unit tests --- unittests/test_filters.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/unittests/test_filters.py b/unittests/test_filters.py index 3ebbbd4013..ff0fa39c06 100644 --- a/unittests/test_filters.py +++ b/unittests/test_filters.py @@ -83,7 +83,9 @@ def test_have_any_name_param_test(sample_param_cases): sample_param_cases) assert 0 == count_checks(filters.have_any_name(['_X@12']), sample_param_cases) - assert 2 == count_checks(filters.have_any_name(['/023313dc', '/efddbc6c']), + + # The /0951c7ff selects two tests as they both have x=1 + assert 3 == count_checks(filters.have_any_name(['/0951c7ff', '/37e9e1c6']), sample_param_cases) assert 2 == count_checks(filters.have_any_name(['_X@0', '_X@1']), sample_param_cases)