Skip to content

Commit 91831f9

Browse files
committed
cleaning up tool initialization to speed up tests
1 parent ccaffe9 commit 91831f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2609
-2628
lines changed

test/Builder/TargetSubst.py

Lines changed: 52 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,52 @@
1-
#!/usr/bin/env python
2-
#
3-
# __COPYRIGHT__
4-
#
5-
# Permission is hereby granted, free of charge, to any person obtaining
6-
# a copy of this software and associated documentation files (the
7-
# "Software"), to deal in the Software without restriction, including
8-
# without limitation the rights to use, copy, modify, merge, publish,
9-
# distribute, sublicense, and/or sell copies of the Software, and to
10-
# permit persons to whom the Software is furnished to do so, subject to
11-
# the following conditions:
12-
#
13-
# The above copyright notice and this permission notice shall be included
14-
# in all copies or substantial portions of the Software.
15-
#
16-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17-
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18-
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23-
#
24-
25-
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26-
27-
"""
28-
Verify that the ensure_suffix argument to causes us to add the suffix
29-
configured for the Builder even if it looks like the target already has
30-
a different suffix.
31-
"""
32-
33-
import TestSCons
34-
35-
test = TestSCons.TestSCons()
36-
37-
test.write('SConstruct', """\
38-
DefaultEnvironment(tools=[])
39-
env = Environment(tools=[])
40-
builder = Builder(action=Copy('$TARGET', '$SOURCE'))
41-
tgt = builder(env, target="${SOURCE}.out", source="infile")
42-
""")
43-
44-
test.write('infile', "infile\n")
45-
test.run(arguments = '.')
46-
test.must_match('infile.out', "infile\n")
47-
test.pass_test()
48-
49-
# Local Variables:
50-
# tab-width:4
51-
# indent-tabs-mode:nil
52-
# End:
53-
# vim: set expandtab tabstop=4 shiftwidth=4:
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+
Verify that the ensure_suffix argument to causes us to add the suffix
28+
configured for the Builder even if it looks like the target already has
29+
a different suffix.
30+
"""
31+
32+
import TestSCons
33+
34+
test = TestSCons.TestSCons()
35+
36+
test.write('SConstruct', """\
37+
DefaultEnvironment(tools=[])
38+
env = Environment(tools=[])
39+
builder = Builder(action=Copy('$TARGET', '$SOURCE'))
40+
tgt = builder(env, target="${SOURCE}.out", source="infile")
41+
""")
42+
43+
test.write('infile', "infile\n")
44+
test.run(arguments = '.')
45+
test.must_match('infile.out', "infile\n")
46+
test.pass_test()
47+
48+
# Local Variables:
49+
# tab-width:4
50+
# indent-tabs-mode:nil
51+
# End:
52+
# vim: set expandtab tabstop=4 shiftwidth=4:

test/Builder/add_src_builder.py

Lines changed: 71 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,71 @@
1-
#!/usr/bin/env python
2-
#
3-
# __COPYRIGHT__
4-
#
5-
# Permission is hereby granted, free of charge, to any person obtaining
6-
# a copy of this software and associated documentation files (the
7-
# "Software"), to deal in the Software without restriction, including
8-
# without limitation the rights to use, copy, modify, merge, publish,
9-
# distribute, sublicense, and/or sell copies of the Software, and to
10-
# permit persons to whom the Software is furnished to do so, subject to
11-
# the following conditions:
12-
#
13-
# The above copyright notice and this permission notice shall be included
14-
# in all copies or substantial portions of the Software.
15-
#
16-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17-
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18-
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23-
#
24-
25-
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26-
27-
"""
28-
Verify that we can call add_src_builder() to add a builder to
29-
another on the fly.
30-
31-
This used to trigger infinite recursion (issue 1681) because the
32-
same src_builder list object was being re-used between all Builder
33-
objects that weren't initialized with a separate src_builder.
34-
"""
35-
36-
import TestSCons
37-
38-
test = TestSCons.TestSCons()
39-
40-
test.write('SConstruct', """\
41-
DefaultEnvironment(tools=[])
42-
copy_out = Builder(action = Copy('$TARGET', '$SOURCE'),
43-
suffix = '.out',
44-
src_suffix = '.mid')
45-
46-
copy_mid = Builder(action = Copy('$TARGET', '$SOURCE'),
47-
suffix = '.mid', \
48-
src_suffix = '.in')
49-
50-
env = Environment(tools=[])
51-
env['BUILDERS']['CopyOut'] = copy_out
52-
env['BUILDERS']['CopyMid'] = copy_mid
53-
54-
copy_out.add_src_builder(copy_mid)
55-
56-
env.CopyOut('file1.out', 'file1.in')
57-
""")
58-
59-
test.write('file1.in', "file1.in\n")
60-
61-
test.run()
62-
63-
test.must_match('file1.mid', "file1.in\n")
64-
test.must_match('file1.out', "file1.in\n")
65-
66-
test.pass_test()
67-
68-
# Local Variables:
69-
# tab-width:4
70-
# indent-tabs-mode:nil
71-
# End:
72-
# vim: set expandtab tabstop=4 shiftwidth=4:
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+
Verify that we can call add_src_builder() to add a builder to
28+
another on the fly.
29+
30+
This used to trigger infinite recursion (issue 1681) because the
31+
same src_builder list object was being re-used between all Builder
32+
objects that weren't initialized with a separate src_builder.
33+
"""
34+
35+
import TestSCons
36+
37+
test = TestSCons.TestSCons()
38+
39+
test.write('SConstruct', """\
40+
DefaultEnvironment(tools=[])
41+
copy_out = Builder(action = Copy('$TARGET', '$SOURCE'),
42+
suffix = '.out',
43+
src_suffix = '.mid')
44+
45+
copy_mid = Builder(action = Copy('$TARGET', '$SOURCE'),
46+
suffix = '.mid', \
47+
src_suffix = '.in')
48+
49+
env = Environment(tools=[])
50+
env['BUILDERS']['CopyOut'] = copy_out
51+
env['BUILDERS']['CopyMid'] = copy_mid
52+
53+
copy_out.add_src_builder(copy_mid)
54+
55+
env.CopyOut('file1.out', 'file1.in')
56+
""")
57+
58+
test.write('file1.in', "file1.in\n")
59+
60+
test.run()
61+
62+
test.must_match('file1.mid', "file1.in\n")
63+
test.must_match('file1.out', "file1.in\n")
64+
65+
test.pass_test()
66+
67+
# Local Variables:
68+
# tab-width:4
69+
# indent-tabs-mode:nil
70+
# End:
71+
# vim: set expandtab tabstop=4 shiftwidth=4:

