Skip to content

Commit 4f44a22

Browse files
committed
Disable tool initialization in tests which don't need it
1 parent 3848c5c commit 4f44a22

File tree

4 files changed

+160
-161
lines changed

4 files changed

+160
-161
lines changed

test/AddOption/basic.py

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
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 the help text when the AddOption() function is used (and when
29-
it's not).
30-
"""
31-
32-
import TestSCons
33-
34-
test = TestSCons.TestSCons()
35-
36-
test.write('SConstruct', """\
37-
env = Environment()
38-
AddOption('--force',
39-
action="store_true",
40-
help='force installation (overwrite any existing files)')
41-
AddOption('--prefix',
42-
nargs=1,
43-
dest='prefix',
44-
action='store',
45-
type='string',
46-
metavar='DIR',
47-
help='installation prefix')
48-
f = GetOption('force')
49-
if f:
50-
f = "True"
51-
print(f)
52-
print(GetOption('prefix'))
53-
""")
54-
55-
test.run('-Q -q .',
56-
stdout="None\nNone\n")
57-
58-
test.run('-Q -q . --force',
59-
stdout="True\nNone\n")
60-
61-
test.run('-Q -q . --prefix=/home/foo',
62-
stdout="None\n/home/foo\n")
63-
64-
test.run('-Q -q . -- --prefix=/home/foo --force',
65-
status=1,
66-
stdout="None\nNone\n")
67-
68-
test.pass_test()
69-
70-
# Local Variables:
71-
# tab-width:4
72-
# indent-tabs-mode:nil
73-
# End:
74-
# 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 the help text when the AddOption() function is used (and when
28+
it's not).
29+
"""
30+
31+
import TestSCons
32+
33+
test = TestSCons.TestSCons()
34+
35+
test.write('SConstruct', """\
36+
DefaultEnvironment(tools=[])
37+
env = Environment(tools=[])
38+
AddOption('--force',
39+
action="store_true",
40+
help='force installation (overwrite any existing files)')
41+
AddOption('--prefix',
42+
nargs=1,
43+
dest='prefix',
44+
action='store',
45+
type='string',
46+
metavar='DIR',
47+
help='installation prefix')
48+
f = GetOption('force')
49+
if f:
50+
f = "True"
51+
print(f)
52+
print(GetOption('prefix'))
53+
""")
54+
55+
test.run('-Q -q .',
56+
stdout="None\nNone\n")
57+
58+
test.run('-Q -q . --force',
59+
stdout="True\nNone\n")
60+
61+
test.run('-Q -q . --prefix=/home/foo',
62+
stdout="None\n/home/foo\n")
63+
64+
test.run('-Q -q . -- --prefix=/home/foo --force',
65+
status=1,
66+
stdout="None\nNone\n")
67+
68+
test.pass_test()
69+
70+
# Local Variables:
71+
# tab-width:4
72+
# indent-tabs-mode:nil
73+
# End:
74+
# vim: set expandtab tabstop=4 shiftwidth=4:

test/AddOption/help.py

Lines changed: 81 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,81 @@
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-
Verify the help text when the AddOption() function is used (and when
26-
it's not).
27-
"""
28-
29-
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
30-
31-
import TestSCons
32-
33-
test = TestSCons.TestSCons()
34-
35-
test.write('SConstruct', """\
36-
env = Environment()
37-
AddOption('--force',
38-
action="store_true",
39-
help='force installation (overwrite existing files)')
40-
AddOption('--prefix',
41-
nargs=1,
42-
dest='prefix',
43-
action='store',
44-
type='string',
45-
metavar='DIR',
46-
help='installation prefix')
47-
""")
48-
49-
expected_lines = [
50-
'Local Options:',
51-
' --force force installation (overwrite existing files)',
52-
' --prefix=DIR installation prefix',
53-
]
54-
55-
test.run(arguments = '-h')
56-
lines = test.stdout().split('\n')
57-
missing = [e for e in expected_lines if e not in lines]
58-
59-
if missing:
60-
print("====== STDOUT:")
61-
print(test.stdout())
62-
print("====== Missing the following lines in the above AddOption() help output:")
63-
print("\n".join(missing))
64-
test.fail_test()
65-
66-
test.unlink('SConstruct')
67-
68-
test.run(arguments = '-h')
69-
lines = test.stdout().split('\n')
70-
unexpected = [e for e in expected_lines if e in lines]
71-
72-
if unexpected:
73-
print("====== STDOUT:")
74-
print(test.stdout())
75-
print("====== Unexpected lines in the above non-AddOption() help output:")
76-
print("\n".join(unexpected))
77-
test.fail_test()
78-
79-
test.pass_test()
80-
81-
# Local Variables:
82-
# tab-width:4
83-
# indent-tabs-mode:nil
84-
# End:
85-
# 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+
import TestSCons
27+
28+
test = TestSCons.TestSCons()
29+
30+
test.write('SConstruct', """\
31+
DefaultEnvironment(tools=[])
32+
env = Environment(tools=[])
33+
AddOption('--force',
34+
action="store_true",
35+
help='force installation (overwrite existing files)')
36+
AddOption('--prefix',
37+
nargs=1,
38+
dest='prefix',
39+
action='store',
40+
type='string',
41+
metavar='DIR',
42+
help='installation prefix')
43+
""")
44+
45+
expected_lines = [
46+
'Local Options:',
47+
' --force force installation (overwrite existing files)',
48+
' --prefix=DIR installation prefix',
49+
]
50+
51+
test.run(arguments = '-h')
52+
lines = test.stdout().split('\n')
53+
missing = [e for e in expected_lines if e not in lines]
54+
55+
if missing:
56+
print("====== STDOUT:")
57+
print(test.stdout())
58+
print("====== Missing the following lines in the above AddOption() help output:")
59+
print("\n".join(missing))
60+
test.fail_test()
61+
62+
test.unlink('SConstruct')
63+
64+
test.run(arguments = '-h')
65+
lines = test.stdout().split('\n')
66+
unexpected = [e for e in expected_lines if e in lines]
67+
68+
if unexpected:
69+
print("====== STDOUT:")
70+
print(test.stdout())
71+
print("====== Unexpected lines in the above non-AddOption() help output:")
72+
print("\n".join(unexpected))
73+
test.fail_test()
74+
75+
test.pass_test()
76+
77+
# Local Variables:
78+
# tab-width:4
79+
# indent-tabs-mode:nil
80+
# End:
81+
# vim: set expandtab tabstop=4 shiftwidth=4:

test/AddOption/longopts.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
test = TestSCons.TestSCons()
3636

3737
test.write('SConstruct', """\
38+
DefaultEnvironment(tools=[])
3839
AddOption('--myargument', dest='myargument', type='string', default='gully')
3940
AddOption('--myarg', dest='myarg', type='string', default='balla')
4041
print("myargument: " + str(GetOption('myargument')))

test/AddOption/multi-arg.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
test.write(
3737
'SConstruct',
3838
"""\
39-
env = Environment()
39+
DefaultEnvironment(tools=[])
40+
env = Environment(tools=[])
4041
AddOption('--extras',
4142
nargs=2,
4243
dest='extras',
@@ -71,7 +72,8 @@
7172
test.write(
7273
'SConstruct',
7374
"""\
74-
env = Environment()
75+
DefaultEnvironment(tools=[])
76+
env = Environment(tools=[])
7577
AddOption(
7678
'--prefix',
7779
nargs=1,

0 commit comments

Comments
 (0)