diff options
author | Steven Knight <knight@baldmt.com> | 2004-09-26 06:12:36 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-09-26 06:12:36 (GMT) |
commit | 3b0b62cb7fa049ae5d87268f4d2e6a8832166d9e (patch) | |
tree | 933957ff679497cef5c97cacacf2b6a461355e29 /src/engine | |
parent | 07d2524f1b230ffc11d43d3261418a767803e198 (diff) | |
download | SCons-3b0b62cb7fa049ae5d87268f4d2e6a8832166d9e.zip SCons-3b0b62cb7fa049ae5d87268f4d2e6a8832166d9e.tar.gz SCons-3b0b62cb7fa049ae5d87268f4d2e6a8832166d9e.tar.bz2 |
More robust Scanner comparisons. (Kevin Quick)
Diffstat (limited to 'src/engine')
-rw-r--r-- | src/engine/SCons/BuilderTests.py | 17 | ||||
-rw-r--r-- | src/engine/SCons/Scanner/ScannerTests.py | 5 | ||||
-rw-r--r-- | src/engine/SCons/Scanner/__init__.py | 6 |
3 files changed, 27 insertions, 1 deletions
diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index 53a5628..a67d22a 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -864,6 +864,23 @@ class BuilderTestCase(unittest.TestCase): assert tgt.target_scanner == tscan, tgt.target_scanner assert tgt.source_scanner == tscan, tgt.source_scanner + def test_actual_scanner(self): + """Test usage of actual Scanner objects.""" + + import SCons.Scanner + + def func(self): + pass + + scanner = SCons.Scanner.Scanner(func, name='fooscan') + + b1 = SCons.Builder.Builder(action='bld', target_scanner=scanner) + b2 = SCons.Builder.Builder(action='bld', target_scanner=scanner) + b3 = SCons.Builder.Builder(action='bld') + + assert b1 == b2 + assert b1 != b3 + def test_src_scanner(slf): """Testing ability to set a source file scanner through a builder.""" class TestScanner: diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py index 2115c70..d4ae05b 100644 --- a/src/engine/SCons/Scanner/ScannerTests.py +++ b/src/engine/SCons/Scanner/ScannerTests.py @@ -172,6 +172,11 @@ class BaseTestCase(unittest.TestCase): env.VARIABLE = "i4" self.test(s, env, DummyNode('i4.cpp'), ['i4.h', 'i4.hpp'], arg) + def test___cmp__(self): + """Test the Scanner.Base class __cmp__() method""" + s = SCons.Scanner.Base(self.func, "Cmp") + assert cmp(s, None) + def test_hash(self): """Test the Scanner.Base class __hash__() method""" s = SCons.Scanner.Base(self.func, "Hash") diff --git a/src/engine/SCons/Scanner/__init__.py b/src/engine/SCons/Scanner/__init__.py index f1b85e8..68b56bb 100644 --- a/src/engine/SCons/Scanner/__init__.py +++ b/src/engine/SCons/Scanner/__init__.py @@ -217,7 +217,11 @@ class Base: return nodes def __cmp__(self, other): - return cmp(self.__dict__, other.__dict__) + try: + return cmp(self.__dict__, other.__dict__) + except AttributeError: + # other probably doesn't have a __dict__ + return cmp(self.__dict__, other) def __hash__(self): return id(self) |