summaryrefslogtreecommitdiff
path: root/tools/build/v2/test/unused.py
blob: 9db2380cd11281a4b5f7a68cae2e4241bfac9f29 (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
#!/usr/bin/python

# Copyright 2003 Vladimir Prus 
# Distributed under the Boost Software License, Version 1.0. 
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) 

# Test that unused sources are at least reported.

import BoostBuild
from string import find

t = BoostBuild.Tester()

t.set_tree("unused")

t.run_build_system()
# The second invocation should do nothing, and produce no warning. The previous
# invocation might have printed executed actions and other things, so it is not
# easy to check if warning was issued or not.
t.run_build_system()
t.fail_test(find(t.stdout(), "warning: Unused source { b.X } in main target ./a") == -1)

t.run_build_system("-sGENERATE_ONLY_UNUSABLE=1")
t.fail_test(find(t.stdout(), "warning: Unused source { b.X } in main target ./a") == -1)

# Now check that even if main target generates nothing, its usage requirements
# are still propagated to dependants.
t.write("a.cpp", """
#ifdef FOO
int main() {}
#endif
""")
t.run_build_system("-sGENERATE_NOTHING=1")

t.cleanup()