Currently join doesn't handle empty values correctly, as it will add an extra {SEPARATOR} for each of them.
Passing in this value: ['', 'foo', 'bar', ''] will result in this: '@foo@bar@' This obviously isn't what we want, we really want 'foo@bar', and this patch corrects the behavior to do that. Signed-off-by: Dylan Baker <dylanx.c.ba...@intel.com> --- framework/grouptools.py | 9 +++++++++ framework/tests/grouptools_tests.py | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/framework/grouptools.py b/framework/grouptools.py index d6749d6..b223bf4 100644 --- a/framework/grouptools.py +++ b/framework/grouptools.py @@ -109,6 +109,15 @@ def join(first, *args): conincedently very similar to the way posixpath.join is implemented. """ + # If first happens to be a non-existant value, walk through args until we + # find a real value and use that. + args = (a for a in args) + if not first: + for group in args: + if group: + first = group + break + for group in args: # Only append things if the group is not empty, otherwise we'll get # extra SEPARATORs where we don't want them diff --git a/framework/tests/grouptools_tests.py b/framework/tests/grouptools_tests.py index e3b4ee0..f36e350 100644 --- a/framework/tests/grouptools_tests.py +++ b/framework/tests/grouptools_tests.py @@ -107,3 +107,10 @@ def test_commonprefix_empty(): value = grouptools.commonprefix((grouptools.join('foo', 'bar'), '')) nt.eq_(expected, value) + + +def test_join_empty(): + """grouptools.join: empty values are not joined""" + expected = 'spec' + test = grouptools.join('', 'spec') + nt.eq_(expected, test) -- 2.5.1 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit