Skip to content

Commit f8bb7b9

Browse files
committed
minimize tool initialization in tests
1 parent 7d33a93 commit f8bb7b9

20 files changed

+1297
-1289
lines changed

test/Configure/Builder-call.py

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
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 calling normal Builders from an actual Configure
29-
context environment works correctly.
30-
"""
31-
32-
import TestSCons
33-
34-
_python_ = TestSCons._python_
35-
36-
test = TestSCons.TestSCons()
37-
38-
test.write('mycommand.py', r"""
39-
import sys
40-
sys.stderr.write( 'Hello World on stderr\n' )
41-
sys.stdout.write( 'Hello World on stdout\n' )
42-
with open(sys.argv[1], 'w') as f:
43-
f.write( 'Hello World\n' )
44-
""")
45-
46-
test.write('SConstruct', """\
47-
env = Environment()
48-
def CustomTest(*args):
49-
return 0
50-
conf = env.Configure(custom_tests = {'MyTest' : CustomTest})
51-
if not conf.MyTest():
52-
env.Command("hello", [], r'%(_python_)s mycommand.py $TARGET')
53-
env = conf.Finish()
54-
""" % locals())
55-
56-
test.run(stderr="Hello World on stderr\n")
57-
58-
test.pass_test()
59-
60-
# Local Variables:
61-
# tab-width:4
62-
# indent-tabs-mode:nil
63-
# End:
64-
# 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 calling normal Builders from an actual Configure
28+
context environment works correctly.
29+
"""
30+
31+
import TestSCons
32+
33+
_python_ = TestSCons._python_
34+
35+
test = TestSCons.TestSCons()
36+
37+
test.write('mycommand.py', r"""
38+
import sys
39+
sys.stderr.write( 'Hello World on stderr\n' )
40+
sys.stdout.write( 'Hello World on stdout\n' )
41+
with open(sys.argv[1], 'w') as f:
42+
f.write( 'Hello World\n' )
43+
""")
44+
45+
test.write('SConstruct', """\
46+
DefaultEnvironment(tools=[])
47+
env = Environment(tools=[])
48+
def CustomTest(*args):
49+
return 0
50+
conf = env.Configure(custom_tests = {'MyTest' : CustomTest})
51+
if not conf.MyTest():
52+
env.Command("hello", [], r'%(_python_)s mycommand.py $TARGET')
53+
env = conf.Finish()
54+
""" % locals())
55+
56+
test.run(stderr="Hello World on stderr\n")
57+
58+
test.pass_test()
59+
60+
# Local Variables:
61+
# tab-width:4
62+
# indent-tabs-mode:nil
63+
# End:
64+
# vim: set expandtab tabstop=4 shiftwidth=4:

test/Configure/CONFIGUREDIR.py

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
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-
Test that the configure context directory can be specified by
29-
setting the $CONFIGUREDIR construction variable.
30-
"""
31-
32-
import TestSCons
33-
34-
test = TestSCons.TestSCons()
35-
36-
test.write("SConstruct", """\
37-
def CustomTest(context):
38-
context.Message('Executing Custom Test ... ')
39-
context.Result(1)
40-
41-
env = Environment(CONFIGUREDIR = 'custom_config_dir')
42-
conf = Configure(env, custom_tests = {'CustomTest' : CustomTest})
43-
conf.CustomTest();
44-
env = conf.Finish()
45-
""")
46-
47-
test.run()
48-
49-
test.must_exist('custom_config_dir')
50-
51-
test.pass_test()
52-
53-
# Local Variables:
54-
# tab-width:4
55-
# indent-tabs-mode:nil
56-
# End:
57-
# 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+
Test that the configure context directory can be specified by
28+
setting the $CONFIGUREDIR construction variable.
29+
"""
30+
31+
import TestSCons
32+
33+
test = TestSCons.TestSCons()
34+
35+
test.write("SConstruct", """\
36+
DefaultEnvironment(tools=[])
37+
def CustomTest(context):
38+
context.Message('Executing Custom Test ... ')
39+
context.Result(1)
40+
41+
env = Environment(tools=[], CONFIGUREDIR = 'custom_config_dir')
42+
conf = Configure(env, custom_tests = {'CustomTest' : CustomTest})
43+
conf.CustomTest();
44+
env = conf.Finish()
45+
""")
46+
47+
test.run()
48+
49+
test.must_exist('custom_config_dir')
50+
51+
test.pass_test()
52+
53+
# Local Variables:
54+
# tab-width:4
55+
# indent-tabs-mode:nil
56+
# End:
57+
# vim: set expandtab tabstop=4 shiftwidth=4:

test/Configure/CONFIGURELOG.py

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
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-
Test that the configure context log file name can be specified by
29-
setting the $CONFIGURELOG construction variable.
30-
"""
31-
32-
import TestSCons
33-
34-
test = TestSCons.TestSCons()
35-
36-
SConstruct_path = test.workpath('SConstruct')
37-
38-
test.write(SConstruct_path, """\
39-
def CustomTest(context):
40-
context.Message('Executing Custom Test ...')
41-
context.Result(1)
42-
43-
env = Environment(CONFIGURELOG = 'custom.logfile')
44-
conf = Configure(env, custom_tests = {'CustomTest' : CustomTest})
45-
conf.CustomTest();
46-
env = conf.Finish()
47-
""")
48-
49-
test.run()
50-
51-
expect = """\
52-
file %(SConstruct_path)s,line 6:
53-
\tConfigure(confdir = .sconf_temp)
54-
scons: Configure: Executing Custom Test ...
55-
scons: Configure: (cached) yes
56-
57-
58-
""" % locals()
59-
60-
test.must_match('custom.logfile', expect, mode='r')
61-
62-
test.pass_test()
63-
64-
# Local Variables:
65-
# tab-width:4
66-
# indent-tabs-mode:nil
67-
# End:
68-
# 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+
Test that the configure context log file name can be specified by
28+
setting the $CONFIGURELOG construction variable.
29+
"""
30+
31+
import TestSCons
32+
33+
test = TestSCons.TestSCons()
34+
35+
SConstruct_path = test.workpath('SConstruct')
36+
37+
test.write(SConstruct_path, """\
38+
DefaultEnvironment(tools=[])
39+
def CustomTest(context):
40+
context.Message('Executing Custom Test ...')
41+
context.Result(1)
42+
43+
env = Environment(tools=[], CONFIGURELOG = 'custom.logfile')
44+
conf = Configure(env, custom_tests = {'CustomTest' : CustomTest})
45+
conf.CustomTest();
46+
env = conf.Finish()
47+
""")
48+
49+
test.run()
50+
51+
expect = """\
52+
file %(SConstruct_path)s,line 7:
53+
\tConfigure(confdir = .sconf_temp)
54+
scons: Configure: Executing Custom Test ...
55+
scons: Configure: (cached) yes
56+
57+
58+
""" % locals()
59+
60+
test.must_match('custom.logfile', expect, mode='r')
61+
62+
test.pass_test()
63+
64+
# Local Variables:
65+
# tab-width:4
66+
# indent-tabs-mode:nil
67+
# End:
68+
# vim: set expandtab tabstop=4 shiftwidth=4:

0 commit comments

Comments
 (0)