summaryrefslogtreecommitdiffstats
path: root/test/sconsign
diff options
context:
space:
mode:
Diffstat (limited to 'test/sconsign')
-rw-r--r--test/sconsign/corrupt.py104
-rw-r--r--test/sconsign/ghost-entries.py117
-rw-r--r--test/sconsign/nonwritable.py110
-rw-r--r--test/sconsign/script/Configure.py102
-rw-r--r--test/sconsign/script/SConsignFile.py471
-rw-r--r--test/sconsign/script/Signatures.py180
-rw-r--r--test/sconsign/script/bad.py67
-rw-r--r--test/sconsign/script/dblite.py173
-rw-r--r--test/sconsign/script/no-SConsignFile.py304
9 files changed, 1628 insertions, 0 deletions
diff --git a/test/sconsign/corrupt.py b/test/sconsign/corrupt.py
new file mode 100644
index 0000000..cab4d75
--- /dev/null
+++ b/test/sconsign/corrupt.py
@@ -0,0 +1,104 @@
+#!/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__"
+
+"""
+Test that we get proper warnings when .sconsign* files are corrupt.
+"""
+
+import TestSCons
+import TestCmd
+
+test = TestSCons.TestSCons(match = TestCmd.match_re)
+
+test.subdir('work1', ['work1', 'sub'],
+ 'work2', ['work2', 'sub'])
+
+work1__sconsign_dblite = test.workpath('work1', '.sconsign.dblite')
+work2_sub__sconsign = test.workpath('work2', 'sub', '.sconsign')
+
+SConstruct_contents = """\
+def build1(target, source, env):
+ open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
+ return None
+
+B1 = Builder(action = build1)
+env = Environment(BUILDERS = { 'B1' : B1})
+env.B1(target = 'sub/foo.out', source = 'foo.in')
+"""
+
+
+
+test.write(['work1', 'SConstruct'], SConstruct_contents)
+
+test.write(['work1', 'foo.in'], "work1/foo.in\n")
+
+stderr = '''
+scons: warning: Ignoring corrupt .sconsign file: \.sconsign\.dblite
+.*
+'''
+
+stdout = test.wrap_stdout('build1\(\["sub.foo\.out"\], \["foo\.in"\]\)\n')
+
+test.write(work1__sconsign_dblite, 'not:a:sconsign:file')
+test.run(chdir='work1', arguments='.', stderr=stderr, stdout=stdout)
+
+test.write(work1__sconsign_dblite, '\0\0\0\0\0\0\0\0\0\0\0\0\0\0')
+test.run(chdir='work1', arguments='.', stderr=stderr, stdout=stdout)
+
+
+
+# Test explicitly using a .sconsign file in each directory.
+
+SConstruct_contents = """\
+SConsignFile(None)
+""" + SConstruct_contents
+
+test.write(['work2', 'SConstruct'], SConstruct_contents)
+
+test.write(['work2', 'foo.in'], "work2/foo.in\n")
+
+stderr = '''
+scons: warning: Ignoring corrupt .sconsign file: sub.\.sconsign
+.*
+'''
+
+stdout = test.wrap_stdout('build1\(\["sub.foo\.out"\], \["foo\.in"\]\)\n')
+
+test.write(work2_sub__sconsign, 'not:a:sconsign:file')
+test.run(chdir='work2', arguments='.', stderr=stderr, stdout=stdout)
+
+test.write(work2_sub__sconsign, '\0\0\0\0\0\0\0\0\0\0\0\0\0\0')
+test.run(chdir='work2', arguments='.', stderr=stderr, stdout=stdout)
+
+
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/sconsign/ghost-entries.py b/test/sconsign/ghost-entries.py
new file mode 100644
index 0000000..46916ca
--- /dev/null
+++ b/test/sconsign/ghost-entries.py
@@ -0,0 +1,117 @@
+#!/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__"
+
+"""
+Verify that "ghost" entries in the .sconsign file don't have Nodes
+created for them on subsequent runs (which would cause errors
+when scanning directories).
+"""
+
+import os.path
+
+d_current_txt = os.path.join('d', 'current.txt')
+
+import TestSCons
+
+test = TestSCons.TestSCons()
+
+# This test case is from Morten Elo Petersen. It's harder because
+# blib-case1only actually exists in the build dir after the -c, so the
+# Dir scanner finds it and adds it to the dir's entries.
+# Unfortunately FS.py's File.exists() method checks it later and finds
+# it looks like a stale build copy of a missing source, so it deletes
+# it. And then it's later discovered to be missing since it's still
+# in the dir's entries list. The fix for this is to test for missing
+# source files in the dir scanner (Scanner/Dir.py), and delete them
+# (just like File.exists() does if they're found in the build dir
+# rather than making entries for them.
+
+test.write('SConstruct', """\
+def cat(target, source, env):
+ fp = open(str(target[0]), 'wb')
+ for s in source:
+ fp.write(open(str(s), 'rb').read())
+ fp.close()
+env=Environment()
+Export('env')
+env['BUILDERS']['Cat']=Builder(action=cat, multi=1)
+SConscript('src/SConscript',variant_dir='build')
+""")
+
+test.subdir('src')
+test.write(['src', 'SConscript'], """\
+Import('env')
+if ARGUMENTS['case']=='1':
+ A=env.Cat('#build/lib/blib-case1only','src.txt')
+ B=env.Cat('#build/lib/blibB','#build/lib/blib-case1only')
+if ARGUMENTS['case']=='2':
+ A=env.Cat('case2only','src.txt')
+ B=env.Cat('#build/lib/blibB.txt','case2only')
+env.Alias('go','#build/lib')
+""")
+
+test.write(['src', 'src.txt'], "anything")
+
+test.run(arguments="-Q go case=1")
+test.must_exist('build/lib/blib-case1only')
+test.run(arguments="-Q go case=2")
+test.run(arguments="-Q go case=2 -c")
+test.run(arguments="-Q go case=2")
+
+
+#############################################################################
+# This test case is from Jason Orendorff.
+# Checking for existence before making nodes for things found in the
+# .sconsign fixes this one.
+
+test.write('SConstruct', """\
+Command("d/current.txt", [], [Touch("$TARGET")])
+if 'pass' in ARGUMENTS and ARGUMENTS['pass'] == '1':
+ Command("d/obsolete.txt", [], [Touch("$TARGET")])
+Command("installer.exe", ['d'], [Touch("$TARGET")])
+""")
+
+test.run(arguments='-Q pass=1')
+
+# Now delete the created files
+test.unlink(['d', 'obsolete.txt'])
+test.unlink(['d', 'current.txt'])
+test.rmdir(['d'])
+
+# Run again, as pass 2
+expect = """Touch("%(d_current_txt)s")
+Touch("installer.exe")
+""" % locals()
+
+test.run(arguments='-Q pass=2', stdout=expect)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/sconsign/nonwritable.py b/test/sconsign/nonwritable.py
new file mode 100644
index 0000000..913dcf1
--- /dev/null
+++ b/test/sconsign/nonwritable.py
@@ -0,0 +1,110 @@
+#!/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__"
+
+"""
+Test that things still work when a .sconsign* file is not writable.
+"""
+
+import os
+import TestSCons
+import TestCmd
+import pickle
+
+test = TestSCons.TestSCons(match = TestCmd.match_re)
+
+test.subdir('work1',
+ ['work1', 'sub1'],
+ ['work1', 'sub2'],
+ ['work1', 'sub3'],
+ 'work2',
+ ['work2', 'sub1'],
+ ['work2', 'sub2'],
+ ['work2', 'sub3'])
+
+work1__sconsign_dblite = test.workpath('work1', '.sconsign.dblite')
+work2_sub1__sconsign = test.workpath('work2', 'sub1', '.sconsign')
+work2_sub2__sconsign = test.workpath('work2', 'sub2', '.sconsign')
+work2_sub3__sconsign = test.workpath('work2', 'sub3', '.sconsign')
+
+SConstruct_contents = """\
+def build1(target, source, env):
+ open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
+ return None
+
+def build2(target, source, env):
+ import os
+ import os.path
+ open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
+ dir, file = os.path.split(str(target[0]))
+ os.chmod(dir, 0555)
+ return None
+
+B1 = Builder(action = build1)
+B2 = Builder(action = build2)
+env = Environment(BUILDERS = { 'B1' : B1, 'B2' : B2 })
+env.B1(target = 'sub1/foo.out', source = 'foo.in')
+env.B2(target = 'sub2/foo.out', source = 'foo.in')
+env.B2(target = 'sub3/foo.out', source = 'foo.in')
+"""
+
+
+
+test.write(['work1', 'SConstruct'], SConstruct_contents)
+
+test.write(['work1', 'foo.in'], "work1/foo.in\n")
+
+test.write(work1__sconsign_dblite, "")
+
+os.chmod(work1__sconsign_dblite, 0444)
+
+test.run(chdir='work1', arguments='.')
+
+
+
+SConstruct_contents = """\
+SConsignFile(None)
+""" + SConstruct_contents
+
+test.write(['work2', 'SConstruct'], SConstruct_contents)
+
+test.write(['work2', 'foo.in'], "work2/foo.in\n")
+
+pickle.dump({}, open(work2_sub1__sconsign, 'wb'), 1)
+pickle.dump({}, open(work2_sub2__sconsign, 'wb'), 1)
+
+os.chmod(work2_sub1__sconsign, 0444)
+
+test.run(chdir='work2', arguments='.')
+
+
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/sconsign/script/Configure.py b/test/sconsign/script/Configure.py
new file mode 100644
index 0000000..679f084
--- /dev/null
+++ b/test/sconsign/script/Configure.py
@@ -0,0 +1,102 @@
+#!/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__"
+
+"""
+Verify that we can print .sconsign files with Configure context
+info in them (which have different BuildInfo entries).
+"""
+
+import os
+import re
+
+import TestSCons
+import TestSConsign
+
+_obj = TestSCons._obj
+
+test = TestSConsign.TestSConsign(match = TestSConsign.match_re,
+ diff = TestSConsign.diff_re)
+
+# Note: Here we pass the full search PATH of our current system to
+# the detect() method. This way we try to ensure that we find the same
+# compiler executable as the SConstruct below, which uses
+# os.environ['PATH'] too.
+CC = test.detect('CC', ENV={'PATH' : os.environ.get('PATH','')}, norm=1)
+CC_dir, CC_file = os.path.split(CC)
+
+CC = re.escape(CC)
+CC_dir = re.escape(os.path.normcase(CC_dir))
+CC_file = re.escape(CC_file)
+
+# 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.
+
+_sconf_temp_conftest_0_c = '.sconf_temp/conftest_0.c'
+
+test.write('SConstruct', """
+import os
+env = Environment(ENV={'PATH' : os.environ.get('PATH','')})
+conf = Configure(env)
+r1 = conf.CheckCHeader( 'math.h' )
+env = conf.Finish()
+""")
+
+test.run(arguments = '.')
+
+sig_re = r'[0-9a-fA-F]{32}'
+date_re = r'\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d'
+
+# Note: There's a space at the end of the '.*': line, because the
+# Value node being printed actually begins with a newline. It would
+# probably be good to change that to a repr() of the contents.
+expect = r"""=== .:
+SConstruct: None \d+ \d+
+=== .sconf_temp:
+conftest_0.c:
+ '.*':
+#include "math.h"
+
+
+ %(sig_re)s \[.*\]
+conftest_0%(_obj)s:
+ %(_sconf_temp_conftest_0_c)s: %(sig_re)s \d+ \d+
+ %(CC)s: %(sig_re)s \d+ \d+
+ %(sig_re)s \[.*\]
+=== %(CC_dir)s:
+%(CC_file)s: %(sig_re)s \d+ \d+
+""" % locals()
+
+test.run_sconsign(arguments = ".sconsign",
+ stdout = expect)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py
new file mode 100644
index 0000000..74fb1f0
--- /dev/null
+++ b/test/sconsign/script/SConsignFile.py
@@ -0,0 +1,471 @@
+#!/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__"
+
+"""
+Verify that the sconsign script works with files generated when
+using the signatures in an SConsignFile().
+"""
+
+import re
+
+import TestSCons
+import TestSConsign
+
+test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
+
+test.subdir('sub1', 'sub2')
+
+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 sys
+
+path = sys.argv[1].split()
+output = open(sys.argv[2], 'wb')
+input = open(sys.argv[3], 'rb')
+
+output.write('fake_cc.py: %s\n' % sys.argv)
+
+def find_file(f):
+ for dir in path:
+ p = dir + os.sep + f
+ if os.path.exists(p):
+ return open(p, 'rb')
+ return None
+
+def process(infp, outfp):
+ for line in infp.readlines():
+ m = re.match('#include <(.*)>', line)
+ if m:
+ file = m.group(1)
+ process(find_file(file), outfp)
+ else:
+ outfp.write(line)
+
+process(input, output)
+
+sys.exit(0)
+""")
+
+test.write(fake_link_py, r"""#!/usr/bin/env python
+import sys
+
+output = open(sys.argv[1], 'wb')
+input = open(sys.argv[2], 'rb')
+
+output.write('fake_link.py: %s\n' % sys.argv)
+
+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.
+
+sub1_hello_c = 'sub1/hello.c'
+sub1_hello_obj = 'sub1/hello.obj'
+sub2_hello_c = 'sub2/hello.c'
+sub2_hello_obj = 'sub2/hello.obj'
+sub2_inc1_h = 'sub2/inc1.h'
+sub2_inc2_h = 'sub2/inc2.h'
+
+test.write(['SConstruct'], """\
+SConsignFile()
+env1 = Environment(PROGSUFFIX = '.exe',
+ OBJSUFFIX = '.obj',
+ 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')
+""" % locals())
+
+test.write(['sub1', 'hello.c'], r"""
+sub1/hello.c
+""")
+
+test.write(['sub2', 'hello.c'], r"""
+#include <inc1.h>
+#include <inc2.h>
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("sub2/goodbye.c\n");
+ exit (0);
+}
+""")
+
+test.write(['sub2', 'inc1.h'], r"""\
+#define STRING1 "inc1.h"
+""")
+
+test.write(['sub2', 'inc2.h'], r"""\
+#define STRING2 "inc2.h"
+""")
+
+test.run(arguments = '--implicit-cache .')
+
+sig_re = r'[0-9a-fA-F]{32}'
+
+test.run_sconsign(arguments = ".sconsign",
+ stdout = r"""=== .:
+SConstruct: None \d+ \d+
+fake_cc\.py: %(sig_re)s \d+ \d+
+fake_link\.py: %(sig_re)s \d+ \d+
+=== sub1:
+hello.c: %(sig_re)s \d+ \d+
+hello.exe: %(sig_re)s \d+ \d+
+ %(sub1_hello_obj)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+
+ fake_cc\.py: %(sig_re)s \d+ \d+
+ %(sig_re)s \[.*\]
+=== sub2:
+hello.c: %(sig_re)s \d+ \d+
+hello.exe: %(sig_re)s \d+ \d+
+ %(sub2_hello_obj)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+
+ 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+
+""" % locals())
+
+test.run_sconsign(arguments = "--raw .sconsign",
+ stdout = r"""=== .:
+SConstruct: {'csig': None, 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+=== sub1:
+hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sig_re)s \[.*\]
+hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sig_re)s \[.*\]
+=== sub2:
+hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sub2_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sig_re)s \[.*\]
+hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sub2_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sub2_inc1_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sub2_inc2_h)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sig_re)s \[.*\]
+inc1.h: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+inc2.h: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+""" % locals())
+
+expect = r"""=== .:
+SConstruct:
+ csig: None
+ timestamp: \d+
+ size: \d+
+fake_cc\.py:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+fake_link\.py:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+=== sub1:
+hello.c:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+hello.exe:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ implicit:
+ %(sub1_hello_obj)s:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ fake_link\.py:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ action: %(sig_re)s \[.*\]
+hello.obj:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ implicit:
+ %(sub1_hello_c)s:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ fake_cc\.py:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ action: %(sig_re)s \[.*\]
+=== sub2:
+hello.c:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+hello.exe:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ implicit:
+ %(sub2_hello_obj)s:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ fake_link\.py:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ action: %(sig_re)s \[.*\]
+hello.obj:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ implicit:
+ %(sub2_hello_c)s:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ %(sub2_inc1_h)s:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ %(sub2_inc2_h)s:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ fake_cc\.py:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ action: %(sig_re)s \[.*\]
+inc1.h:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+inc2.h:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+""" % locals()
+
+test.run_sconsign(arguments = "-v .sconsign", stdout=expect)
+
+test.run_sconsign(arguments = "-c -v .sconsign",
+ stdout = r"""=== .:
+SConstruct:
+ csig: None
+fake_cc\.py:
+ csig: %(sig_re)s
+fake_link\.py:
+ csig: %(sig_re)s
+=== sub1:
+hello.c:
+ csig: %(sig_re)s
+hello.exe:
+ csig: %(sig_re)s
+hello.obj:
+ csig: %(sig_re)s
+=== sub2:
+hello.c:
+ csig: %(sig_re)s
+hello.exe:
+ csig: %(sig_re)s
+hello.obj:
+ csig: %(sig_re)s
+inc1.h:
+ csig: %(sig_re)s
+inc2.h:
+ csig: %(sig_re)s
+""" % locals())
+
+test.run_sconsign(arguments = "-s -v .sconsign",
+ stdout = r"""=== .:
+SConstruct:
+ size: \d+
+fake_cc\.py:
+ size: \d+
+fake_link\.py:
+ size: \d+
+=== sub1:
+hello.c:
+ size: \d+
+hello.exe:
+ size: \d+
+hello.obj:
+ size: \d+
+=== sub2:
+hello.c:
+ size: \d+
+hello.exe:
+ size: \d+
+hello.obj:
+ size: \d+
+inc1.h:
+ size: \d+
+inc2.h:
+ size: \d+
+""" % locals())
+
+test.run_sconsign(arguments = "-t -v .sconsign",
+ stdout = r"""=== .:
+SConstruct:
+ timestamp: \d+
+fake_cc\.py:
+ timestamp: \d+
+fake_link\.py:
+ timestamp: \d+
+=== sub1:
+hello.c:
+ timestamp: \d+
+hello.exe:
+ timestamp: \d+
+hello.obj:
+ timestamp: \d+
+=== sub2:
+hello.c:
+ timestamp: \d+
+hello.exe:
+ timestamp: \d+
+hello.obj:
+ timestamp: \d+
+inc1.h:
+ timestamp: \d+
+inc2.h:
+ timestamp: \d+
+""" % locals())
+
+test.run_sconsign(arguments = "-e hello.obj .sconsign",
+ stdout = r"""=== .:
+=== sub1:
+hello.obj: %(sig_re)s \d+ \d+
+ %(sub1_hello_c)s: %(sig_re)s \d+ \d+
+ fake_cc\.py: %(sig_re)s \d+ \d+
+ %(sig_re)s \[.*\]
+=== sub2:
+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+
+ fake_cc\.py: %(sig_re)s \d+ \d+
+ %(sig_re)s \[.*\]
+""" % locals(),
+ stderr = r"""sconsign: no entry `hello\.obj' in `\.'
+""" % locals())
+
+test.run_sconsign(arguments = "-e hello.obj -e hello.exe -e hello.obj .sconsign",
+ stdout = r"""=== .:
+=== sub1:
+hello.obj: %(sig_re)s \d+ \d+
+ %(sub1_hello_c)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+
+ 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+
+ fake_cc\.py: %(sig_re)s \d+ \d+
+ %(sig_re)s \[.*\]
+=== sub2:
+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+
+ fake_cc\.py: %(sig_re)s \d+ \d+
+ %(sig_re)s \[.*\]
+hello.exe: %(sig_re)s \d+ \d+
+ %(sub2_hello_obj)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+
+ fake_cc\.py: %(sig_re)s \d+ \d+
+ %(sig_re)s \[.*\]
+""" % locals(),
+ stderr = r"""sconsign: no entry `hello\.obj' in `\.'
+sconsign: no entry `hello\.exe' in `\.'
+sconsign: no entry `hello\.obj' in `\.'
+""" % locals())
+
+#test.run_sconsign(arguments = "-i -v .sconsign",
+# stdout = r"""=== sub1:
+#hello.exe:
+# implicit:
+# hello.obj: %(sig_re)s
+#hello.obj:
+# implicit:
+# hello.c: %(sig_re)s
+#=== sub2:
+#hello.exe:
+# implicit:
+# hello.obj: %(sig_re)s
+#hello.obj:
+# implicit:
+# hello.c: %(sig_re)s
+# inc1.h: %(sig_re)s
+# inc2.h: %(sig_re)s
+#inc1.h: %(sig_re)s
+#inc2.h: %(sig_re)s
+#""" % locals())
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/sconsign/script/Signatures.py b/test/sconsign/script/Signatures.py
new file mode 100644
index 0000000..cfd2a7f
--- /dev/null
+++ b/test/sconsign/script/Signatures.py
@@ -0,0 +1,180 @@
+#!/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__"
+
+"""
+Verify that the sconsign script works when using a .sconsign file in
+each subdirectory (SConsignFile(None)) written with the non-default
+value of Decider('timestamp-newer').
+
+This used to test the non-default combination of
+SourceSignatures('timestamp') with TargetSignatures('content').
+"""
+
+import TestSCons
+import TestSConsign
+
+test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
+
+# 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.
+
+sub1_hello_c = 'sub1/hello.c'
+sub1_hello_obj = 'sub1/hello.obj'
+
+test.subdir('sub1', 'sub2')
+
+# 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 sys
+
+path = sys.argv[1].split()
+output = open(sys.argv[2], 'wb')
+input = open(sys.argv[3], 'rb')
+
+output.write('fake_cc.py: %s\n' % sys.argv)
+
+def find_file(f):
+ for dir in path:
+ p = dir + os.sep + f
+ if os.path.exists(p):
+ return open(p, 'rb')
+ return None
+
+def process(infp, outfp):
+ for line in infp.readlines():
+ m = re.match('#include <(.*)>', line)
+ if m:
+ file = m.group(1)
+ process(find_file(file), outfp)
+ else:
+ outfp.write(line)
+
+process(input, output)
+
+sys.exit(0)
+""")
+
+test.write(fake_link_py, r"""#!/usr/bin/env python
+import sys
+
+output = open(sys.argv[1], 'wb')
+input = open(sys.argv[2], 'rb')
+
+output.write('fake_link.py: %s\n' % sys.argv)
+
+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',
+ # Specify the command lines with lists-of-lists so
+ # finding the implicit dependencies works even with
+ # spaces in the fake_*_py path names.
+ 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')
+""" % locals())
+
+test.write(['sub1', 'hello.c'], r"""\
+sub1/hello.c
+""")
+
+test.write(['sub2', 'hello.c'], r"""\
+#include <inc1.h>
+#include <inc2.h>
+sub2/hello.c
+""")
+
+test.write(['sub2', 'inc1.h'], r"""\
+#define STRING1 "inc1.h"
+""")
+
+test.write(['sub2', 'inc2.h'], r"""\
+#define STRING2 "inc2.h"
+""")
+
+test.sleep()
+
+test.run(arguments = '. --max-drift=1')
+
+sig_re = r'[0-9a-fA-F]{32}'
+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+
+ fake_link\.py: None \d+ \d+
+ %(sig_re)s \[.*\]
+hello.obj: %(sig_re)s \d+ \d+
+ %(sub1_hello_c)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+
+ 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+
+ fake_cc\.py: None '%(date_re)s' \d+
+ %(sig_re)s \[.*\]
+""" % locals())
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/sconsign/script/bad.py b/test/sconsign/script/bad.py
new file mode 100644
index 0000000..fc21577
--- /dev/null
+++ b/test/sconsign/script/bad.py
@@ -0,0 +1,67 @@
+#!/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__"
+
+"""
+Verify that the sconsign script generates appropriate error messages when
+passed various non-existent or bad sconsign files as arguments.
+"""
+
+import TestSConsign
+
+test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
+
+test.write('bad1', "bad1\n")
+test.write('bad2.dblite', "bad2.dblite\n")
+test.write('bad3', "bad3\n")
+
+test.run_sconsign(arguments = "-f dblite no_sconsign",
+ stderr = "sconsign: \[Errno 2\] No such file or directory: 'no_sconsign'\n")
+
+test.run_sconsign(arguments = "-f dblite bad1",
+ stderr = "sconsign: \[Errno 2\] No such file or directory: 'bad1.dblite'\n")
+
+test.run_sconsign(arguments = "-f dblite bad1.dblite",
+ stderr = "sconsign: \[Errno 2\] No such file or directory: 'bad1.dblite'\n")
+
+test.run_sconsign(arguments = "-f dblite bad2",
+ stderr = "sconsign: ignoring invalid `dblite' file `bad2'\n")
+
+test.run_sconsign(arguments = "-f dblite bad2.dblite",
+ stderr = "sconsign: ignoring invalid `dblite' file `bad2.dblite'\n")
+
+test.run_sconsign(arguments = "-f sconsign no_sconsign",
+ stderr = "sconsign: \[Errno 2\] No such file or directory: 'no_sconsign'\n")
+
+test.run_sconsign(arguments = "-f sconsign bad3",
+ stderr = "sconsign: ignoring invalid .sconsign file `bad3'\n")
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/sconsign/script/dblite.py b/test/sconsign/script/dblite.py
new file mode 100644
index 0000000..0daf8bf
--- /dev/null
+++ b/test/sconsign/script/dblite.py
@@ -0,0 +1,173 @@
+#!/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__"
+
+"""
+Verify that various ways of getting at a an sconsign file written with
+the default dblite module and default .dblite suffix work correctly.
+"""
+
+import re,sys
+
+import TestSConsign
+
+test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
+
+_exe = TestSConsign._exe
+_obj = TestSConsign._obj
+
+CC = test.detect('CC', norm=1)
+LINK = test.detect('LINK', norm=1)
+if LINK is None: LINK = CC
+
+def escape_drive_case(s):
+ """Turn c\: into [cC]\:"""
+ if re.match(r'^(.)[\\]?:', s):
+ drive=s[0]
+ return '['+drive.lower()+drive.upper()+']'+s[1:]
+ else:
+ return s
+
+CC = escape_drive_case(re.escape(CC))
+LINK = escape_drive_case(re.escape(LINK))
+
+test.subdir('sub1', 'sub2')
+
+# 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.
+
+sub1_hello_c = 'sub1/hello.c'
+sub1_hello_obj = 'sub1/hello%s' % _obj
+
+test.write('SConstruct', """
+SConsignFile('my_sconsign')
+Decider('timestamp-newer')
+env1 = Environment()
+env1.Program('sub1/hello.c')
+env2 = env1.Clone(CPPPATH = ['sub2'])
+env2.Program('sub2/hello.c')
+""")
+
+test.write(['sub1', 'hello.c'], r"""\
+#include <stdio.h>
+#include <stdlib.h>
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("sub1/hello.c\n");
+ exit (0);
+}
+""")
+
+test.write(['sub2', 'hello.c'], r"""\
+#include <stdio.h>
+#include <stdlib.h>
+#include <inc1.h>
+#include <inc2.h>
+int
+main(int argc, char *argv[])
+{
+ argv[argc++] = "--";
+ printf("sub2/goodbye.c\n");
+ exit (0);
+}
+""")
+
+test.write(['sub2', 'inc1.h'], r"""\
+#define STRING1 "inc1.h"
+""")
+
+test.write(['sub2', 'inc2.h'], r"""\
+#define STRING2 "inc2.h"
+""")
+
+test.sleep()
+
+test.run(arguments = '. --max-drift=1')
+
+sig_re = r'[0-9a-fA-F]{32}'
+date_re = r'\S+ \S+ [ \d]\d \d\d:\d\d:\d\d \d\d\d\d'
+
+if sys.platform == 'win32':
+ import SCons.Tool.MSCommon as msc
+ if msc.msvc_exists():
+ manifest = r"""
+embedManifestExeCheck\(target, source, env\)"""
+ else:
+ manifest = ''
+else:
+ manifest = ''
+
+expect = r"""=== sub1:
+hello%(_exe)s: %(sig_re)s \d+ \d+
+ %(sub1_hello_obj)s: %(sig_re)s \d+ \d+
+ %(LINK)s: None \d+ \d+
+ %(sig_re)s \[.*%(manifest)s\]
+hello%(_obj)s: %(sig_re)s \d+ \d+
+ %(sub1_hello_c)s: None \d+ \d+
+ %(CC)s: None \d+ \d+
+ %(sig_re)s \[.*\]
+""" % locals()
+
+expect_r = """=== sub1:
+hello%(_exe)s: %(sig_re)s '%(date_re)s' \d+
+ %(sub1_hello_obj)s: %(sig_re)s '%(date_re)s' \d+
+ %(LINK)s: None '%(date_re)s' \d+
+ %(sig_re)s \[.*%(manifest)s\]
+hello%(_obj)s: %(sig_re)s '%(date_re)s' \d+
+ %(sub1_hello_c)s: None '%(date_re)s' \d+
+ %(CC)s: None '%(date_re)s' \d+
+ %(sig_re)s \[.*\]
+""" % locals()
+
+common_flags = '-e hello%(_exe)s -e hello%(_obj)s -d sub1' % locals()
+
+test.run_sconsign(arguments = "%s my_sconsign" % common_flags,
+ stdout = expect)
+
+test.run_sconsign(arguments = "%s my_sconsign.dblite" % common_flags,
+ stdout = expect)
+
+test.run_sconsign(arguments = "%s -f dblite my_sconsign" % common_flags,
+ stdout = expect)
+
+test.run_sconsign(arguments = "%s -f dblite my_sconsign.dblite" % common_flags,
+ stdout = expect)
+
+test.run_sconsign(arguments = "%s -r -f dblite my_sconsign" % common_flags,
+ stdout = expect_r)
+
+test.run_sconsign(arguments = "%s -r -f dblite my_sconsign.dblite" % common_flags,
+ stdout = expect_r)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/sconsign/script/no-SConsignFile.py b/test/sconsign/script/no-SConsignFile.py
new file mode 100644
index 0000000..09ecfa2
--- /dev/null
+++ b/test/sconsign/script/no-SConsignFile.py
@@ -0,0 +1,304 @@
+#!/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__"
+
+"""
+Verify that the sconsign script works when using an individual
+.sconsign file in each directory (SConsignFile(None)).
+"""
+
+import TestSCons
+import TestSConsign
+
+test = TestSConsign.TestSConsign(match = TestSConsign.match_re)
+
+test.subdir('sub1', 'sub2')
+
+# 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 sys
+
+path = sys.argv[1].split()
+output = open(sys.argv[2], 'wb')
+input = open(sys.argv[3], 'rb')
+
+output.write('fake_cc.py: %s\n' % sys.argv)
+
+def find_file(f):
+ for dir in path:
+ p = dir + os.sep + f
+ if os.path.exists(p):
+ return open(p, 'rb')
+ return None
+
+def process(infp, outfp):
+ for line in infp.readlines():
+ m = re.match('#include <(.*)>', line)
+ if m:
+ file = m.group(1)
+ process(find_file(file), outfp)
+ else:
+ outfp.write(line)
+
+process(input, output)
+
+sys.exit(0)
+""")
+
+test.write(fake_link_py, r"""#!/usr/bin/env python
+import sys
+
+output = open(sys.argv[1], 'wb')
+input = open(sys.argv[2], 'rb')
+
+output.write('fake_link.py: %s\n' % sys.argv)
+
+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.
+
+sub1_hello_c = 'sub1/hello.c'
+sub1_hello_obj = 'sub1/hello.obj'
+sub2_hello_c = 'sub2/hello.c'
+sub2_hello_obj = 'sub2/hello.obj'
+sub2_inc1_h = 'sub2/inc1.h'
+sub2_inc2_h = 'sub2/inc2.h'
+
+test.write(['SConstruct'], """
+SConsignFile(None)
+env1 = Environment(PROGSUFFIX = '.exe',
+ OBJSUFFIX = '.obj',
+ # Specify the command lines with lists-of-lists so
+ # finding the implicit dependencies works even with
+ # spaces in the fake_*_py path names.
+ 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')
+""" % locals())
+
+test.write(['sub1', 'hello.c'], r"""\
+sub1/hello.c
+""")
+
+test.write(['sub2', 'hello.c'], r"""\
+#include <inc1.h>
+#include <inc2.h>
+sub2/hello.c
+""")
+
+test.write(['sub2', 'inc1.h'], r"""\
+#define STRING1 "inc1.h"
+""")
+
+test.write(['sub2', 'inc2.h'], r"""\
+#define STRING2 "inc2.h"
+""")
+
+test.run(arguments = '--implicit-cache --tree=prune .')
+
+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+
+ 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+
+ fake_cc\.py: %(sig_re)s \d+ \d+
+ %(sig_re)s \[.*\]
+""" % locals()
+
+test.run_sconsign(arguments = "sub1/.sconsign", stdout=expect)
+
+test.run_sconsign(arguments = "--raw sub1/.sconsign",
+ stdout = r"""hello.c: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+hello.exe: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sub1_hello_obj)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ fake_link\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sig_re)s \[.*\]
+hello.obj: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sub1_hello_c)s: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ fake_cc\.py: {'csig': '%(sig_re)s', 'timestamp': \d+L?, 'size': \d+L?, '_version_id': 2}
+ %(sig_re)s \[.*\]
+""" % locals())
+
+test.run_sconsign(arguments = "-v sub1/.sconsign",
+ stdout = r"""hello.c:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+hello.exe:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ implicit:
+ %(sub1_hello_obj)s:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ fake_link\.py:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ action: %(sig_re)s \[.*\]
+hello.obj:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ implicit:
+ %(sub1_hello_c)s:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ fake_cc\.py:
+ csig: %(sig_re)s
+ timestamp: \d+
+ size: \d+
+ action: %(sig_re)s \[.*\]
+""" % locals())
+
+test.run_sconsign(arguments = "-c -v sub1/.sconsign",
+ stdout = r"""hello.c:
+ csig: %(sig_re)s
+hello.exe:
+ csig: %(sig_re)s
+hello.obj:
+ csig: %(sig_re)s
+""" % locals())
+
+test.run_sconsign(arguments = "-s -v sub1/.sconsign",
+ stdout = r"""hello.c:
+ size: \d+
+hello.exe:
+ size: \d+
+hello.obj:
+ size: \d+
+""" % locals())
+
+test.run_sconsign(arguments = "-t -v sub1/.sconsign",
+ stdout = r"""hello.c:
+ timestamp: \d+
+hello.exe:
+ timestamp: \d+
+hello.obj:
+ timestamp: \d+
+""" % locals())
+
+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+
+ 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+
+ 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+
+ 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+
+ fake_cc\.py: %(sig_re)s \d+ \d+
+ %(sig_re)s \[.*\]
+""" % locals())
+
+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+
+ 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+
+ 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+
+""" % locals())
+
+#test.run_sconsign(arguments = "-i -v sub2/.sconsign",
+# stdout = r"""hello.c: %(sig_re)s \d+ \d+
+#hello.exe: %(sig_re)s \d+ \d+
+# implicit:
+# hello.obj: %(sig_re)s \d+ \d+
+#hello.obj: %(sig_re)s \d+ \d+
+# implicit:
+# hello.c: %(sig_re)s \d+ \d+
+# inc1.h: %(sig_re)s \d+ \d+
+# inc2.h: %(sig_re)s \d+ \d+
+#""" % locals())
+
+test.run_sconsign(arguments = "-e hello.obj sub2/.sconsign sub1/.sconsign",
+ stdout = r"""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+
+ 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+
+ fake_cc\.py: %(sig_re)s \d+ \d+
+ %(sig_re)s \[.*\]
+""" % locals())
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: