diff options
| author | Steven Knight <knight@baldmt.com> | 2005-01-21 12:00:30 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2005-01-21 12:00:30 (GMT) |
| commit | 9925c571d1b4efcfba5838bf93971f98f34cc17d (patch) | |
| tree | 43dc31c3adcc426161d7c53c9a60cc9ec1d5ac35 /src/engine/SCons/Scanner/ScannerTests.py | |
| parent | 7f820e64f11a4f047685713c163ca5fee35e676c (diff) | |
| download | SCons-9925c571d1b4efcfba5838bf93971f98f34cc17d.zip SCons-9925c571d1b4efcfba5838bf93971f98f34cc17d.tar.gz SCons-9925c571d1b4efcfba5838bf93971f98f34cc17d.tar.bz2 | |
Regain lost performance improvements by using paths instead of targets for scanner calls and re-using Binder objects for identical paths.
Diffstat (limited to 'src/engine/SCons/Scanner/ScannerTests.py')
| -rw-r--r-- | src/engine/SCons/Scanner/ScannerTests.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/engine/SCons/Scanner/ScannerTests.py b/src/engine/SCons/Scanner/ScannerTests.py index 493a330..c38dc84 100644 --- a/src/engine/SCons/Scanner/ScannerTests.py +++ b/src/engine/SCons/Scanner/ScannerTests.py @@ -42,7 +42,7 @@ class DummyEnvironment(UserDict.UserDict): if strSubst[0] == '$': return [self.data[strSubst[1:]]] return [[strSubst]] - def subst_path(self, path, target=None): + def subst_path(self, path, target=None, source=None): if type(path) != type([]): path = [path] return map(self.subst, path) @@ -124,6 +124,25 @@ class BaseTestCase(unittest.TestCase): else: self.failIf(hasattr(self, "arg"), "an argument was given when it shouldn't have been") + def test_path(self): + """Test the Scanner.Base path() method""" + def pf(env, cwd, target, source, argument=None): + return "pf: %s %s %s %s %s" % \ + (env.VARIABLE, cwd, target[0], source[0], argument) + + env = DummyEnvironment() + env.VARIABLE = 'v1' + target = DummyNode('target') + source = DummyNode('source') + + s = SCons.Scanner.Base(self.func, path_function=pf) + p = s.path(env, 'here', [target], [source]) + assert p == "pf: v1 here target source None", p + + s = SCons.Scanner.Base(self.func, path_function=pf, argument="xyz") + p = s.path(env, 'here', [target], [source]) + assert p == "pf: v1 here target source xyz", p + def test_positional(self): """Test the Scanner.Base class using positional arguments""" s = SCons.Scanner.Base(self.func, "Pos") |
