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