# Enable deprecated warnings by default.
SCons.Warnings._warningOut = _scons_internal_warning
SCons.Warnings.enableWarningClass(SCons.Warnings.DeprecatedWarning)
+ SCons.Warnings.enableWarningClass(SCons.Warnings.CorruptSConsignWarning)
try:
cmd_opts, t = getopt.getopt(string.split(os.environ['SCONSFLAGS']),
import string
import SCons.Node
import time
+import SCons.Warnings
#XXX Get rid of the global array so this becomes re-entrant.
sig_files = []
pass
else:
for line in file.readlines():
- filename, rest = map(string.strip, string.split(line, ":", 1))
- self.entries[filename] = SConsignEntry(self.module, rest)
-
+ try:
+ filename, rest = map(string.strip, string.split(line, ":", 1))
+ self.entries[filename] = SConsignEntry(self.module, rest)
+ except ValueError:
+ SCons.Warnings.warn(SCons.Warnings.CorruptSConsignWarning,
+ "Ignoring corrupt .sconsign file: %s"%self.sconsign)
+ self.entries = {}
+
global sig_files
sig_files.append(self)
import os
import TestSCons
+import TestCmd
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match = TestCmd.match_re)
test.subdir('sub1', 'sub2', 'sub3')
os.chmod(sub1__sconsign, 0666)
+test.write('SConstruct', """
+def build1(target, source, env):
+ print '%s->%s'%(str(source[0]), str(target[0]))
+ 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 = 'sub1/foo.out', source = 'foo.in')
+""")
+
+stderr = '''
+SCons warning: Ignoring corrupt .sconsign file: sub1..sconsign
+.*
+'''
+
+stdout = '''foo.in->sub1.foo.out
+'''
+
+test.write(sub1__sconsign, 'garbage')
+test.run(arguments = '.', stderr=stderr, stdout=stdout)
+
+test.write(sub1__sconsign, 'not:a:sconsign:file')
+test.run(arguments = '.', stderr=stderr, stdout=stdout)
+
+test.write(sub1__sconsign, '\0\0\0\0\0\0\0\0\0\0\0\0\0\0')
+test.run(arguments = '.', stderr=stderr, stdout=stdout)
+
+
test.pass_test()