diff options
author | Steven Knight <knight@baldmt.com> | 2002-08-05 04:05:13 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2002-08-05 04:05:13 (GMT) |
commit | 30e7b8895dff89607f971face4e68fa8f38bfcb3 (patch) | |
tree | b10dbfe3f0b036f8b731bc5556d91e4bac43f881 | |
parent | 711e5cdfe154688814d7f493cc2c832c79fd1014 (diff) | |
download | SCons-30e7b8895dff89607f971face4e68fa8f38bfcb3.zip SCons-30e7b8895dff89607f971face4e68fa8f38bfcb3.tar.gz SCons-30e7b8895dff89607f971face4e68fa8f38bfcb3.tar.bz2 |
Add a decent error message for corrupted .sconsign files (Bug 579666). (Anthony Roach)
-rw-r--r-- | src/CHANGES.txt | 2 | ||||
-rw-r--r-- | src/engine/SCons/Script/__init__.py | 1 | ||||
-rw-r--r-- | src/engine/SCons/Sig/__init__.py | 12 | ||||
-rw-r--r-- | src/engine/SCons/Warnings.py | 3 | ||||
-rw-r--r-- | test/sconsign.py | 32 |
5 files changed, 46 insertions, 4 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 30f8eb9..6e24752 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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 diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index a00c734..bce17ba 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -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']), diff --git a/src/engine/SCons/Sig/__init__.py b/src/engine/SCons/Sig/__init__.py index 7739aad..b6a5c25 100644 --- a/src/engine/SCons/Sig/__init__.py +++ b/src/engine/SCons/Sig/__init__.py @@ -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) diff --git a/src/engine/SCons/Warnings.py b/src/engine/SCons/Warnings.py index 5ba3aec..bf18ba5 100644 --- a/src/engine/SCons/Warnings.py +++ b/src/engine/SCons/Warnings.py @@ -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. diff --git a/test/sconsign.py b/test/sconsign.py index 76fa355..57906af 100644 --- a/test/sconsign.py +++ b/test/sconsign.py @@ -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() |