1#!/usr/local/bin/python3.8
2#
3# Copyright (c) 2008 Steven Watanabe
4#
5# Distributed under the Boost Software License, Version 1.0.
6# (See accompanying file LICENSE_1_0.txt or copy at
7# http://www.boost.org/LICENSE_1_0.txt)
8
9# Test that the common.copy rule set the modification date of the new file to
10# the current time.
11
12import BoostBuild
13
14tester = BoostBuild.Tester(use_test_config=False)
15
16tester.write("test1.cpp", """\
17template<bool, int M, class Next>
18struct time_waster {
19    typedef typename time_waster<true, M-1, time_waster>::type type1;
20    typedef typename time_waster<false, M-1, time_waster>::type type2;
21    typedef void type;
22};
23template<bool B, class Next>
24struct time_waster<B, 0, Next> {
25    typedef void type;
26};
27typedef time_waster<true, 10, void>::type type;
28int f() { return 0; }
29""")
30
31tester.write("test2.cpp", """\
32template<bool, int M, class Next>
33struct time_waster {
34    typedef typename time_waster<true, M-1, time_waster>::type type1;
35    typedef typename time_waster<false, M-1, time_waster>::type type2;
36    typedef void type;
37};
38template<bool B, class Next>
39struct time_waster<B, 0, Next> {
40    typedef void type;
41};
42typedef time_waster<true, 10, void>::type type;
43int g() { return 0; }
44""")
45
46tester.write("jamroot.jam", """\
47obj test2 : test2.cpp ;
48obj test1 : test1.cpp : <dependency>test2 ;
49install test2i : test2 : <dependency>test1 ;
50""")
51
52tester.run_build_system()
53tester.expect_addition("bin/$toolset/debug*/test2.obj")
54tester.expect_addition("bin/$toolset/debug*/test1.obj")
55tester.expect_addition("test2i/test2.obj")
56tester.expect_nothing_more()
57
58test2src = tester.read("test2i/test2.obj", binary=True)
59test2dest = tester.read("bin/$toolset/debug*/test2.obj", binary=True)
60if test2src != test2dest:
61    BoostBuild.annotation("failure", "The object file was not copied "
62        "correctly")
63    tester.fail_test(1)
64
65tester.run_build_system(["-d1"])
66tester.expect_output_lines("common.copy*", False)
67tester.expect_nothing_more()
68
69tester.cleanup()
70