|
1 | 1 | #!/usr/bin/env python
|
2 | 2 | #
|
3 |
| -# __COPYRIGHT__ |
| 3 | +# MIT License |
| 4 | +# |
| 5 | +# Copyright The SCons Foundation |
4 | 6 | #
|
5 | 7 | # Permission is hereby granted, free of charge, to any person obtaining
|
6 | 8 | # a copy of this software and associated documentation files (the
|
|
20 | 22 | # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21 | 23 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22 | 24 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23 |
| -# |
24 | 25 |
|
25 |
| -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" |
| 26 | +""" |
| 27 | +Test the Pseudo method |
| 28 | +""" |
26 | 29 |
|
27 | 30 | import TestSCons
|
28 | 31 |
|
29 | 32 | test = TestSCons.TestSCons()
|
30 | 33 |
|
31 |
| -# Firstly, build a pseudo target and make sure we get no warnings it |
32 |
| -# doesn't exist under any circumstances |
33 |
| -test.write('SConstruct', """ |
| 34 | +test.write('SConstruct', """\ |
34 | 35 | env = Environment()
|
35 |
| -env.Pseudo(env.Command('foo.out', [], '@echo boo')) |
36 |
| -""") |
37 |
| - |
38 |
| -test.run(arguments='-Q', stdout = 'boo\n') |
| 36 | +foo = env.Command('foo.out', [], '@echo boo') |
| 37 | +bar = env.Command('bar.out', [], Touch('$TARGET')) |
| 38 | +env.Pseudo(foo, bar) |
39 | 39 |
|
40 |
| -test.run(arguments='-Q --warning=target-not-built', stdout = "boo\n") |
41 |
| - |
42 |
| -# Now do the same thing again but create the target and check we get an |
43 |
| -# error if it exists after the build |
44 |
| -test.write('SConstruct', """ |
45 |
| -env = Environment() |
46 |
| -env.Pseudo(env.Command('foo.out', [], Touch('$TARGET'))) |
| 40 | +gfoo = Command('foo.glb', [], '@echo boo') |
| 41 | +gbar = Command('bar.glb', [], Touch('$TARGET')) |
| 42 | +Pseudo(gfoo, gbar) |
47 | 43 | """)
|
48 | 44 |
|
49 |
| -test.run(arguments='-Q', stdout = 'Touch("foo.out")\n', stderr = None, |
50 |
| - status = 2) |
51 |
| -test.must_contain_all_lines(test.stderr(), |
52 |
| - 'scons: *** Pseudo target foo.out must not exist') |
53 |
| -test.run(arguments='-Q --warning=target-not-built', |
54 |
| - stdout = 'Touch("foo.out")\n', |
55 |
| - stderr = None, status = 2) |
56 |
| -test.must_contain_all_lines(test.stderr(), |
57 |
| - 'scons: *** Pseudo target foo.out must not exist') |
| 45 | +# foo.out build does not create file, should generate no errors |
| 46 | +test.run(arguments='-Q foo.out', stdout='boo\n') |
| 47 | +# missing target warning triggers if requested |
| 48 | +test.run(arguments='-Q foo.out --warning=target-not-built', stdout="boo\n") |
| 49 | +# bar.out build creates file, error if it exists after the build |
| 50 | +test.run(arguments='-Q bar.out', stdout='Touch("bar.out")\n', stderr=None, status=2) |
| 51 | +test.must_contain_all_lines( |
| 52 | + test.stderr(), |
| 53 | + 'scons: *** Pseudo target bar.out must not exist', |
| 54 | +) |
| 55 | +# warning must not appear since target created |
| 56 | +test.run( |
| 57 | + arguments='-Q bar.out --warning=target-not-built', |
| 58 | + stdout='Touch("bar.out")\n', |
| 59 | + stderr=None, |
| 60 | + status=2, |
| 61 | +) |
| 62 | +test.must_contain_all_lines( |
| 63 | + test.stderr(), |
| 64 | + 'scons: *** Pseudo target bar.out must not exist', |
| 65 | +) |
| 66 | + |
| 67 | +# repeat the process for the global function form (was missing initially) |
| 68 | +test.run(arguments='-Q foo.glb', stdout='boo\n') |
| 69 | +test.run(arguments='-Q foo.glb --warning=target-not-built', stdout="boo\n") |
| 70 | +test.run(arguments='-Q bar.glb', stdout='Touch("bar.glb")\n', stderr=None, status=2) |
| 71 | +test.must_contain_all_lines( |
| 72 | + test.stderr(), |
| 73 | + 'scons: *** Pseudo target bar.glb must not exist', |
| 74 | +) |
| 75 | +test.run( |
| 76 | + arguments='-Q bar.glb --warning=target-not-built', |
| 77 | + stdout='Touch("bar.glb")\n', |
| 78 | + stderr=None, |
| 79 | + status=2, |
| 80 | +) |
| 81 | +test.must_contain_all_lines( |
| 82 | + test.stderr(), |
| 83 | + 'scons: *** Pseudo target bar.glb must not exist', |
| 84 | +) |
58 | 85 |
|
59 | 86 | test.pass_test()
|
60 | 87 |
|
|
0 commit comments