summaryrefslogtreecommitdiffstats
path: root/src/boost/tools/build/test/core_fail_expected.py
blob: 1d4be557b609abf28cddad364f4a75620122a914 (plain)
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
135
136
137
138
139
#!/usr/bin/python

# Copyright 2017 Steven Watanabe
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)

import BoostBuild

def test_basic():
    t = BoostBuild.Tester(pass_toolset=0)

    t.write("file.jam", """\
    actions fail
    {
        invalid-dd0eeb5899734622
    }

    FAIL_EXPECTED t1 ;
    fail t1 ;

    UPDATE t1 ;
    """)

    t.run_build_system(["-ffile.jam"])
    t.expect_output_lines("...failed*", False)
    t.expect_nothing_more()

    t.cleanup()

def test_error():
    t = BoostBuild.Tester(pass_toolset=0)

    t.write("file.jam", """\
    actions pass
    {
        echo okay >$(<)
    }

    FAIL_EXPECTED t1 ;
    pass t1 ;

    UPDATE t1 ;
    """)

    t.run_build_system(["-ffile.jam"], status=1)
    t.expect_output_lines("...failed pass t1...")
    t.expect_nothing_more()

    t.cleanup()

def test_multiple_actions():
    """FAIL_EXPECTED targets are considered to pass if the first
    updating action fails.  Further actions will be skipped."""
    t = BoostBuild.Tester(pass_toolset=0)

    t.write("file.jam", """\
    actions fail
    {
        invalid-dd0eeb5899734622
    }

    actions pass
    {
         echo okay >$(<)
    }

    FAIL_EXPECTED t1 ;
    fail t1 ;
    pass t1 ;

    UPDATE t1 ;
    """)

    t.run_build_system(["-ffile.jam", "-d1"])
    t.expect_output_lines("...failed*", False)
    t.expect_output_lines("pass t1", False)
    t.expect_nothing_more()

    t.cleanup()

def test_quitquick():
    """Tests that FAIL_EXPECTED targets do not cause early exit
    on failure."""
    t = BoostBuild.Tester(pass_toolset=0)

    t.write("file.jam", """\
    actions fail
    {
        invalid-dd0eeb5899734622
    }

    actions pass
    {
        echo okay >$(<)
    }

    FAIL_EXPECTED t1 ;
    fail t1 ;

    pass t2 ;

    UPDATE t1 t2 ;
    """)

    t.run_build_system(["-ffile.jam", "-q", "-d1"])
    t.expect_output_lines("pass t2")
    t.expect_addition("t2")
    t.expect_nothing_more()

    t.cleanup()

def test_quitquick_error():
    """FAIL_EXPECTED targets should cause early exit if they unexpectedly pass."""
    t = BoostBuild.Tester(pass_toolset=0)

    t.write("file.jam", """\
    actions pass
    {
        echo okay >$(<)
    }

    FAIL_EXPECTED t1 ;
    pass t1 ;
    pass t2 ;

    UPDATE t1 t2 ;
    """)

    t.run_build_system(["-ffile.jam", "-q", "-d1"], status=1)
    t.expect_output_lines("pass t2", False)
    t.expect_nothing_more()

    t.cleanup()

test_basic()
test_error()
test_multiple_actions()
test_quitquick()
test_quitquick_error()