summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2002-01-11 07:03:58 (GMT)
committerSteven Knight <knight@baldmt.com>2002-01-11 07:03:58 (GMT)
commit1337a21f86a49c41940e9b95b7ebf5139cfa03d3 (patch)
treea35eb93886633346141fd0032f4c9c784f73ead4 /test
parent73d5fcf51f9002bb3a0da8a32576b2e8ce0cb54a (diff)
downloadSCons-1337a21f86a49c41940e9b95b7ebf5139cfa03d3.zip
SCons-1337a21f86a49c41940e9b95b7ebf5139cfa03d3.tar.gz
SCons-1337a21f86a49c41940e9b95b7ebf5139cfa03d3.tar.bz2
Add command-line redirection (Charles Crain).
Diffstat (limited to 'test')
-rw-r--r--test/build-errors.py61
-rw-r--r--test/redirection.py62
2 files changed, 112 insertions, 11 deletions
diff --git a/test/build-errors.py b/test/build-errors.py
index 9f09ea0..8545642 100644
--- a/test/build-errors.py
+++ b/test/build-errors.py
@@ -48,28 +48,56 @@ env.bld(target = 'f1', source = 'f1.in')
test.run(arguments='-f SConstruct1 .',
stdout = "%s f1.in f1\n" % no_such_file,
- stderr = """scons: %s: No such file or directory
+ stderr = None)
+
+bad_command = "Bad command or file name\n"
+
+unrecognized = """'%s' is not recognized as an internal or external command,
+operable program or batch file.
+scons: *** [%s] Error 1
+"""
+
+unspecified = """The name specified is not recognized as an
+internal or external command, operable program or batch file.
+scons: *** [%s] Error 1
+"""
+
+test.description_set("Incorrect STDERR:\n%s\n" % test.stderr())
+if os.name == 'nt':
+ errs = [
+ bad_command,
+ unrecognized % (no_such_file, 'f1'),
+ unspecified % 'f1'
+ ]
+ test.fail_test(not test.stderr() in errs)
+else:
+ test.fail_test(test.stderr() != """sh: %s: No such file or directory
scons: *** [f1] Error 127
""" % no_such_file)
+
test.write('SConstruct2', r"""
bld = Builder(name = 'bld', action = '%s $SOURCES $TARGET')
env = Environment(BUILDERS = [bld])
env.bld(target = 'f2', source = 'f2.in')
""" % string.replace(not_executable, '\\', '\\\\'))
+test.run(arguments='-f SConstruct2 .',
+ stdout = "%s f2.in f2\n" % not_executable,
+ stderr = None)
+
+test.description_set("Incorrect STDERR:\n%s\n" % test.stderr())
if os.name == 'nt':
- expect = """scons: %s: No such file or directory
-scons: *** [f2] Error 127
-""" % not_executable
+ errs = [
+ bad_command,
+ unrecognized % (no_such_file, 'f2'),
+ unspecified % 'f2'
+ ]
+ test.fail_test(not test.stderr() in errs)
else:
- expect = """scons: %s: Permission denied
+ test.fail_test(test.stderr() != """sh: %s: Permission denied
scons: *** [f2] Error 126
-""" % not_executable
-
-test.run(arguments='-f SConstruct2 .',
- stdout = "%s f2.in f2\n" % not_executable,
- stderr = expect)
+""" % not_executable)
test.write('SConstruct3', r"""
bld = Builder(name = 'bld', action = '%s $SOURCES $TARGET')
@@ -79,7 +107,18 @@ env.bld(target = 'f3', source = 'f3.in')
test.run(arguments='-f SConstruct3 .',
stdout = "%s f3.in f3\n" % test.workdir,
- stderr = """scons: %s: Permission denied
+ stderr = None)
+
+test.description_set("Incorrect STDERR:\n%s\n" % test.stderr())
+if os.name == 'nt':
+ errs = [
+ bad_command,
+ unrecognized % (no_such_file, 'f3'),
+ unspecified % 'f3'
+ ]
+ test.fail_test(not test.stderr() in errs)
+else:
+ test.fail_test(test.stderr() != """sh: %s: is a directory
scons: *** [f3] Error 126
""" % test.workdir)
diff --git a/test/redirection.py b/test/redirection.py
new file mode 100644
index 0000000..1cd3f60
--- /dev/null
+++ b/test/redirection.py
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2001 Steven Knight
+#
+# 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__"
+
+import os
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+test.write('cat.py', r"""
+import sys
+try:
+ input = open(sys.argv[1], 'r').read()
+except IndexError:
+ input = sys.stdin.read()
+sys.stdout.write(input)
+sys.exit(0)
+""")
+
+test.write('SConstruct', r"""
+env = Environment()
+env.Command(target='foo1', source='bar1',
+ action='python cat.py $SOURCES > $TARGET')
+env.Command(target='foo2', source='bar2',
+ action='python cat.py < $SOURCES > $TARGET')
+env.Command(target='foo3', source='bar3',
+ action='python cat.py $SOURCES | python cat.py > $TARGET')
+""")
+
+test.write('bar1', 'bar1\r\n')
+test.write('bar2', 'bar2\r\n')
+test.write('bar3', 'bar3\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.pass_test()
+