summaryrefslogtreecommitdiff
path: root/test/ESCAPE.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-10-24 19:16:49 +0000
committerSteven Knight <knight@baldmt.com>2004-10-24 19:16:49 +0000
commit94bc4b290d761fb360892545995ff43c799787ad (patch)
tree5524f457aa2f9184f037f84a9db6f5eda6e5384c /test/ESCAPE.py
parentbee21adc6cff4199de370c30d24ff69aac9611c6 (diff)
downloadscons-94bc4b290d761fb360892545995ff43c799787ad.tar.gz
Add tests for SHELL, SPAWN and ESCAPE.
Diffstat (limited to 'test/ESCAPE.py')
-rw-r--r--test/ESCAPE.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/test/ESCAPE.py b/test/ESCAPE.py
new file mode 100644
index 00000000..bee55bcc
--- /dev/null
+++ b/test/ESCAPE.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+#
+# __COPYRIGHT__
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+"""
+Test the ESCAPE construction variable.
+"""
+
+import TestSCons
+
+python = TestSCons.python
+
+test = TestSCons.TestSCons()
+
+test.write('cat.py', """\
+import sys
+ofp = open(sys.argv[1], 'wb')
+for s in sys.argv[2:]:
+ ofp.write(open(s, 'rb').read())
+ofp.close()
+""")
+
+test.write('SConstruct', """\
+import string
+# We still need to run this through the original ESCAPE function,
+# because that's set up to work in tandem with the existing SHELL,
+# which we're not replacing.
+orig_escape = Environment()['ESCAPE']
+def my_escape(s):
+ s = string.replace(s, 'file.in', 'file.xxx')
+ return orig_escape(s)
+env = Environment(ESCAPE = my_escape)
+env.Command('file.out', 'file.in', "%(python)s cat.py $TARGET $SOURCES")
+""" % locals())
+
+test.write('file.in', "file.in\n")
+test.write('file.xxx', "file.xxx\n")
+
+test.run()
+
+test.must_match('file.out', "file.xxx\n")
+
+test.pass_test()