Add additional tests to provide more examples.
[scons.git] / test / Library.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.write('SConstruct', """
12 env = Environment(LIBS = 'foo1 foo2 foo3')
13 env.Library(target = 'foo1', source = 'f1.c')
14 env.Library(target = 'foo2', source = 'f2a.c f2b.c f2c.c')
15 env.Library(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c'])
16 env.Program(target = 'prog', source = 'prog.c')
17 """)
18
19 test.write('f1.c', """
20 void
21 f1(void)
22 {
23         printf("f1.c\n");
24 }
25 """)
26
27 test.write('f2a.c', """
28 void
29 f2a(void)
30 {
31         printf("f2a.c\n");
32 }
33 """)
34
35 test.write('f2b.c', """
36 void
37 f2b(void)
38 {
39         printf("f2b.c\n");
40 }
41 """)
42
43 test.write('f2c.c', """
44 void
45 f2c(void)
46 {
47         printf("f2c.c\n");
48 }
49 """)
50
51 test.write('f3a.c', """
52 void
53 f3a(void)
54 {
55         printf("f3a.c\n");
56 }
57 """)
58
59 test.write('f3b.c', """
60 void
61 f3b(void)
62 {
63         printf("f3b.c\n");
64 }
65 """)
66
67 test.write('f3c.c', """
68 f3c(void)
69 {
70         printf("f3c.c\n");
71 }
72 """)
73
74 test.write('prog.c', """
75 void f1(void);
76 void f2a(void);
77 void f2b(void);
78 void f2c(void);
79 void f3a(void);
80 void f3b(void);
81 void f3c(void);
82 int
83 main(int argc, char *argv[])
84 {
85         argv[argc++] = "--";
86         f1();
87         f2a();
88         f2b();
89         f2c();
90         f3a();
91         f3b();
92         f3c();
93         printf("prog.c\n");
94 }
95 """)
96
97 test.run(arguments = 'libfoo1.a libfoo2.a libfoo3.a')
98
99 test.run(program = test.workpath('prog'),
100         stdout = "f1.c\nf2a.c\nf2b.c\nf2c.c\nf3a.c\nf3b.c\nf3c.c\nprog.c\n")
101
102 test.pass_test()