Repository: reframe-hpc/reframe

Issue:
`--describe` option shows `reference` as `null` even if it is defined
Example:

```python
@rfm.simple_test
class stream_test(rfm.RegressionTest):
    valid_systems = ['*']
    valid_prog_environs = ['+openmp']
    build_system = 'SingleSource'
    sourcepath = 'stream.c'
    reference = {
        'tresa': {
            'copy_bandwidth': (23000, -0.05, None, 'MB/s')
        }
    }

    ...
```

```bash
./bin/reframe -C tutorials/cscs-webinar-2022/config/mysettings.py -c tutorials/cscs-webinar-2022/tests/stream6.py --describe | jq .[].reference
```

```console
null
null
```

Discussion:

Patch:
diff --git a/reframe/utility/__init__.py b/reframe/utility/__init__.py
index 12edb01e..a381abea 100644
--- a/reframe/utility/__init__.py
+++ b/reframe/utility/__init__.py
@@ -1275,6 +1275,9 @@ class ScopedDict(UserDict):
     def __missing__(self, key):
         raise KeyError(str(key))
 
+    def __rfm_json_encode__(self):
+        return self.data
+
 
 @functools.total_ordering
 class OrderedSet(collections.abc.MutableSet):


Test patch:
diff --git a/unittests/test_utility.py b/unittests/test_utility.py
index b89236ce..224d4dc0 100644
--- a/unittests/test_utility.py
+++ b/unittests/test_utility.py
@@ -799,7 +799,6 @@ def test_scoped_dict_construction():
         'a': {'k1': 3, 'k2': 4},
         'b': {'k3': 5}
     }
-    namespace_dict = reframe.utility.ScopedDict()
     namespace_dict = reframe.utility.ScopedDict(d)
 
     # Change local dict and verify that the stored values are not affected
@@ -1088,6 +1087,17 @@ def test_scoped_dict_update():
     assert scoped_dict == scoped_dict_alt
 
 
+def test_scoped_dict_json_enc():
+    import json
+
+    d = {
+        'a': {'k1': 3, 'k2': 4},
+        'b': {'k3': 5}
+    }
+    ns_dict = reframe.utility.ScopedDict(d)
+    assert d == json.loads(jsonext.dumps(ns_dict))
+
+
 def test_sequence_view():
     l = util.SequenceView([1, 2, 2])
     assert 1 == l[0]