Test portability fix. Fix handling of >.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 17 Aug 2004 07:16:58 +0000 (07:16 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 17 Aug 2004 07:16:58 +0000 (07:16 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1032 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Util.py
src/engine/SCons/UtilTests.py
test/Flatten.py
test/redirection.py

index 25cea2f4043d13ddc854e9acc6d7d868f1416067..ea5d7f65c3ffad03c5a5e93c8c4a14804867dd38 100644 (file)
@@ -803,16 +803,34 @@ def scons_subst_list(strSubst, env, mode=SUBST_RAW, target=None, source=None, di
 
             if not self.in_strip or self.mode != SUBST_SIG:
                 try:
-                    y = self[-1][-1] + x
+                    current_word = self[-1][-1]
                 except IndexError:
                     self.add_new_word(x)
                 else:
-                    literal1 = self.literal(self[-1][-1])
-                    literal2 = self.literal(x)
-                    y = self.conv(y)
-                    if is_String(y):
-                        y = CmdStringHolder(y, literal1 or literal2)
-                    self[-1][-1] = y
+                    # All right, this is a hack and it should probably
+                    # be refactored out of existence in the future.
+                    # The issue is that we want to smoosh words together
+                    # and make one file name that gets escaped if
+                    # we're expanding something like foo$EXTENSION,
+                    # but we don't want to smoosh them together if
+                    # it's something like >$TARGET, because then we'll
+                    # treat the '>' like it's part of the file name.
+                    # So for now, just hard-code looking for the special
+                    # command-line redirection characters...
+                    try:
+                        last_char = str(current_word)[-1]
+                    except IndexError:
+                        last_char = '\0'
+                    if last_char in '<>|':
+                        self.add_new_word(x)
+                    else:
+                        y = current_word + x
+                        literal1 = self.literal(self[-1][-1])
+                        literal2 = self.literal(x)
+                        y = self.conv(y)
+                        if is_String(y):
+                            y = CmdStringHolder(y, literal1 or literal2)
+                        self[-1][-1] = y
 
         def add_new_word(self, x):
             if not self.in_strip or self.mode != SUBST_SIG:
index fb9f14c1a5a28c9d7145e0d94574ded046643621..0cda461478038fc11d82251134d610d8c0cfad0a 100644 (file)
@@ -652,6 +652,12 @@ class UtilTestCase(unittest.TestCase):
 
             # Bug reported by Christoph Wiedemann.
             cvt('$xxx/bin'),        [['/bin']],
+
+            # Test variables smooshed together with different prefixes.
+            'foo$AAA',              [['fooa']],
+            '<$AAA',                [['<', 'a']],
+            '>$AAA',                [['>', 'a']],
+            '|$AAA',                [['|', 'a']],
         ]
 
         kwargs = {'target' : target, 'source' : source}
index 7679bdb0b8795e7272a8c5b3546e6b45a5a35e57..1b98f669f7622801cb87fde69b5fa5f814534f41 100644 (file)
@@ -28,6 +28,8 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 Test that the Flatten() function is available and works.
 """
 
+import string
+
 import TestSCons
 
 test = TestSCons.TestSCons()
@@ -60,13 +62,17 @@ test.write('file1.in', "file1.in\n")
 test.write('file2a.in', "file2a.in\n")
 test.write('file2b.in', "file2b.in\n")
 
+def double_backslash(f):
+    p = test.workpath(f)
+    return string.replace(p, '\\', '\\\\')
+
 expect = """\
 ['begin', '%s', 'middle', '%s', 'end']
 ['%s', 'a', 'b', 'c', '%s']
 [1, 2, 3, 4]
 [1, 2, 3, 4]
-""" % (test.workpath('file1.out'), test.workpath('file2.out'),
-       test.workpath('file1.out'), test.workpath('file2.out'))
+""" % (double_backslash('file1.out'), double_backslash('file2.out'),
+       double_backslash('file1.out'), double_backslash('file2.out'))
 
 test.run(chdir = "work",
          arguments = ".",
index cc356c6011011e34474d1d2a76db77213ebd516e..5aac517678d3cc4aee6c12ed1e7b4cac8a18de0a 100644 (file)
@@ -49,16 +49,21 @@ env.Command(target='foo2', source='bar2',
             action= '%s cat.py < $SOURCES > $TARGET')
 env.Command(target='foo3', source='bar3',
             action='%s cat.py $SOURCES | %s cat.py > $TARGET')
-""" % (python, python, python, python))
+env.Command(target='foo4', source='bar4',
+            action='%s cat.py <$SOURCES |%s cat.py >$TARGET')
+""" % (python, python, python, python, python, python))
 
 test.write('bar1', 'bar1\r\n')
 test.write('bar2', 'bar2\r\n')
 test.write('bar3', 'bar3\r\n')
+test.write('bar4', 'bar4\r\n')
 
 test.run(arguments='.')
+
 test.fail_test(test.read('foo1') != 'bar1\r\n')
 test.fail_test(test.read('foo2') != 'bar2\r\n')
 test.fail_test(test.read('foo3') != 'bar3\r\n')
+test.fail_test(test.read('foo4') != 'bar4\r\n')
 
 test.pass_test()