summaryrefslogtreecommitdiff
path: root/src/engine/SCons/EnvironmentTests.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-04-14 13:09:11 +0000
committerSteven Knight <knight@baldmt.com>2004-04-14 13:09:11 +0000
commit73f9a42aaa603934e51ffb10bc256e9a3c17cd9b (patch)
tree9fc71cff3cdd7238433923ca761f8d74a8ce23d9 /src/engine/SCons/EnvironmentTests.py
parente4adb76f832acf1d22f99801a54abb9ea1562182 (diff)
downloadscons-73f9a42aaa603934e51ffb10bc256e9a3c17cd9b.tar.gz
Fix custom scanner behavior when setting/copying/replacing the SCANNERS construction variable.
Diffstat (limited to 'src/engine/SCons/EnvironmentTests.py')
-rw-r--r--src/engine/SCons/EnvironmentTests.py87
1 files changed, 62 insertions, 25 deletions
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 3447e7bf..0995a053 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -108,10 +108,17 @@ class Scanner:
self.skeys = skeys
def __call__(self, filename):
+ global scanned_it
scanned_it[filename] = 1
def __cmp__(self, other):
- return cmp(self.__dict__, other.__dict__)
+ try:
+ return cmp(self.__dict__, other.__dict__)
+ except AttributeError:
+ return 1
+
+ def get_skeys(self, env):
+ return self.skeys
@@ -538,43 +545,73 @@ class EnvironmentTestCase(unittest.TestCase):
assert built_it['out2']
def test_Scanners(self):
- """Test Scanner execution through different environments
+ """Test setting SCANNERS in various ways
One environment is initialized with a single
Scanner object, one with a list of a single Scanner
object, and one with a list of two Scanner objects.
"""
-# global scanned_it
-#
-# s1 = Scanner(name = 'scanner1', skeys = [".c", ".cc"])
-# s2 = Scanner(name = 'scanner2', skeys = [".m4"])
-#
-# scanned_it = {}
-# env1 = Environment(SCANNERS = s1)
+ global scanned_it
+
+ s1 = Scanner(name = 'scanner1', skeys = [".c", ".cc"])
+ s2 = Scanner(name = 'scanner2', skeys = [".m4"])
+ s3 = Scanner(name = 'scanner3', skeys = [".m4", ".m5"])
+
+# XXX Tests for scanner execution through different environments,
+# XXX if we ever want to do that some day
+# scanned_it = {}
+# env1 = Environment(SCANNERS = s1)
# env1.scanner1(filename = 'out1')
-# assert scanned_it['out1']
+# assert scanned_it['out1']
#
-# scanned_it = {}
-# env2 = Environment(SCANNERS = [s1])
+# scanned_it = {}
+# env2 = Environment(SCANNERS = [s1])
# env1.scanner1(filename = 'out1')
-# assert scanned_it['out1']
+# assert scanned_it['out1']
#
-# scanned_it = {}
+# scanned_it = {}
# env3 = Environment()
-# env3.Replace(SCANNERS = [s1, s2])
+# env3.Replace(SCANNERS = [s1])
# env3.scanner1(filename = 'out1')
# env3.scanner2(filename = 'out2')
# env3.scanner1(filename = 'out3')
-# assert scanned_it['out1']
-# assert scanned_it['out2']
-# assert scanned_it['out3']
-#
-# s = env3.get_scanner(".c")
-# assert s == s1, s
-# s = env3.get_scanner(skey=".m4")
-# assert s == s2, s
-# s = env3.get_scanner(".cxx")
-# assert s == None, s
+# assert scanned_it['out1']
+# assert scanned_it['out2']
+# assert scanned_it['out3']
+
+ suffixes = [".c", ".cc", ".cxx", ".m4", ".m5"]
+
+ env = Environment(SCANNERS = [])
+ s = map(env.get_scanner, suffixes)
+ assert s == [None, None, None, None, None], s
+
+ env.Replace(SCANNERS = [s1])
+ s = map(env.get_scanner, suffixes)
+ assert s == [s1, s1, None, None, None], s
+
+ env.Append(SCANNERS = [s2])
+ s = map(env.get_scanner, suffixes)
+ assert s == [s1, s1, None, s2, None], s
+
+ env.AppendUnique(SCANNERS = [s3])
+ s = map(env.get_scanner, suffixes)
+ assert s == [s1, s1, None, s2, s3], s
+
+ env = env.Copy(SCANNERS = [s2])
+ s = map(env.get_scanner, suffixes)
+ assert s == [None, None, None, s2, None], s
+
+ env['SCANNERS'] = [s1]
+ s = map(env.get_scanner, suffixes)
+ assert s == [s1, s1, None, None, None], s
+
+ env.PrependUnique(SCANNERS = [s2, s1])
+ s = map(env.get_scanner, suffixes)
+ assert s == [s1, s1, None, s2, None], s
+
+ env.Prepend(SCANNERS = [s3])
+ s = map(env.get_scanner, suffixes)
+ assert s == [s1, s1, None, s3, s3], s
def test_ENV(self):
"""Test setting the external ENV in Environments