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')
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
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
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')
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')
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())
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
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')
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.
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')
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()
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())
csig: %(sig_re)s
timestamp: \d+
size: \d+
- %(python)s:
+ fake_link\.py:
csig: %(sig_re)s
timestamp: \d+
size: \d+
csig: %(sig_re)s
timestamp: \d+
size: \d+
- %(python)s:
+ fake_cc\.py:
csig: %(sig_re)s
timestamp: \d+
size: \d+
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())
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+
%(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())
being the equivalent of Decider('content').
"""
-import os.path
+import os
import TestSCons
-_python_ = TestSCons._python_
-
test = TestSCons.TestSCons()
-#if os.path.exists('sconsign.py'):
-# sconsign = 'sconsign.py'
-#elif os.path.exists('sconsign'):
-# sconsign = 'sconsign'
-#else:
-# print "Can find neither 'sconsign.py' nor 'sconsign' scripts."
-# test.no_result(1)
-
test.subdir('src', ['src', 'sub'])
-test.write('fake_cc.py', """\
+# 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, """\
+#!/usr/bin/env python
import sys
ofp = open(sys.argv[1], 'wb')
ofp.write('fake_cc.py: %s\\n' % sys.argv)
ofp.write(open(s, 'rb').read())
""")
-test.write('fake_link.py', """\
+test.write(fake_link_py, """\
+#!/usr/bin/env python
import sys
ofp = open(sys.argv[1], 'wb')
ofp.write('fake_link.py: %s\\n' % sys.argv)
ofp.write(open(s, 'rb').read())
""")
+test.chmod(fake_cc_py, 0755)
+test.chmod(fake_link_py, 0755)
+
test.write('SConstruct', """\
SConsignFile(None)
env = Environment(PROGSUFFIX = '.exe',
OBJSUFFIX = '.obj',
- CCCOM = r'%(_python_)s fake_cc.py $TARGET $SOURCES',
- LINKCOM = r'%(_python_)s fake_link.py $TARGET $SOURCES')
+ CCCOM = r'%(fake_cc_py)s $TARGET $SOURCES',
+ LINKCOM = r'%(fake_link_py)s $TARGET $SOURCES')
+env.PrependENVPath('PATHEXT', '.PY')
env.SConscript('src/SConstruct', exports=['env'])
env.Object('foo.c')
""" % locals())
SConsignFile(None)
env = Environment(PROGSUFFIX = '.exe',
OBJSUFFIX = '.obj',
- CCCOM = r'%(_python_)s fake_cc.py $TARGET $SOURCES',
- LINKCOM = r'%(_python_)s fake_link.py $TARGET $SOURCES')
+ CCCOM = r'%(fake_cc_py)s $TARGET $SOURCES',
+ LINKCOM = r'%(fake_link_py)s $TARGET $SOURCES')
+env.PrependENVPath('PATHEXT', '.PY')
p = env.Program('prog', ['main.c', '../foo$OBJSUFFIX', 'sub/bar.c'])
env.Default(p)
""" % locals())
src_sub_bar_obj = os.path.join('src', 'sub', 'bar.obj')
expect = """\
-fake_link.py: ['fake_link.py', '%(src_prog_exe)s', '%(src_main_obj)s', 'foo.obj', '%(src_sub_bar_obj)s']
-fake_cc.py: ['fake_cc.py', '%(src_main_obj)s', '%(src_main_c)s']
+fake_link.py: ['%(fake_link_py)s', '%(src_prog_exe)s', '%(src_main_obj)s', 'foo.obj', '%(src_sub_bar_obj)s']
+fake_cc.py: ['%(fake_cc_py)s', '%(src_main_obj)s', '%(src_main_c)s']
src/main.c
-fake_cc.py: ['fake_cc.py', 'foo.obj', 'foo.c']
+fake_cc.py: ['%(fake_cc_py)s', 'foo.obj', 'foo.c']
foo.c
-fake_cc.py: ['fake_cc.py', '%(src_sub_bar_obj)s', '%(src_sub_bar_c)s']
+fake_cc.py: ['%(fake_cc_py)s', '%(src_sub_bar_obj)s', '%(src_sub_bar_c)s']
src/sub/bar.c
""" % locals()