diff --git a/tests/apis/wscript b/tests/apis/wscript index 62777a66..bba9bed4 100755 --- a/tests/apis/wscript +++ b/tests/apis/wscript @@ -56,7 +56,8 @@ def test(ctx): tt('path_from', dd.path_from(pp), os.path.split(os.getcwd())[1]) tt('path_from (reverse)', pp.path_from(dd), '..') tt('same path', pp.path_from(pp), '.') - tt('same_root', bld.root.path_from(bld.root), '.') + tt('path from root is abspath()', pp.path_from(bld.root), pp.abspath()) + tt('root from root', bld.root.path_from(bld.root), bld.root.abspath()) tt('root height', bld.root.height(), 0) tt('self height', dd.height(), len(absdir)) diff --git a/waflib/Node.py b/waflib/Node.py index eba07551..b3a93639 100644 --- a/waflib/Node.py +++ b/waflib/Node.py @@ -430,10 +430,9 @@ class Node(object): :param node: path to use as a reference :type node: :py:class:`waflib.Node.Node` - :returns: the relative path + :returns: a relative path or an absolute one if that is better :rtype: string """ - c1 = self c2 = node @@ -461,13 +460,11 @@ class Node(object): c2 = c2.parent if c1.parent: - for i in range(up): - lst.append('..') + lst.extend(['..'] * up) + lst.reverse() + return os.sep.join(lst) or '.' else: - if lst and not Utils.is_win32: - lst.append('') - lst.reverse() - return os.sep.join(lst) or '.' + return self.abspath() def abspath(self): """