diff options
author | Steven Knight <knight@baldmt.com> | 2004-10-24 19:16:49 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-10-24 19:16:49 (GMT) |
commit | c3d0b21a6dfd673934ca8184fdf1df45566b321c (patch) | |
tree | 5524f457aa2f9184f037f84a9db6f5eda6e5384c /test/SHELL.py | |
parent | 1b01d02832482b0f881c6fe23122221a9c29ac8f (diff) | |
download | SCons-c3d0b21a6dfd673934ca8184fdf1df45566b321c.zip SCons-c3d0b21a6dfd673934ca8184fdf1df45566b321c.tar.gz SCons-c3d0b21a6dfd673934ca8184fdf1df45566b321c.tar.bz2 |
Add tests for SHELL, SPAWN and ESCAPE.
Diffstat (limited to 'test/SHELL.py')
-rw-r--r-- | test/SHELL.py | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/test/SHELL.py b/test/SHELL.py new file mode 100644 index 0000000..9082dbd --- /dev/null +++ b/test/SHELL.py @@ -0,0 +1,81 @@ +#!/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 SHELL construction variable. +""" + +import os +import sys + + +import TestSCons + +python = TestSCons.python + +test = TestSCons.TestSCons() + +if sys.platform == 'win32': + sys.stderr.write('Cannot set SHELL separately from other variables on win32.\n') + test.no_result(1) + +my_shell = test.workpath('my_shell.py') + +test.write(my_shell, """\ +#!%(python)s +import os +import string +import sys +cmd = sys.argv[2] +def stripquote(s): + if s[0] == '"' and s[-1] == '"' or \ + s[0] == "'" and s[-1] == "'": + s = s[1:-1] + return s +args = string.split(stripquote(sys.argv[2])) +args = map(stripquote, args) +ofp = open(args[2], 'wb') +for f in args[3:] + ['extra.txt']: + ofp.write(open(f, 'rb').read()) +ofp.close() +sys.exit(0) +""" % locals()) + +os.chmod(my_shell, 0755) + +test.write('SConstruct', """\ +env = Environment(SHELL = r'%(my_shell)s') +env.Command('file.out', 'file.in', "%(python)s fake_cat_program $TARGET $SOURCES") +""" % locals()) + +test.write('file.in', "file.in\n") +test.write('extra.txt', "extra.txt\n") + +test.run() + +test.must_match('file.out', "file.in\nextra.txt\n") + +test.pass_test() |