summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-03-14 06:22:34 (GMT)
committerSteven Knight <knight@baldmt.com>2003-03-14 06:22:34 (GMT)
commitd23c48ac837a86808c6bd3713149498684400411 (patch)
tree7b8ba573ba311a71cde70cf00e7d6e7e1ab22330
parent71a49faea8b046709ef816aee7b7bb5f9e4a1ccc (diff)
downloadSCons-d23c48ac837a86808c6bd3713149498684400411.zip
SCons-d23c48ac837a86808c6bd3713149498684400411.tar.gz
SCons-d23c48ac837a86808c6bd3713149498684400411.tar.bz2
Fix WhereIs() to return a normalized path. (Lachlan O'Dea)
-rw-r--r--src/CHANGES.txt2
-rw-r--r--src/engine/SCons/Util.py6
-rw-r--r--src/engine/SCons/UtilTests.py20
3 files changed, 18 insertions, 10 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index 3f9c1b4..2ddcf5a 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 16ff388..3bfb79a 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 603631c..890f54d 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()."""