Repository: reframe-hpc/reframe

Issue:
Nodelist in failure report adds a `None` at the end
This is very easy to reproduce:

```
./bin/reframe -c unittests/resources/checks/hellocheck.py -S 'prerun_cmds=set -e;foo' -r
```

```
FAILURE INFO for HelloTest
  * Expanded name: HelloTest
  * Description: C Hello World test
  * System partition: generic:default
  * Environment: builtin
  * Stage directory: /Users/karakasv/Repositories/reframe/stage/generic/default/builtin/HelloTest
  * Node list: tresa.localNone
  * Job type: local (id=80795)
  * Dependencies (conceptual): []
  * Dependencies (actual): []
  * Maintainers: ['VK']
  * Failing phase: sanity
  * Rerun with '-n /2b3e4546 -p builtin --system generic:default -r'
  * Reason: sanity error: pattern 'Hello, World\\!' not found in 'rfm_job.out'
```

Discussion:

Patch:
diff --git a/reframe/utility/__init__.py b/reframe/utility/__init__.py
index aa678bce..f6b7d664 100644
--- a/reframe/utility/__init__.py
+++ b/reframe/utility/__init__.py
@@ -836,6 +836,9 @@ class _NodeGroup:
         self.__nodes.append(nid)
 
     def __str__(self):
+        if not self.__nodes:
+            return self.__name
+
         abbrev = []
         encoded = _rl_encode(_delta_encode(self.nodes))
         for unit in encoded:
@@ -920,7 +923,8 @@ def nodelist_abbrev(nodes):
         basename, width, nid = _parse_node(n)
         ng = _NodeGroup(basename, width)
         node_groups.setdefault(ng, ng)
-        node_groups[ng].add(nid)
+        if nid is not None:
+            node_groups[ng].add(nid)
 
     return ','.join(str(ng) for ng in node_groups)
 


Test patch:
diff --git a/unittests/test_utility.py b/unittests/test_utility.py
index 4e9f8fe7..d3392b8d 100644
--- a/unittests/test_utility.py
+++ b/unittests/test_utility.py
@@ -1800,6 +1800,8 @@ def test_nodelist_utilities():
     assert nodelist(['nid01', 'nid10', 'nid20']) == 'nid01,nid10,nid20'
     assert nodelist([]) == ''
     assert nodelist(['nid001']) == 'nid001'
+    assert nodelist(['node']) == 'node'
+    assert nodelist(['nid001', 'node', 'nid002']) == 'nid00[1-2],node'
 
     # Test the reverse operation
     assert expand('nid00[0-4],nid01[0-4],nid02[0-4]') == sorted(nid_nodes)