diff options
author | Gary Oberbrunner <garyo@oberbrunner.com> | 2010-07-04 17:47:05 (GMT) |
---|---|---|
committer | Gary Oberbrunner <garyo@oberbrunner.com> | 2010-07-04 17:47:05 (GMT) |
commit | 18d1302e8531ac99b30fa16615b270d5e751745b (patch) | |
tree | b684687c1e666f7e506cb0227277dcd5bcaa66e5 /test | |
parent | 4e1e98a120c8679d5492d308b7061a71dd47408d (diff) | |
download | SCons-18d1302e8531ac99b30fa16615b270d5e751745b.zip SCons-18d1302e8531ac99b30fa16615b270d5e751745b.tar.gz SCons-18d1302e8531ac99b30fa16615b270d5e751745b.tar.bz2 |
Set module metadata for site_scons/site_init.py files. From Arve Knudsen; closes issue 2520.
Diffstat (limited to 'test')
-rw-r--r-- | test/site_scons/site_init.py | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/test/site_scons/site_init.py b/test/site_scons/site_init.py index 83c9a7f..9f2e411 100644 --- a/test/site_scons/site_init.py +++ b/test/site_scons/site_init.py @@ -24,18 +24,64 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +""" +Verify various aspects of the handling of site_init.py. + +And more .. +""" + import TestSCons import sys +import os.path + +test = TestSCons.TestSCons() + +test.subdir('site_scons') + + +def _test_metadata(): + """Test site_init's module metadata. + + The following special variables should be predefined: __doc__, + __file__ and __name__. No special variables should be transferred from + SCons.Script. + """ + test.write(['site_scons', 'site_init.py'], """\ +import os.path +import re + +special = [] +for x in globals().keys(): + if re.match("__[^_]+__", x): + if x in ("__builtins__", "__package__",): + # Ignore certain keywords, as they are known to be added by Python + continue + special.append(x) + +print sorted(special) +print __doc__ +print os.path.realpath(__file__) +print __name__ +""") + + test.write('SConstruct', "\n") + test.run(arguments = '-Q .', + stdout = """\ +['__doc__', '__file__', '__name__'] +None +%s +site_init +scons: `.' is up to date. +""" % (os.path.realpath(os.path.join('site_scons', 'site_init.py')),)) + +_test_metadata() + """ 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') - if sys.platform == 'win32': cat_cmd='type' else: |