diff options
| author | Steven Knight <knight@baldmt.com> | 2003-01-06 18:42:37 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2003-01-06 18:42:37 (GMT) |
| commit | 7fbd5909a526fc1ad282c7e701b0f7832af2e3ed (patch) | |
| tree | 04f622a7b8fdab4ca337f20eced35b4d2699beb6 /src/engine/SCons/Node/FSTests.py | |
| parent | 6702e9dce5182eaa012da9dc511fcf85cf205049 (diff) | |
| download | SCons-7fbd5909a526fc1ad282c7e701b0f7832af2e3ed.zip SCons-7fbd5909a526fc1ad282c7e701b0f7832af2e3ed.tar.gz SCons-7fbd5909a526fc1ad282c7e701b0f7832af2e3ed.tar.bz2 | |
Refactor the Scanner interface to eliminate unnecessary scanning and make it easier to write efficient scanners.
Diffstat (limited to 'src/engine/SCons/Node/FSTests.py')
| -rw-r--r-- | src/engine/SCons/Node/FSTests.py | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index a624d97..e23178c 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -69,7 +69,9 @@ class Scanner: global scanner_count scanner_count = scanner_count + 1 self.hash = scanner_count - def scan(self, node, env, target): + def path(self, env, target): + return () + def __call__(self, node, env, path): return [node] def __hash__(self): return self.hash @@ -669,6 +671,35 @@ class FSTestCase(unittest.TestCase): f1.store_implicit() assert f1.get_stored_implicit()[0] == os.path.join("d1", "f1") + # Test underlying scanning functionality in get_implicit_deps() + env = Environment() + f12 = fs.File("f12") + t1 = fs.File("t1") + + deps = f12.get_implicit_deps(env, None, t1) + assert deps == [], deps + + class MyScanner(Scanner): + call_count = 0 + def __call__(self, node, env, path): + self.call_count = self.call_count + 1 + return [node] + s = MyScanner() + + deps = f12.get_implicit_deps(env, s, t1) + assert deps == [f12], deps + assert s.call_count == 1, s.call_count + + deps = f12.get_implicit_deps(env, s, t1) + assert deps == [f12], deps + assert s.call_count == 1, s.call_count + + f12.built() + + deps = f12.get_implicit_deps(env, s, t1) + assert deps == [f12], deps + assert s.call_count == 2, s.call_count + # Test building a file whose directory is not there yet... f1 = fs.File(test.workpath("foo/bar/baz/ack")) assert not f1.dir.exists() |
