5c6c4f163319bd64cef2ab6d9e0c3e70442b6eab
[scons.git] / test / Depends.py
1 #!/usr/bin/env python
2
3 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
4
5 import TestSCons
6
7 test = TestSCons.TestSCons()
8
9 test.pass_test()        #XXX Short-circuit until this is implemented.
10
11 test.subdir('subdir')
12
13 test.write('build.py', r"""
14 import sys
15 contents = open(sys.argv[2], 'r').read() + open(sys.argv[3], 'r').read()
16 file = open(sys.argv[1], 'w')
17 file.write(contents)
18 file.close()
19 """)
20
21 test.write('SConstruct', """
22 Foo = Builder(name = "Foo",
23           action = "python build.py %(target)s %(source)s subdir/foo.dep")
24 Bar = Builder(name = "Bar",
25           action = "python build.py %(target)s %(source)s subdir/bar.dep")
26 env = Environment(BUILDERS = [Foo, Bar])
27 env.Depends(target = ['f1.out', 'f2.out'], source = 'subdir/foo.dep')
28 env.Depends(target = 'f3.out', source = 'subdir/bar.dep')
29 env.Foo(target = 'f1.out', source = 'f1.in')
30 env.Foo(target = 'f2.out', source = 'f2.in')
31 env.Bar(target = 'f3.out', source = 'f3.in')
32 SConscript('subdir/SConscript')
33 """)
34
35 test.write(['subdir', 'SConscript'], """
36 env.Depends(target = 'f4.out', source = 'bar.dep')
37 env.Foo(target = 'f4.out', source = 'f4.in')
38 """)
39
40 test.write('f1.in', "f1.in\n")
41
42 test.write('f2.in', "f2.in\n")
43
44 test.write(['subdir', 'f4.in'], "subdir/f4.in\n")
45
46 test.write(['subdir', 'foo.dep'], "subdir/foo.dep 1\n")
47
48 test.write(['subdir', 'bar.dep'], "subdir/bar.dep 1\n")
49
50 test.run(arguments = '.')
51
52 test.fail_test(test.read('f1.out') != "f1.in\nsubdir/foo.dep 1\n")
53 test.fail_test(test.read('f2.out') != "f2.in\nsubdir/foo.dep 1\n")
54 test.fail_test(test.read('f3.out') != "f3.in\nsubdir/bar.dep 1\n")
55 test.fail_test(test.read('subdir', 'f4.out') !=
56                                         "subdir/f4.in\nsubdir/bar.dep 1\n")
57
58 test.write(['subdir', 'foo.dep'], "subdir/foo.dep 2\n")
59
60 test.write(['subdir', 'bar.dep'], "subdir/bar.dep 2\n")
61
62 test.run(arguments = '.')
63
64 test.fail_test(test.read('f1.out') != "f1.in\nsubdir/foo.dep 2\n")
65 test.fail_test(test.read('f2.out') != "f2.in\nsubdir/foo.dep 2\n")
66 test.fail_test(test.read('f3.out') != "f3.in\nsubdir/bar.dep 2\n")
67 test.fail_test(test.read('subdir', 'f4.out') !=
68                                         "subdir/f4.in\nsubdir/bar.dep 2\n")
69
70 test.write(['subdir', 'bar.dep'], "subdir/bar.dep 3\n")
71
72 test.run(arguments = '.')
73
74 test.fail_test(test.read('f1.out') != "f1.in\nsubdir/foo.dep 2\n")
75 test.fail_test(test.read('f2.out') != "f2.in\nsubdir/foo.dep 2\n")
76 test.fail_test(test.read('f3.out') != "f3.in\nsubdir/bar.dep 2\n")
77 test.fail_test(test.read('subdir', 'f4.out') !=
78                                         "subdir/f4.in\nsubdir/bar.dep 3\n")
79
80 test.pass_test()