summaryrefslogtreecommitdiffstats
path: root/test/sconsign
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2009-01-26 17:17:19 (GMT)
committerSteven Knight <knight@baldmt.com>2009-01-26 17:17:19 (GMT)
commit63e148fc7aae07d15733b7470f648c7377e66402 (patch)
tree010a7b57a8b5fb05d6934cc433f725fa1d7754ce /test/sconsign
parent0cb9ac61c6e4eeb45585c39d9b072a488b5d8d44 (diff)
downloadSCons-63e148fc7aae07d15733b7470f648c7377e66402.zip
SCons-63e148fc7aae07d15733b7470f648c7377e66402.tar.gz
SCons-63e148fc7aae07d15733b7470f648c7377e66402.tar.bz2
Fix tests that use the Python interpreter to execute internal scripts
and also set SConsignFile(None) so the implicit command dependencies don't cause .sconsign files to be written into the system directory where the Python executable lives.
Diffstat (limited to 'test/sconsign')
-rw-r--r--test/sconsign/script/SConsignFile.py1
-rw-r--r--test/sconsign/script/Signatures.py35
-rw-r--r--test/sconsign/script/no-SConsignFile.py56
3 files changed, 60 insertions, 32 deletions
diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py
index 9341062..71c91cb 100644
--- a/test/sconsign/script/SConsignFile.py
+++ b/test/sconsign/script/SConsignFile.py
@@ -110,6 +110,7 @@ env1 = Environment(PROGSUFFIX = '.exe',
OBJSUFFIX = '.obj',
CCCOM = r'%(_python_)s fake_cc.py sub2 $TARGET $SOURCE',
LINKCOM = r'%(_python_)s fake_link.py $TARGET $SOURCE')
+env1.PrependENVPath('PATHEXT', '.PY')
env1.Program('sub1/hello.c')
env2 = env1.Clone(CPPPATH = ['sub2'])
env2.Program('sub2/hello.c')
diff --git a/test/sconsign/script/Signatures.py b/test/sconsign/script/Signatures.py
index 823ef1d..9fdf54e 100644
--- a/test/sconsign/script/Signatures.py
+++ b/test/sconsign/script/Signatures.py
@@ -36,9 +36,6 @@ SourceSignatures('timestamp') with TargetSignatures('content').
import TestSCons
import TestSConsign
-python = TestSCons.python
-_python_ = TestSCons._python_
-
test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
# Note: We don't use os.path.join() representations of the file names
@@ -50,7 +47,20 @@ sub1_hello_obj = 'sub1/hello.obj'
test.subdir('sub1', 'sub2')
-test.write('fake_cc.py', r"""
+# Because this test sets SConsignFile(None), we execute our fake
+# scripts directly, not by feeding them to the Python executable.
+# That is, we chmod 0755 and us a "#!/usr/bin/env python" first
+# line for POSIX systems, and add .PY to the %PATHEXT% variable on
+# Windows. If we didn't do this, then running this script with
+# suitable prileveges would create a .sconsign file in the directory
+# where the Python executable lives. This can happen out of the
+# box on Mac OS X, with the result that the .sconsign statefulness
+# can mess up other tests.
+
+fake_cc_py = test.workpath('fake_cc.py')
+fake_link_py = test.workpath('fake_link.py')
+
+test.write(fake_cc_py, r"""#!/usr/bin/env python
import os
import re
import string
@@ -83,7 +93,7 @@ process(input, output)
sys.exit(0)
""")
-test.write('fake_link.py', r"""
+test.write(fake_link_py, r"""#!/usr/bin/env python
import sys
output = open(sys.argv[1], 'wb')
@@ -96,13 +106,16 @@ output.write(input.read())
sys.exit(0)
""")
+test.chmod(fake_cc_py, 0755)
+test.chmod(fake_link_py, 0755)
+
test.write('SConstruct', """
SConsignFile(None)
Decider('timestamp-newer')
env1 = Environment(PROGSUFFIX = '.exe',
OBJSUFFIX = '.obj',
- CCCOM = r'%(_python_)s fake_cc.py sub2 $TARGET $SOURCE',
- LINKCOM = r'%(_python_)s fake_link.py $TARGET $SOURCE')
+ CCCOM = r'%(fake_cc_py)s sub2 $TARGET $SOURCE',
+ LINKCOM = r'%(fake_link_py)s $TARGET $SOURCE')
env1.Program('sub1/hello.c')
env2 = env1.Clone(CPPPATH = ['sub2'])
env2.Program('sub2/hello.c')
@@ -136,22 +149,22 @@ date_re = r'\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d'
test.run_sconsign(arguments = "-e hello.exe -e hello.obj sub1/.sconsign",
stdout = r"""hello.exe: %(sig_re)s \d+ \d+
%(sub1_hello_obj)s: %(sig_re)s \d+ \d+
- %(python)s: None \d+ \d+
+ fake_link\.py: None \d+ \d+
%(sig_re)s \[.*\]
hello.obj: %(sig_re)s \d+ \d+
%(sub1_hello_c)s: None \d+ \d+
- %(python)s: None \d+ \d+
+ fake_cc\.py: None \d+ \d+
%(sig_re)s \[.*\]
""" % locals())
test.run_sconsign(arguments = "-e hello.exe -e hello.obj -r sub1/.sconsign",
stdout = r"""hello.exe: %(sig_re)s '%(date_re)s' \d+
%(sub1_hello_obj)s: %(sig_re)s '%(date_re)s' \d+
- %(python)s: None '%(date_re)s' \d+
+ fake_link\.py: None '%(date_re)s' \d+
%(sig_re)s \[.*\]
hello.obj: %(sig_re)s '%(date_re)s' \d+
%(sub1_hello_c)s: None '%(date_re)s' \d+
- %(python)s: None '%(date_re)s' \d+
+ fake_cc\.py: None '%(date_re)s' \d+
%(sig_re)s \[.*\]
""" % locals())
diff --git a/test/sconsign/script/no-SConsignFile.py b/test/sconsign/script/no-SConsignFile.py
index 16389cb..dacc011 100644
--- a/test/sconsign/script/no-SConsignFile.py
+++ b/test/sconsign/script/no-SConsignFile.py
@@ -32,14 +32,24 @@ Verify that the sconsign script works when using an individual
import TestSCons
import TestSConsign
-python = TestSCons.python
-_python_ = TestSCons._python_
-
test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
test.subdir('sub1', 'sub2')
-test.write('fake_cc.py', r"""
+# Because this test sets SConsignFile(None), we execute our fake
+# scripts directly, not by feeding them to the Python executable.
+# That is, we chmod 0755 and us a "#!/usr/bin/env python" first
+# line for POSIX systems, and add .PY to the %PATHEXT% variable on
+# Windows. If we didn't do this, then running this script with
+# suitable prileveges would create a .sconsign file in the directory
+# where the Python executable lives. This can happen out of the
+# box on Mac OS X, with the result that the .sconsign statefulness
+# can mess up other tests.
+
+fake_cc_py = test.workpath('fake_cc.py')
+fake_link_py = test.workpath('fake_link.py')
+
+test.write(fake_cc_py, r"""#!/usr/bin/env python
import os
import re
import string
@@ -72,7 +82,7 @@ process(input, output)
sys.exit(0)
""")
-test.write('fake_link.py', r"""
+test.write(fake_link_py, r"""#!/usr/bin/env python
import sys
output = open(sys.argv[1], 'wb')
@@ -85,6 +95,9 @@ output.write(input.read())
sys.exit(0)
""")
+test.chmod(fake_cc_py, 0755)
+test.chmod(fake_link_py, 0755)
+
# Note: We don't use os.path.join() representations of the file names
# in the expected output because paths in the .sconsign files are
# canonicalized to use / as the separator.
@@ -100,8 +113,9 @@ test.write(['SConstruct'], """
SConsignFile(None)
env1 = Environment(PROGSUFFIX = '.exe',
OBJSUFFIX = '.obj',
- CCCOM = r'%(_python_)s fake_cc.py sub2 $TARGET $SOURCE',
- LINKCOM = r'%(_python_)s fake_link.py $TARGET $SOURCE')
+ CCCOM = r'%(fake_cc_py)s sub2 $TARGET $SOURCE',
+ LINKCOM = r'%(fake_link_py)s $TARGET $SOURCE')
+env1.PrependENVPath('PATHEXT', '.PY')
env1.Program('sub1/hello.c')
env2 = env1.Clone(CPPPATH = ['sub2'])
env2.Program('sub2/hello.c')
@@ -132,11 +146,11 @@ sig_re = r'[0-9a-fA-F]{32}'
expect = r"""hello.c: %(sig_re)s \d+ \d+
hello.exe: %(sig_re)s \d+ \d+
%(sub1_hello_obj)s: %(sig_re)s \d+ \d+
- %(python)s: %(sig_re)s \d+ \d+
+ fake_link\.py: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
hello.obj: %(sig_re)s \d+ \d+
%(sub1_hello_c)s: %(sig_re)s \d+ \d+
- %(python)s: %(sig_re)s \d+ \d+
+ fake_cc\.py: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
""" % locals()
@@ -148,11 +162,11 @@ test.run_sconsign(arguments = "--raw sub1/.sconsign",
stdout = r"""hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
%(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
- %(python)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+ fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
%(sig_re)s \[.*\]
hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
%(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
- %(python)s: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
+ fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+, 'size': \d+L?, '_version_id': 1}
%(sig_re)s \[.*\]
""" % locals())
@@ -170,7 +184,7 @@ hello.exe:
csig: %(sig_re)s
timestamp: \d+
size: \d+
- %(python)s:
+ fake_link\.py:
csig: %(sig_re)s
timestamp: \d+
size: \d+
@@ -184,7 +198,7 @@ hello.obj:
csig: %(sig_re)s
timestamp: \d+
size: \d+
- %(python)s:
+ fake_cc\.py:
csig: %(sig_re)s
timestamp: \d+
size: \d+
@@ -221,22 +235,22 @@ hello.obj:
test.run_sconsign(arguments = "-e hello.obj sub1/.sconsign",
stdout = r"""hello.obj: %(sig_re)s \d+ \d+
%(sub1_hello_c)s: %(sig_re)s \d+ \d+
- %(python)s: %(sig_re)s \d+ \d+
+ fake_cc\.py: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
""" % locals())
test.run_sconsign(arguments = "-e hello.obj -e hello.exe -e hello.obj sub1/.sconsign",
stdout = r"""hello.obj: %(sig_re)s \d+ \d+
%(sub1_hello_c)s: %(sig_re)s \d+ \d+
- %(python)s: %(sig_re)s \d+ \d+
+ fake_cc\.py: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
hello.exe: %(sig_re)s \d+ \d+
%(sub1_hello_obj)s: %(sig_re)s \d+ \d+
- %(python)s: %(sig_re)s \d+ \d+
+ fake_link\.py: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
hello.obj: %(sig_re)s \d+ \d+
%(sub1_hello_c)s: %(sig_re)s \d+ \d+
- %(python)s: %(sig_re)s \d+ \d+
+ fake_cc\.py: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
""" % locals())
@@ -244,13 +258,13 @@ test.run_sconsign(arguments = "sub2/.sconsign",
stdout = r"""hello.c: %(sig_re)s \d+ \d+
hello.exe: %(sig_re)s \d+ \d+
%(sub2_hello_obj)s: %(sig_re)s \d+ \d+
- %(python)s: %(sig_re)s \d+ \d+
+ fake_link\.py: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
hello.obj: %(sig_re)s \d+ \d+
%(sub2_hello_c)s: %(sig_re)s \d+ \d+
%(sub2_inc1_h)s: %(sig_re)s \d+ \d+
%(sub2_inc2_h)s: %(sig_re)s \d+ \d+
- %(python)s: %(sig_re)s \d+ \d+
+ fake_cc\.py: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
inc1.h: %(sig_re)s \d+ \d+
inc2.h: %(sig_re)s \d+ \d+
@@ -273,11 +287,11 @@ test.run_sconsign(arguments = "-e hello.obj sub2/.sconsign sub1/.sconsign",
%(sub2_hello_c)s: %(sig_re)s \d+ \d+
%(sub2_inc1_h)s: %(sig_re)s \d+ \d+
%(sub2_inc2_h)s: %(sig_re)s \d+ \d+
- %(python)s: %(sig_re)s \d+ \d+
+ fake_cc\.py: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
hello.obj: %(sig_re)s \d+ \d+
%(sub1_hello_c)s: %(sig_re)s \d+ \d+
- %(python)s: %(sig_re)s \d+ \d+
+ fake_cc\.py: %(sig_re)s \d+ \d+
%(sig_re)s \[.*\]
""" % locals())