1 | #!/usr/bin/python |
---|
2 | |
---|
3 | # Copyright (C) Vladimir Prus 2003. Permission to copy, use, modify, sell and |
---|
4 | # distribute this software is granted provided this copyright notice appears in |
---|
5 | # all copies. This software is provided "as is" without express or implied |
---|
6 | # warranty, and with no claim as to its suitability for any purpose. |
---|
7 | |
---|
8 | # Test for the regression testing framework. |
---|
9 | from BoostBuild import Tester, List |
---|
10 | |
---|
11 | # Create a temporary working directory |
---|
12 | t = Tester() |
---|
13 | |
---|
14 | t.write("c.cpp", "") |
---|
15 | |
---|
16 | t.write("r.cpp", """ |
---|
17 | |
---|
18 | void helper(); |
---|
19 | |
---|
20 | #include <iostream> |
---|
21 | int main(int ac, char* av[]) |
---|
22 | { |
---|
23 | helper(); |
---|
24 | |
---|
25 | for (int i = 1; i < ac; ++i) |
---|
26 | std::cout << av[i] << '\\n'; |
---|
27 | return 0; |
---|
28 | } |
---|
29 | """) |
---|
30 | |
---|
31 | t.write("c-f.cpp", """ |
---|
32 | int |
---|
33 | """) |
---|
34 | |
---|
35 | t.write("r-f.cpp", """ |
---|
36 | int main() |
---|
37 | { |
---|
38 | return 1; |
---|
39 | } |
---|
40 | """) |
---|
41 | |
---|
42 | |
---|
43 | t.write("Jamfile", """ |
---|
44 | import testing ; |
---|
45 | |
---|
46 | compile c.cpp ; |
---|
47 | compile-fail c-f.cpp ; |
---|
48 | run r.cpp libs//helper : foo bar ; |
---|
49 | run-fail r-f.cpp ; |
---|
50 | |
---|
51 | """) |
---|
52 | |
---|
53 | t.write("libs/Jamfile", """ |
---|
54 | lib helper : helper.cpp ; |
---|
55 | """) |
---|
56 | |
---|
57 | t.write("libs/helper.cpp", """ |
---|
58 | void |
---|
59 | #if defined(_WIN32) |
---|
60 | __declspec(dllexport) |
---|
61 | #endif |
---|
62 | helper() {} |
---|
63 | |
---|
64 | """) |
---|
65 | |
---|
66 | t.write("project-root.jam", "") |
---|
67 | |
---|
68 | # First test that when outcomes are expected, all .test files are created. |
---|
69 | t.run_build_system("hardcode-dll-paths=false", stderr=None, status=None) |
---|
70 | t.expect_addition("bin/c.test/$toolset/debug/c.test") |
---|
71 | t.expect_addition("bin/c-f.test/$toolset/debug/c-f.test") |
---|
72 | t.expect_addition("bin/r.test/$toolset/debug/r.test") |
---|
73 | t.expect_addition("bin/r-f.test/$toolset/debug/r-f.test") |
---|
74 | |
---|
75 | # Make sure args are handled. |
---|
76 | t.expect_content("bin/r.test/$toolset/debug/r.output", |
---|
77 | "foo\nbar\n\nEXIT STATUS: 0\n") |
---|
78 | |
---|
79 | # Test that input file is handled as well. |
---|
80 | t.write("r.cpp", """ |
---|
81 | #include <iostream> |
---|
82 | #include <fstream> |
---|
83 | int main(int ac, char* av[]) |
---|
84 | { |
---|
85 | for (int i = 1; i < ac; ++i) { |
---|
86 | std::ifstream ifs(av[i]); |
---|
87 | std::cout << ifs.rdbuf(); |
---|
88 | } |
---|
89 | |
---|
90 | return 0; |
---|
91 | } |
---|
92 | """) |
---|
93 | |
---|
94 | t.write("dir/input.txt", "test input") |
---|
95 | |
---|
96 | t.write("Jamfile", """ |
---|
97 | import testing ; |
---|
98 | |
---|
99 | compile c.cpp ; |
---|
100 | obj c-obj : c.cpp ; |
---|
101 | compile-fail c-f.cpp ; |
---|
102 | run r.cpp : : dir/input.txt ; |
---|
103 | run-fail r-f.cpp ; |
---|
104 | time execution : r ; |
---|
105 | time compilation : c-obj ; |
---|
106 | """) |
---|
107 | |
---|
108 | t.run_build_system('hardcode-dll-paths=false') |
---|
109 | t.expect_content("bin/r.test/$toolset/debug/r.output", |
---|
110 | "test input\nEXIT STATUS: 0\n") |
---|
111 | |
---|
112 | t.expect_addition('bin/$toolset/debug/execution.time') |
---|
113 | t.expect_addition('bin/$toolset/debug/compilation.time') |
---|
114 | |
---|
115 | # Make sure test failures are detected. Reverse expectation and see |
---|
116 | # if .test files are created or not. |
---|
117 | t.write("Jamfile", """ |
---|
118 | import testing ; |
---|
119 | |
---|
120 | compile-fail c.cpp ; |
---|
121 | compile c-f.cpp ; |
---|
122 | run-fail r.cpp : : dir/input.txt ; |
---|
123 | run r-f.cpp ; |
---|
124 | """) |
---|
125 | |
---|
126 | t.touch(List("c.cpp c-f.cpp r.cpp r-f.cpp")) |
---|
127 | |
---|
128 | t.run_build_system("hardcode-dll-paths=false", stderr=None, status=1) |
---|
129 | t.expect_removal("bin/c.test/$toolset/debug/c.test") |
---|
130 | t.expect_removal("bin/c-f.test/$toolset/debug/c-f.test") |
---|
131 | t.expect_removal("bin/r.test/$toolset/debug/r.test") |
---|
132 | t.expect_removal("bin/r-f.test/$toolset/debug/r-f.test") |
---|
133 | |
---|
134 | t.cleanup() |
---|