summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/EnvironmentTests.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-09-05 15:33:09 (GMT)
committerSteven Knight <knight@baldmt.com>2002-09-05 15:33:09 (GMT)
commit3cc2054726843bc99b8efe37964db7d94aeec1e7 (patch)
tree1e8bb877b01a593ddc0363675a2bdd4124359bbd /src/engine/SCons/EnvironmentTests.py
parent246819663b8eaeb130580f4b97990248f26eaadd (diff)
downloadSCons-3cc2054726843bc99b8efe37964db7d94aeec1e7.zip
SCons-3cc2054726843bc99b8efe37964db7d94aeec1e7.tar.gz
SCons-3cc2054726843bc99b8efe37964db7d94aeec1e7.tar.bz2
Refactor SCons.Util.Detect() into an Environment method.
Diffstat (limited to 'src/engine/SCons/EnvironmentTests.py')
-rw-r--r--src/engine/SCons/EnvironmentTests.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 8154990..21d241d 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -23,8 +23,10 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+import os
import string
import sys
+import TestCmd
import unittest
from SCons.Environment import *
@@ -580,7 +582,35 @@ class EnvironmentTestCase(unittest.TestCase):
assert dict['_CPPINCFLAGS'][17] == '$)', \
dict['_CPPINCFLAGS'][17]
+ def test_Detect(self):
+ """Test Detect()ing tools"""
+ test = TestCmd.TestCmd(workdir = '')
+ test.subdir('sub1', 'sub2')
+ test.write(['sub1', 'xxx.exe'], "sub1/xxx.exe\n")
+ test.write(['sub2', 'xxx.exe'], "sub2/xxx.exe\n")
+ sub1 = test.workpath('sub1')
+ sub2 = test.workpath('sub2')
+ env = Environment(ENV = { 'PATH' : [sub1, sub2] })
+ x = env.Detect('xxx.exe')
+ assert x is None, x
+
+ sub2_xxx_exe = test.workpath('sub2', 'xxx.exe')
+ os.chmod(sub2_xxx_exe, 0755)
+
+ env = Environment(ENV = { 'PATH' : [sub1, sub2] })
+ x = env.Detect('xxx.exe')
+ assert x == 'xxx.exe'
+
+ sub1_xxx_exe = test.workpath('sub1', 'xxx.exe')
+ os.chmod(sub1_xxx_exe, 0755)
+
+ x = env.Detect('xxx.exe')
+ assert x == 'xxx.exe'
+
+ env = Environment(ENV = { 'PATH' : [] })
+ x = env.Detect('xxx.exe')
+ assert x is None, x
def test_platform(self):
"""Test specifying a platform callable when instantiating."""