Add a decent error message for corrupted .sconsign files (Bug 579666). (Anthony...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 5 Aug 2002 04:05:13 +0000 (04:05 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Mon, 5 Aug 2002 04:05:13 +0000 (04:05 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@428 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Script/__init__.py
src/engine/SCons/Sig/__init__.py
src/engine/SCons/Warnings.py
test/sconsign.py

index 30f8eb958c1a3a0658d8d9e85c384f35b071640d..6e24752d4defef8fb0bc4e6673268613b14e24be 100644 (file)
@@ -20,6 +20,8 @@ RELEASE 0.09 -
 
  - Make -U be case insensitive on Win32 systems.
 
+ - Issue a warning and continue when finding a corrupt .sconsign file.
+
 
 
 RELEASE 0.08 - Mon, 15 Jul 2002 12:08:51 -0500
index a00c7347d84a59c3b535f5ba7a9acac63d2ee417..bce17ba8904110ce11212280e97fbe1b2051b2a6 100644 (file)
@@ -865,6 +865,7 @@ def _main():
     # 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']),
index 7739aad7685028f0c27987643551739bf0725d19..b6a5c25fe42958ceb389a81b48411fd43057da52 100644 (file)
@@ -34,6 +34,7 @@ import os.path
 import string
 import SCons.Node
 import time
+import SCons.Warnings
 
 #XXX Get rid of the global array so this becomes re-entrant.
 sig_files = []
@@ -131,9 +132,14 @@ class SConsignFile:
             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)
 
index 5ba3aec3dadec63ec3b555ef0308582133f2f54e..bf18ba5a23af1c5c99bbee49354c1d0652b0239b 100644 (file)
@@ -44,6 +44,9 @@ class DeprecatedWarning(Warning):
 class DependencyWarning(Warning):
     pass
 
+class CorruptSConsignWarning(Warning):
+    pass
+
 _warningAsException = 0
 
 # The below is a list of 2-tuples.  The first element is a class object.
index 76fa355f8aceb909153727fecd69e874b3193d3a..57906af42a04bd82d889b8dc1e231188c2fbe8be 100644 (file)
@@ -26,8 +26,9 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import os
 import TestSCons
+import TestCmd
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match = TestCmd.match_re)
 
 test.subdir('sub1', 'sub2', 'sub3')
 
@@ -70,4 +71,33 @@ test.fail_test(test.read(sub2__sconsign) == "")
 
 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()