|
| 1 | +#!/usr/bin/env python |
| 2 | +# |
| 3 | +# MIT License |
| 4 | +# |
| 5 | +# Copyright The SCons Foundation |
| 6 | +# |
| 7 | +# Permission is hereby granted, free of charge, to any person obtaining |
| 8 | +# a copy of this software and associated documentation files (the |
| 9 | +# "Software"), to deal in the Software without restriction, including |
| 10 | +# without limitation the rights to use, copy, modify, merge, publish, |
| 11 | +# distribute, sublicense, and/or sell copies of the Software, and to |
| 12 | +# permit persons to whom the Software is furnished to do so, subject to |
| 13 | +# the following conditions: |
| 14 | +# |
| 15 | +# The above copyright notice and this permission notice shall be included |
| 16 | +# in all copies or substantial portions of the Software. |
| 17 | +# |
| 18 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY |
| 19 | +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
| 20 | +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 21 | +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 22 | +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 23 | +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 24 | +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 25 | + |
| 26 | +""" |
| 27 | +Test that the --debug=includes option prints the implicit |
| 28 | +dependencies of a target. |
| 29 | +
|
| 30 | +A separate test to make sure it works if there is more than one source. |
| 31 | +The main test uses a C compiler, and object builders there are |
| 32 | +single-source, so we need a different scheme. |
| 33 | +""" |
| 34 | + |
| 35 | +import TestSCons |
| 36 | + |
| 37 | +test = TestSCons.TestSCons() |
| 38 | + |
| 39 | +test.write('SConstruct', """ |
| 40 | +import os |
| 41 | +import os.path |
| 42 | +import sys |
| 43 | +
|
| 44 | +DefaultEnvironment(tools=[]) |
| 45 | +
|
| 46 | +def buildIt(env, target, source): |
| 47 | + with open(target[0], 'w') as ofp: |
| 48 | + for out in source: |
| 49 | + with open(source[0], 'r') as ifp: |
| 50 | + ofp.write(ifp.read()) |
| 51 | + return 0 |
| 52 | +
|
| 53 | +def source_scanner(node, env, path, builder): |
| 54 | + return [File('a.inc'), File('b.inc')] |
| 55 | +
|
| 56 | +env = Environment(tools=[]) |
| 57 | +env.Command( |
| 58 | + target="f.out", |
| 59 | + source=["f1.in", "f2.in"], |
| 60 | + action=buildIt, |
| 61 | + source_scanner=Scanner( |
| 62 | + lambda node, env, path: source_scanner(node, env, path, "w-env") |
| 63 | + ) |
| 64 | +) |
| 65 | +""") |
| 66 | + |
| 67 | +# the contents of these sources/includes don't matter |
| 68 | +test.write('f1.in', "f1.in\n") |
| 69 | +test.write('f2.in', "f2.in\n") |
| 70 | +test.write('a.inc', "a.inc\n") |
| 71 | +test.write('b.inc', "b.inc\n") |
| 72 | + |
| 73 | +expect = """ |
| 74 | ++-f1.in |
| 75 | + +-a.inc |
| 76 | + | +-[a.inc] |
| 77 | + | +-b.inc |
| 78 | + | +-[a.inc] |
| 79 | + | +-[b.inc] |
| 80 | + +-[b.inc] |
| 81 | ++-f2.in |
| 82 | + +-a.inc |
| 83 | + | +-[a.inc] |
| 84 | + | +-b.inc |
| 85 | + | +-[a.inc] |
| 86 | + | +-[b.inc] |
| 87 | + +-[b.inc] |
| 88 | +""" |
| 89 | +test.run(arguments="-Q --debug=includes f.out") |
| 90 | +test.must_contain_all_lines(test.stdout(), [expect]) |
| 91 | + |
| 92 | +test.pass_test() |
0 commit comments