Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] Fix nodelist abbreviation when last node number is a multiple of 10 #3339

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading