summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Command.py3
-rw-r--r--test/ENV.py3
-rw-r--r--test/Program.py24
-rw-r--r--test/option-c.py5
-rw-r--r--test/subdir.py65
5 files changed, 80 insertions, 20 deletions
diff --git a/test/Command.py b/test/Command.py
index c3080cb..e9d7452 100644
--- a/test/Command.py
+++ b/test/Command.py
@@ -57,8 +57,7 @@ test.write('f2.in', "f2.in\n")
test.write('f3.in', "f3.in\n")
-#XXXtest.run(arguments = '.')
-test.run(arguments = 'f1.out f2.out f3.out')
+test.run(arguments = '.')
test.fail_test(test.read('f1.out') != "f1.in\n")
test.fail_test(test.read('f2.out') != "f2.in\n")
diff --git a/test/ENV.py b/test/ENV.py
index 221e7f9..1ff699d 100644
--- a/test/ENV.py
+++ b/test/ENV.py
@@ -71,8 +71,7 @@ os.chmod(bin2_build_py, 0755)
test.write('input', "input file\n")
-#test.run(arguments = '.')
-test.run(arguments = 'bin1.out bin2.out')
+test.run(arguments = '.')
test.fail_test(test.read('bin1.out') != "bin1/build.py\ninput file\n")
test.fail_test(test.read('bin2.out') != "bin2/build.py\ninput file\n")
diff --git a/test/Program.py b/test/Program.py
index 2612d1c..6a0db70 100644
--- a/test/Program.py
+++ b/test/Program.py
@@ -36,7 +36,7 @@ test.write('SConstruct', """
env = Environment()
env.Program(target = 'foo1', source = 'f1.c')
env.Program(target = 'foo2', source = 'f2a.c f2b.c f2c.c')
-#XXXenv.Program(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c'])
+env.Program(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c'])
""")
test.write('f1.c', """
@@ -109,15 +109,13 @@ main(int argc, char *argv[])
}
""")
-#XXXtest.run(arguments = '.')
-test.run(arguments = 'foo1 foo2')
+test.run(arguments = '.')
test.run(program = test.workpath('foo1'), stdout = "f1.c\n")
test.run(program = test.workpath('foo2'), stdout = "f2a.c\nf2b.c\nf2c.c\n")
-#XXXtest.run(program = test.workpath('foo3'), stdout = "f3a.c\nf3b.c\nf3c.c\n")
+test.run(program = test.workpath('foo3'), stdout = "f3a.c\nf3b.c\nf3c.c\n")
-#XXXtest.up_to_date(arguments = '.')
-test.up_to_date(arguments = 'foo1 foo2')
+test.up_to_date(arguments = '.')
test.write('f1.c', """
int
@@ -137,22 +135,22 @@ f3b(void)
}
""")
-#XXXtest.run(arguments = '.')
-test.run(arguments = 'foo1 foo2')
+test.run(arguments = '.')
test.run(program = test.workpath('foo1'), stdout = "f1.c X\n")
test.run(program = test.workpath('foo2'), stdout = "f2a.c\nf2b.c\nf2c.c\n")
-#XXXtest.run(program = test.workpath('foo3'), stdout = "f3a.c\nf3b.c X\nf3c.c\n")
+test.run(program = test.workpath('foo3'), stdout = "f3a.c\nf3b.c X\nf3c.c\n")
-#XXXtest.up_to_date(arguments = '.')
-test.up_to_date(arguments = 'foo1 foo2')
+test.up_to_date(arguments = '.')
# make sure the programs don't get rebuilt, because nothing changed:
oldtime1 = os.path.getmtime(test.workpath('foo1'))
oldtime2 = os.path.getmtime(test.workpath('foo2'))
-time.sleep(1) # introduce a small delay, to make the test valid
-test.run(arguments = 'foo1 foo2')
+oldtime3 = os.path.getmtime(test.workpath('foo3'))
+time.sleep(2) # introduce a small delay, to make the test valid
+test.run(arguments = '.')
test.fail_test(not (oldtime1 == os.path.getmtime(test.workpath('foo1'))))
test.fail_test(not (oldtime2 == os.path.getmtime(test.workpath('foo2'))))
+test.fail_test(not (oldtime3 == os.path.getmtime(test.workpath('foo3'))))
test.pass_test()
diff --git a/test/option-c.py b/test/option-c.py
index 0e41ffd..b188d53 100644
--- a/test/option-c.py
+++ b/test/option-c.py
@@ -78,14 +78,13 @@ test.fail_test(os.path.exists(test.workpath('foo1.out')))
test.fail_test(os.path.exists(test.workpath('foo2.out')))
test.fail_test(os.path.exists(test.workpath('foo3.out')))
-test.run(arguments = 'foo1.out foo2.out foo3.out')
+test.run(arguments = '.')
test.fail_test(test.read(test.workpath('foo1.out')) != "foo1.in\n")
test.fail_test(test.read(test.workpath('foo2.out')) != "foo2.in\n")
test.fail_test(test.read(test.workpath('foo3.out')) != "foo3.in\n")
-#XXXtest.run(arguments = '-c .',
-test.run(arguments = '-c foo1.out foo2.out foo3.out',
+test.run(arguments = '-c .',
stdout = "Removed foo1.out\nRemoved foo2.out\nRemoved foo3.out\n")
test.fail_test(os.path.exists(test.workpath('foo1.out')))
diff --git a/test/subdir.py b/test/subdir.py
new file mode 100644
index 0000000..7071b54
--- /dev/null
+++ b/test/subdir.py
@@ -0,0 +1,65 @@
+#!/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 TestSCons
+import os.path
+
+test = TestSCons.TestSCons()
+
+test.subdir('subdir')
+
+test.write('build.py', r"""
+import sys
+contents = open(sys.argv[2], 'r').read()
+file = open(sys.argv[1], 'w')
+file.write(contents)
+file.close()
+""")
+
+test.write('SConstruct', """
+B = Builder(name = "B", action = "python build.py $targets $sources")
+env = Environment(BUILDERS = [B])
+env.B(target = 'subdir/f1.out', source = 'subdir/f1.in')
+env.B(target = 'subdir/f2.out', source = 'subdir/f2.in')
+env.B(target = 'subdir/f3.out', source = 'subdir/f3.in')
+env.B(target = 'subdir/f4.out', source = 'subdir/f4.in')
+""")
+
+test.write('subdir/f1.in', "f1.in\n")
+test.write('subdir/f2.in', "f2.in\n")
+test.write('subdir/f3.in', "f3.in\n")
+test.write('subdir/f4.in', "f4.in\n")
+
+test.run(arguments = 'subdir')
+
+test.fail_test(test.read('subdir/f1.out') != "f1.in\n")
+test.fail_test(test.read('subdir/f2.out') != "f2.in\n")
+test.fail_test(test.read('subdir/f3.out') != "f3.in\n")
+test.fail_test(test.read('subdir/f4.out') != "f4.in\n")
+
+test.up_to_date(arguments = 'subdir')
+
+test.pass_test()