From 337d309e434809058ceb356b40f7415d7c07cc09 Mon Sep 17 00:00:00 2001
From: Steven Knight <knight@baldmt.com>
Date: Tue, 27 Jan 2004 06:35:04 +0000
Subject: Accomodate white space in path names when running tests.

---
 etc/TestCmd.py     |  4 ++--
 runtest.py         |  9 ++++++++-
 src/CHANGES.txt    |  3 +++
 test/SConstruct.py |  2 +-
 test/option-f.py   |  2 +-
 test/scan-once.py  | 12 ++++++++++--
 6 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/etc/TestCmd.py b/etc/TestCmd.py
index 1b78739..61fa2a7 100644
--- a/etc/TestCmd.py
+++ b/etc/TestCmd.py
@@ -173,7 +173,7 @@ version.
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 
 __author__ = "Steven Knight <knight at baldmt dot com>"
-__revision__ = "TestCmd.py 0.04.D009 2003/07/18 17:37:29 knight"
+__revision__ = "TestCmd.py 0.04.D010 2004/01/27 00:11:44 knight"
 __version__ = "0.04"
 
 import os
@@ -636,7 +636,7 @@ class TestCmd:
             if interpreter:
                 cmd = interpreter + " " + cmd
         else:
-            cmd = self.program
+            cmd = escape_cmd(self.program)
             if self.interpreter:
                 cmd =  self.interpreter + " " + cmd
         if arguments:
diff --git a/runtest.py b/runtest.py
index fd421ef..9a0cadd 100644
--- a/runtest.py
+++ b/runtest.py
@@ -354,8 +354,15 @@ class Unbuffered:
 
 sys.stdout = Unbuffered(sys.stdout)
 
+_ws = re.compile('\s')
+
+def escape(s):
+    if _ws.search(s):
+        s = '"' + s + '"'
+    return s
+
 for t in tests:
-    cmd = string.join([python, debug, t.abspath], " ")
+    cmd = string.join(map(escape, [python, debug, t.abspath]), " ")
     if printcmd:
         sys.stdout.write(cmd + "\n")
     s = os.system(cmd)
diff --git a/src/CHANGES.txt b/src/CHANGES.txt
index ffcfe91..26dd7ef 100644
--- a/src/CHANGES.txt
+++ b/src/CHANGES.txt
@@ -141,6 +141,9 @@ RELEASE 0.95 - XXX
     of whether the file was built via scons.bat or scons.py.
     (Thanks to Niall Douglas for contributing code and testing.)
 
+  - Fix TestCmd.py, runtest.py and specific tests to accomodate being
+    run from directories whose paths include white space.
+
   From Vincent Risi:
 
   - Add support for the bcc32, ilink32 and tlib Borland tools.
diff --git a/test/SConstruct.py b/test/SConstruct.py
index cd201d2..a3ad3aa 100644
--- a/test/SConstruct.py
+++ b/test/SConstruct.py
@@ -34,7 +34,7 @@ test.run(arguments = ".",
          stdout = "",
          stderr = r"""
 scons: \*\*\* No SConstruct file found.
-File "\S+", line \d+, in \S+
+File "[^"]+", line \d+, in \S+
 """)
 
 test.match_func = TestCmd.match_exact
diff --git a/test/option-f.py b/test/option-f.py
index 3c8dcee..06afece 100644
--- a/test/option-f.py
+++ b/test/option-f.py
@@ -89,7 +89,7 @@ test.run(arguments = '-f no_such_file .',
          stderr = None)
 test.fail_test(not test.match_re(test.stderr(), """
 scons: warning: Ignoring missing SConscript 'no_such_file'
-File "\S+", line \d+, in .*
+File "[^"]+", line \d+, in .*
 """))
 
 test.pass_test()
diff --git a/test/scan-once.py b/test/scan-once.py
index cf08f5e..cfc4a25 100644
--- a/test/scan-once.py
+++ b/test/scan-once.py
@@ -337,8 +337,16 @@ Mylib.ExportLib(env, lib_fullname)
 #cmd_generated = "cd %s ; sh MAKE-HEADER.sh" % Dir(".")
 #cmd_justlib = "cd %s ; make" % Dir(".")
 
-cmd_generated = "%s $SOURCE" % (sys.executable,)
-cmd_justlib = "%s %s -C ${SOURCES[0].dir}" % (sys.executable, sys.argv[0])
+_ws = re.compile('\s')
+
+def escape(s):
+    if _ws.search(s):
+        s = '"' + s + '"'
+    return s
+
+cmd_generated = "%s $SOURCE" % (escape(sys.executable),)
+cmd_justlib = "%s %s -C ${SOURCES[0].dir}" % ((sys.executable),
+                                              escape(sys.argv[0]))
 
 ##### Deps appear correct ... but wacky scanning?
 # Why?
-- 
cgit v0.12