summaryrefslogtreecommitdiff
path: root/test/site_scons
diff options
context:
space:
mode:
authorGary Oberbrunner <garyo@oberbrunner.com>2010-07-04 17:47:05 +0000
committerGary Oberbrunner <garyo@oberbrunner.com>2010-07-04 17:47:05 +0000
commit5fa33777d15dfa4d32d94ed1673127248cfa2851 (patch)
treeb684687c1e666f7e506cb0227277dcd5bcaa66e5 /test/site_scons
parenta466f03d44873d7f975e32556c415d39e79041eb (diff)
downloadscons-5fa33777d15dfa4d32d94ed1673127248cfa2851.tar.gz
Set module metadata for site_scons/site_init.py files. From Arve Knudsen; closes issue 2520.
Diffstat (limited to 'test/site_scons')
-rw-r--r--test/site_scons/site_init.py54
1 files changed, 50 insertions, 4 deletions
diff --git a/test/site_scons/site_init.py b/test/site_scons/site_init.py
index 83c9a7f9..9f2e4114 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: