summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/t0001.py68
-rw-r--r--test/t0002.py72
2 files changed, 140 insertions, 0 deletions
diff --git a/test/t0001.py b/test/t0001.py
new file mode 100644
index 0000000..824e046
--- /dev/null
+++ b/test/t0001.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+
+__revision__ = "test/t0001.py __REVISION__ __DATE__ __DEVELOPER__"
+
+from TestCmd import TestCmd
+import string
+import sys
+
+
+try:
+ import threading
+except ImportError:
+ # if threads are not supported, then
+ # there is nothing to test
+ test.pass_test()
+ sys.exit()
+
+
+test = TestCmd(program = 'scons.py',
+ workdir = '',
+ interpreter = 'python')
+
+test.write('build.py', r"""
+import time
+import sys
+file = open(sys.argv[1], 'w')
+file.write(str(time.time()) + '\n')
+time.sleep(1)
+file.write(str(time.time()))
+file.close()
+""")
+
+test.write('SConstruct', """
+MyBuild = Builder(name = "MyBuild",
+ action = "python build.py %(target)s")
+env = Environment(BUILDERS = [MyBuild])
+env.MyBuild(target = 'f1', source = 'f1.in')
+env.MyBuild(target = 'f2', source = 'f2.in')
+""")
+
+def RunTest(args):
+ test.write('f1.in', 'f1.in')
+ test.write('f2.in', 'f2.in')
+
+ test.run(chdir = '.', arguments = args)
+
+ str = test.read("f1")
+ start1,finish1 = map(float, string.split(str, "\n"))
+
+ str = test.read("f2")
+ start2,finish2 = map(float, string.split(str, "\n"))
+
+ return start2, finish1
+
+start2, finish1 = RunTest('-j 2 f1 f2')
+
+# fail if the second file was not started
+# before the first one was finished
+test.fail_test(not (start2 < finish1))
+
+start2, finish1 = RunTest('f1 f2')
+
+# fail if the second file was started
+# before the first one was finished
+test.fail_test(start2 < finish1)
+
+test.pass_test()
+
diff --git a/test/t0002.py b/test/t0002.py
new file mode 100644
index 0000000..0cdfa81
--- /dev/null
+++ b/test/t0002.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+
+__revision__ = "test/t0002.py __REVISION__ __DATE__ __DEVELOPER__"
+
+from TestCmd import TestCmd
+
+test = TestCmd(program = 'scons.py',
+ workdir = '',
+ interpreter = 'python')
+
+test.write('SConstruct', """
+env = Environment()
+env.Program(target = 'f1', source = 'f1.c')
+env.Program(target = 'f2', source = 'f2.c')
+env.Program(target = 'f3', source = 'f3.c')
+env.Program(target = 'f4', source = 'f4.c')
+""")
+
+test.write('f1.c', """
+int
+main(int argc, char *argv[])
+{
+ printf(\"f1.c\n\");
+ exit (0);
+}
+""")
+
+test.write('f2.c', """
+int
+main(int argc, char *argv[])
+{
+ printf(\"f2.c\n\");
+ exit (0);
+}
+""")
+
+
+test.write('f3.c', """
+int
+main(int argc, char *argv[])
+{
+ printf(\"f3.c\n\");
+ exit (0);
+}
+""")
+
+test.write('f4.c', """
+int
+main(int argc, char *argv[])
+{
+ printf(\"f4.c\n\");
+ exit (0);
+}
+""")
+
+
+test.run(chdir = '.', arguments = '-j 3 f1 f2 f3 f4')
+
+test.run(program = test.workpath('f1'))
+test.fail_test(test.stdout() != "f1.c\n")
+
+test.run(program = test.workpath('f2'))
+test.fail_test(test.stdout() != "f2.c\n")
+
+test.run(program = test.workpath('f3'))
+test.fail_test(test.stdout() != "f3.c\n")
+
+test.run(program = test.workpath('f4'))
+test.fail_test(test.stdout() != "f4.c\n")
+
+
+test.pass_test()