diff options
author | Gary Oberbrunner <garyo@oberbrunner.com> | 2009-04-29 01:18:14 (GMT) |
---|---|---|
committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2009-04-29 01:18:14 (GMT) |
commit | f336f13ec93285dc4f5caf00d79a7f2086e5786a (patch) | |
tree | 888a5686bbe5c770cfbe3b454e874f58e8d02e66 /test | |
parent | 74c4ae42c9361c1e32ff1c80946ce65370a5d273 (diff) | |
download | SCons-f336f13ec93285dc4f5caf00d79a7f2086e5786a.zip SCons-f336f13ec93285dc4f5caf00d79a7f2086e5786a.tar.gz SCons-f336f13ec93285dc4f5caf00d79a7f2086e5786a.tar.bz2 |
fix for bug #2393. Instead of just 'import'ing
site_scons/site_init.py, I now load that file directly into the
SCons.Script namespace using exec ... in. This allows site_init.py to
define tools in the way users expect.
Diffstat (limited to 'test')
-rw-r--r-- | test/site_scons/site_init.py | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/test/site_scons/site_init.py b/test/site_scons/site_init.py new file mode 100644 index 0000000..231f36c --- /dev/null +++ b/test/site_scons/site_init.py @@ -0,0 +1,89 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +""" +Verify site_scons/site_init.py file can define a tool, and it shows up +automatically in the SCons.Script namespace. +""" + +test = TestSCons.TestSCons() + +test.subdir('site_scons') + +test.write(['site_scons', 'site_init.py'], """ +def TOOL_FOO(env): + env['FOO'] = 'cat' + bld = Builder(action = '$FOO ${SOURCE} > ${TARGET}', + suffix = '.tgt') + env.Append(BUILDERS = {'Foo' : bld}) + +""") + +test.write('SConstruct', """ +e=Environment(tools=['default', TOOL_FOO]) +e.Foo(target='foo.out', source='SConstruct') +""") + +test.run(arguments = '-Q .', + stdout = """cat SConstruct > foo.out\n""") + + +""" +Test errors in site_scons/site_init.py. +""" + +test = TestSCons.TestSCons() + +test.subdir('site_scons') + +test.write(['site_scons', 'site_init.py'], """ +raise Exception("Huh?") +""") + +test.write('SConstruct', """ +e=Environment(tools=['default', TOOL_FOO]) +e.Foo(target='foo.out', source='SConstruct') +""") + +test.run(arguments = '-Q .', + stdout = "", + stderr = """.*Error loading site_init file.*Huh\?.*""", + status=2, + match=TestSCons.match_re_dotall) + + + +test.pass_test() + +# end of file + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: |