test/Builder/different-actions.py

Lines changed: 58 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,58 @@
1-
#!/usr/bin/env python
2-
#
3-
# __COPYRIGHT__
4-
#
5-
# Permission is hereby granted, free of charge, to any person obtaining
6-
# a copy of this software and associated documentation files (the
7-
# "Software"), to deal in the Software without restriction, including
8-
# without limitation the rights to use, copy, modify, merge, publish,
9-
# distribute, sublicense, and/or sell copies of the Software, and to
10-
# permit persons to whom the Software is furnished to do so, subject to
11-
# the following conditions:
12-
#
13-
# The above copyright notice and this permission notice shall be included
14-
# in all copies or substantial portions of the Software.
15-
#
16-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17-
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18-
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23-
#
24-
25-
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26-
27-
"""
28-
Verify that two builders in two environments with different
29-
actions generate an error.
30-
"""
31-
32-
import TestSCons
33-
34-
test = TestSCons.TestSCons(match=TestSCons.match_re)
35-
36-
test.write('SConstruct', """\
37-
DefaultEnvironment(tools=[])
38-
e1 = Environment(tools=[])
39-
e2 = Environment(tools=[])
40-
41-
e1.Command('out.txt', [], 'echo 1 > $TARGET')
42-
e2.Command('out.txt', [], 'echo 2 > $TARGET')
43-
""",'w')
44-
45-
expect = TestSCons.re_escape("""
46-
scons: *** Two environments with different actions were specified for the same target: out.txt
47-
(action 1: echo 1 > out.txt)
48-
(action 2: echo 2 > out.txt)
49-
""") + TestSCons.file_expr
50-
51-
test.run(arguments='out.txt', status=2, stderr=expect)
52-
53-
test.pass_test()
54-
55-
# Local Variables:
56-
# tab-width:4
57-
# indent-tabs-mode:nil
58-
# End:
59-
# vim: set expandtab tabstop=4 shiftwidth=4:
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+
Verify that two builders in two environments with different
28+
actions generate an error.
29+
"""
30+
31+
import TestSCons
32+
33+
test = TestSCons.TestSCons(match=TestSCons.match_re)
34+
35+
test.write('SConstruct', """\
36+
DefaultEnvironment(tools=[])
37+
e1 = Environment(tools=[])
38+
e2 = Environment(tools=[])
39+
40+
e1.Command('out.txt', [], 'echo 1 > $TARGET')
41+
e2.Command('out.txt', [], 'echo 2 > $TARGET')
42+
""",'w')
43+
44+
expect = TestSCons.re_escape("""
45+
scons: *** Two environments with different actions were specified for the same target: out.txt
46+
(action 1: echo 1 > out.txt)
47+
(action 2: echo 2 > out.txt)
48+
""") + TestSCons.file_expr
49+
50+
test.run(arguments='out.txt', status=2, stderr=expect)
51+
52+
test.pass_test()
53+
54+
# Local Variables:
55+
# tab-width:4
56+
# indent-tabs-mode:nil
57+
# End:
58+
# vim: set expandtab tabstop=4 shiftwidth=4:

0 commit comments

Comments
 (0)