Repository: reframe-hpc/reframe

Issue:
`-n` and `-x` are not combined correctly
Combining the `-n` and trying to exclude a test using the `-x` it has no effect. How to reproduce:

```
./bin/reframe -C config/machines.py -c tutorials/cscs-webinar-2022/tests/stream9.py -n stream_scale_test -x /5ccda674 -l
```

```
- stream_scale_test %threading=4 %stream_binaries.elem_type=float /5ccda674
    ^stream_build %elem_type=float ~tresa:default+gnu /bed1cb01
- stream_scale_test %threading=2 %stream_binaries.elem_type=float /a02e1a74
    ^stream_build %elem_type=float ~tresa:default+gnu /bed1cb01
- stream_scale_test %threading=1 %stream_binaries.elem_type=float /a54fb2dd
    ^stream_build %elem_type=float ~tresa:default+gnu /bed1cb01
- stream_scale_test %threading=4 %stream_binaries.elem_type=double /986c1e0b
    ^stream_build %elem_type=double ~tresa:default+gnu /3d9fd09f
- stream_scale_test %threading=2 %stream_binaries.elem_type=double /d976421a
    ^stream_build %elem_type=double ~tresa:default+gnu /3d9fd09f
- stream_scale_test %threading=1 %stream_binaries.elem_type=double /b7f1a81d
    ^stream_build %elem_type=double ~tresa:default+gnu /3d9fd09f
```

Although the `stream_scale_test` is selected, but the test with `threading=4` (5ccda674) is still selected.

Comments:

Patch:
diff --git a/reframe/frontend/filters.py b/reframe/frontend/filters.py
index 20441a18..9edf3ced 100644
--- a/reframe/frontend/filters.py
+++ b/reframe/frontend/filters.py
@@ -26,6 +26,9 @@ def _have_name(patt):
         if '@' in patt:
             # Do an exact match on the unique name
             return patt.replace('@', '_') == case.check.unique_name
+        elif patt.startswith('/'):
+            # Do an exact match on the hashcode
+            return patt[1:] == case.check.hashcode
         else:
             return regex.match(display_name)
 


Test patch:
diff --git a/unittests/test_cli.py b/unittests/test_cli.py
index 6a6ca2da..031ad27d 100644
--- a/unittests/test_cli.py
+++ b/unittests/test_cli.py
@@ -574,7 +574,7 @@ def test_list_tags(run_reframe):
     assert returncode == 0
 
 
-def test_filtering_multiple_criteria(run_reframe):
+def test_filtering_multiple_criteria_name(run_reframe):
     returncode, stdout, stderr = run_reframe(
         checkpath=['unittests/resources/checks'],
         action='list',
@@ -586,6 +586,30 @@ def test_filtering_multiple_criteria(run_reframe):
     assert returncode == 0
 
 
+def test_filtering_multiple_criteria_hash(run_reframe):
+    returncode, stdout, stderr = run_reframe(
+        checkpath=['unittests/resources/checks'],
+        action='list',
+        more_options=['-t', 'foo', '-n', '/2b3e4546']
+    )
+    assert 'Traceback' not in stdout
+    assert 'Traceback' not in stderr
+    assert 'Found 1 check(s)' in stdout
+    assert returncode == 0
+
+
+def test_filtering_exclude_hash(run_reframe):
+    returncode, stdout, stderr = run_reframe(
+        checkpath=['unittests/resources/checks'],
+        action='list',
+        more_options=['-x', '/2b3e4546']
+    )
+    assert 'Traceback' not in stdout
+    assert 'Traceback' not in stderr
+    assert 'Found 8 check(s)' in stdout
+    assert returncode == 0
+
+
 def test_show_config_all(run_reframe):
     # Just make sure that this option does not make the frontend crash
     returncode, stdout, stderr = run_reframe(