diff options
author | Daniel Moody <dmoody256@gmail.com> | 2020-05-17 19:41:12 (GMT) |
---|---|---|
committer | Daniel Moody <dmoody256@gmail.com> | 2020-05-17 19:41:12 (GMT) |
commit | cffd40b44080dcce1d238d037e026051eaa7a60b (patch) | |
tree | 31af770366e85ada4ab88ce62b4c5478480cca1e | |
parent | 52773da0faddc808056ffec34ed0112e2b42b5f7 (diff) | |
download | SCons-cffd40b44080dcce1d238d037e026051eaa7a60b.zip SCons-cffd40b44080dcce1d238d037e026051eaa7a60b.tar.gz SCons-cffd40b44080dcce1d238d037e026051eaa7a60b.tar.bz2 |
cover other type of subber and add test
-rw-r--r-- | SCons/Subst.py | 5 | ||||
-rw-r--r-- | test/Subst/TypeError.py | 28 |
2 files changed, 31 insertions, 2 deletions
diff --git a/SCons/Subst.py b/SCons/Subst.py index 29698d5..fbb89b3 100644 --- a/SCons/Subst.py +++ b/SCons/Subst.py @@ -591,12 +591,13 @@ class ListSubber(collections.UserList): self.substitute(a, lvars, 1) self.next_word() elif callable(s): - try: + if (s and + set(signature(s).parameters.keys()) == set(['target', 'source', 'env', 'for_signature'])): s = s(target=lvars['TARGETS'], source=lvars['SOURCES'], env=self.env, for_signature=(self.mode != SUBST_CMD)) - except TypeError: + else: # This probably indicates that it's a callable # object that doesn't match our calling arguments # (like an Action). diff --git a/test/Subst/TypeError.py b/test/Subst/TypeError.py index 628db2f..b288961 100644 --- a/test/Subst/TypeError.py +++ b/test/Subst/TypeError.py @@ -85,8 +85,36 @@ expect = expect_build % (r' \[foo\.bar\]', r'\$\{func\(1\)\}') test.run(status=2, stderr=expect) +# callable exceptions: +test.write('foo.c', """\ +#include <stdio.h> +#include <stdlib.h> +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("foo.c"); + exit (0); +} +""") + +test.write('SConstruct', """\ +class TestCallable(object): + def __init__(self, thing, makePathsRelative = True, debug = False): + pass + def __call__(self, target, source, env, for_signature): + raise TypeError("User callable exception") + +env = Environment() +env["TESTCLASS"] = TestCallable +env["CCCOM"] = "$CC $_CCCOMCOM $CCFLAGS -o ${TESTCLASS('$TARGET')} -c ${TESTCLASS('$SOURCES')}" + +env.Program(target='foo', source='foo.c') +""") +test.run(status=2, stderr=r'.*TypeError\s:\sUser\scallable\sexception.*') +print(test.stdout()) test.pass_test() # Local Variables: |