Fix WhereIs() to return a normalized path. (Lachlan O'Dea)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 14 Mar 2003 06:22:34 +0000 (06:22 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 14 Mar 2003 06:22:34 +0000 (06:22 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@612 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Util.py
src/engine/SCons/UtilTests.py

index 3f9c1b49e51877915de3650e8f483421e0d0f489..2ddcf5aef48b67444253ae8cc5c2072e78728a25 100644 (file)
@@ -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
index 16ff38867d2b3de7b0bf6c1b28e0f4efd7d3d950..3bfb79a9eaa4d0b01281829d699a4cb7cba3df0b 100644 (file)
@@ -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):
index 603631cc5c1a08a35ebc6e13b01e9df9fb38910d..890f54dcf0b70e7ff40f98075acde96982695a89 100644 (file)
@@ -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()."""