From: stevenknight Date: Fri, 14 Mar 2003 06:22:34 +0000 (+0000) Subject: Fix WhereIs() to return a normalized path. (Lachlan O'Dea) X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cd56e40daf08175e146fc9748368793fff668bdc;p=scons.git Fix WhereIs() to return a normalized path. (Lachlan O'Dea) git-svn-id: http://scons.tigris.org/svn/scons/trunk@612 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 3f9c1b49..2ddcf5ae 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -71,6 +71,8 @@ RELEASE 0.12 - XXX - Add SharedObject() support to the masm tool. + - Fix WhereIs() to return normalized paths. + RELEASE 0.11 - Tue, 11 Feb 2003 05:24:33 -0600 diff --git a/src/engine/SCons/Util.py b/src/engine/SCons/Util.py index 16ff3886..3bfb79a9 100644 --- a/src/engine/SCons/Util.py +++ b/src/engine/SCons/Util.py @@ -731,7 +731,7 @@ if sys.platform == 'win32': for ext in pathext: fext = f + ext if os.path.isfile(fext): - return fext + return os.path.normpath(fext) return None elif os.name == 'os2': @@ -752,7 +752,7 @@ elif os.name == 'os2': for ext in pathext: fext = f + ext if os.path.isfile(fext): - return fext + return os.path.normpath(fext) return None else: @@ -770,7 +770,7 @@ else: except: continue if stat.S_IMODE(st[stat.ST_MODE]) & 0111: - return f + return os.path.normpath(f) return None def ParseConfig(env, command, function=None): diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py index 603631cc..890f54dc 100644 --- a/src/engine/SCons/UtilTests.py +++ b/src/engine/SCons/UtilTests.py @@ -508,15 +508,21 @@ class UtilTestCase(unittest.TestCase): wi = WhereIs('xxx.exe', string.join(pathdirs_1234, os.pathsep)) assert wi == test.workpath(sub3_xxx_exe), wi - if sys.platform == 'win32': - wi = WhereIs('xxx', pathext = '') - assert wi is None, wi + if sys.platform == 'win32': + wi = WhereIs('xxx', pathext = '') + assert wi is None, wi - wi = WhereIs('xxx', pathext = '.exe') - assert wi == test.workpath(sub4_xxx_exe), wi + wi = WhereIs('xxx', pathext = '.exe') + assert wi == test.workpath(sub4_xxx_exe), wi - wi = WhereIs('xxx', path = pathdirs_1234, pathext = '.BAT;.EXE') - assert string.lower(wi) == string.lower(test.workpath(sub3_xxx_exe)), wi + wi = WhereIs('xxx', path = pathdirs_1234, pathext = '.BAT;.EXE') + assert string.lower(wi) == string.lower(test.workpath(sub3_xxx_exe)), wi + + # Test that we return a normalized path even when + # the path contains forward slashes. + forward_slash = test.workpath('') + '/sub3' + wi = WhereIs('xxx', path = forward_slash, pathext = '.EXE') + assert string.lower(wi) == string.lower(test.workpath(sub3_xxx_exe)), wi def test_get_env_var(self): """Testing get_environment_var()."""