Skip to content

Commit

Permalink
Merge pull request #3339 from vkarak/bugfix/nodelist-abbrev-multiple-10
Browse files Browse the repository at this point in the history
[bugfix] Fix nodelist abbreviation when last node number is a multiple of 10
  • Loading branch information
vkarak authored Dec 6, 2024
2 parents 925be11 + 130179a commit 3dafd84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion reframe/utility/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def count_digits(n):
'''

num_digits = 1
while n > 10:
while n >= 10:
n /= 10
num_digits += 1

Expand Down
8 changes: 8 additions & 0 deletions unittests/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,14 @@ def test_nodelist_utilities():
assert nodelist(nodes) == 'nid0[00-99]-x,nid100-y'
assert expand('nid0[00-99]-x,nid100-y') == nodes

# Test edge condition when node lists jump from N to N+1 digits
# See GH issue #3338
nodes = ['vs-std-0009', 'vs-std-0010', 'vs-std-0099', 'vs-std-0100']
assert nodelist(nodes) == 'vs-std-00[09-10],vs-std-0[099-100]'
assert expand('vs-std-00[09-10],vs-std-0[099-100]') == [
'vs-std-0009', 'vs-std-0010', 'vs-std-0099', 'vs-std-0100'
]

# Test node duplicates
assert nodelist(['nid001', 'nid001', 'nid002']) == 'nid001,nid00[1-2]'
assert expand('nid001,nid00[1-2]') == ['nid001', 'nid001', 'nid002']
Expand Down

0 comments on commit 3dafd84

Please sign in to comment.