1#!/usr/local/bin/python3.8
2
3# Copyright 2005 Dave Abrahams
4# Distributed under the Boost Software License, Version 1.0.
5# (See accompanying file LICENSE_1_0.txt or copy at
6# http://www.boost.org/LICENSE_1_0.txt)
7
8import BoostBuild
9
10
11def wait_for_bar(t):
12    """
13      Wait to make the test system correctly recognize the 'bar' file as
14    touched after the next build run. Without the wait, the next build run may
15    rebuild the 'bar' file with the new and the old file modification timestamp
16    too close to each other - which could, depending on the currently supported
17    file modification timestamp resolution, be detected as 'no change' by the
18    testing system.
19
20    """
21    t.wait_for_time_change("bar", touch=False)
22
23
24t = BoostBuild.Tester(["-ffile.jam", "-d+3", "-d+12", "-d+13"],
25    pass_toolset=0)
26
27t.write("file.jam", """\
28rule make
29{
30    DEPENDS $(<) : $(>) ;
31    DEPENDS all : $(<) ;
32}
33actions make
34{
35    echo "******" making $(<) from $(>) "******"
36    echo made from $(>) > $(<)
37}
38
39make aux1 : bar ;
40make foo : bar ;
41REBUILDS foo : bar ;
42make bar : baz ;
43make aux2 : bar ;
44""")
45
46t.write("baz", "nothing")
47
48t.run_build_system(["bar"])
49t.expect_addition("bar")
50t.expect_nothing_more()
51
52wait_for_bar(t)
53t.run_build_system(["foo"])
54t.expect_touch("bar")
55t.expect_addition("foo")
56t.expect_nothing_more()
57
58t.run_build_system()
59t.expect_addition(["aux1", "aux2"])
60t.expect_nothing_more()
61
62t.touch("bar")
63wait_for_bar(t)
64t.run_build_system()
65t.expect_touch(["foo", "bar", "aux1", "aux2"])
66t.expect_nothing_more()
67
68t.cleanup()
69