diff options
author | William Deegan <bill@baddogconsulting.com> | 2020-09-19 18:50:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-19 18:50:11 (GMT) |
commit | d41c432be2a38d76df85933e624de59fae35ace3 (patch) | |
tree | c71eb3c5dd706ae2250d56a19b94cd53166ebdd3 /SCons | |
parent | e226031d66b0b0f9259d1eb50b3c0ec78aba281a (diff) | |
parent | 7eaf5b4e54d5592e8849339a2df10be5b0d04ef2 (diff) | |
download | SCons-d41c432be2a38d76df85933e624de59fae35ace3.zip SCons-d41c432be2a38d76df85933e624de59fae35ace3.tar.gz SCons-d41c432be2a38d76df85933e624de59fae35ace3.tar.bz2 |
Merge pull request #3783 from mwichmann/better-tool-msg
Change error in case not-found Tool requested
Diffstat (limited to 'SCons')
-rw-r--r-- | SCons/EnvironmentTests.py | 8 | ||||
-rw-r--r-- | SCons/Platform/PlatformTests.py | 7 | ||||
-rw-r--r-- | SCons/Tool/ToolTests.py | 16 | ||||
-rw-r--r-- | SCons/Tool/__init__.py | 9 |
4 files changed, 22 insertions, 18 deletions
diff --git a/SCons/EnvironmentTests.py b/SCons/EnvironmentTests.py index d2db508..3a18969 100644 --- a/SCons/EnvironmentTests.py +++ b/SCons/EnvironmentTests.py @@ -2477,16 +2477,16 @@ f5: \ exc_caught = None try: env.Tool('does_not_exist') - except SCons.Errors.SConsEnvironmentError: + except SCons.Errors.UserError: exc_caught = 1 - assert exc_caught, "did not catch expected SConsEnvironmentError" + assert exc_caught, "did not catch expected UserError" exc_caught = None try: env.Tool('$NONE') - except SCons.Errors.SConsEnvironmentError: + except SCons.Errors.UserError: exc_caught = 1 - assert exc_caught, "did not catch expected SConsEnvironmentError" + assert exc_caught, "did not catch expected UserError" # Use a non-existent toolpath directory just to make sure we # can call Tool() with the keyword argument. diff --git a/SCons/Platform/PlatformTests.py b/SCons/Platform/PlatformTests.py index e065c3c..4186119 100644 --- a/SCons/Platform/PlatformTests.py +++ b/SCons/Platform/PlatformTests.py @@ -107,14 +107,13 @@ class PlatformTestCase(unittest.TestCase): p(env) assert env['PROGSUFFIX'] == '.exe', env assert env['LIBSUFFIX'] == '.lib', env - assert str + exc_caught = None try: p = SCons.Platform.Platform('_does_not_exist_') except SCons.Errors.UserError: - pass - else: # TODO pylint E0704: bare raise not inside except - raise + exc_caught = 1 + assert exc_caught, "did not catch expected UserError" env = Environment() SCons.Platform.Platform()(env) diff --git a/SCons/Tool/ToolTests.py b/SCons/Tool/ToolTests.py index 75a9454..b7c42b7 100644 --- a/SCons/Tool/ToolTests.py +++ b/SCons/Tool/ToolTests.py @@ -84,19 +84,21 @@ class ToolTestCase(unittest.TestCase): assert env['INCPREFIX'] == '-I', env['INCPREFIX'] assert env['TOOLS'] == ['g++'], env['TOOLS'] + exc_caught = None try: SCons.Tool.Tool() except TypeError: - pass - else: # TODO pylint E0704: bare raise not inside except - raise + exc_caught = 1 + assert exc_caught, "did not catch expected UserError" + exc_caught = None try: p = SCons.Tool.Tool('_does_not_exist_') - except SCons.Errors.SConsEnvironmentError: - pass - else: # TODO pylint E0704: bare raise not inside except - raise + except SCons.Errors.UserError as e: + exc_caught = 1 + # Old msg was Python-style "No tool named", check for new msg: + assert "No tool module" in str(e), e + assert exc_caught, "did not catch expected UserError" def test_pathfind(self): diff --git a/SCons/Tool/__init__.py b/SCons/Tool/__init__.py index 24fb9d2..0c7afb8 100644 --- a/SCons/Tool/__init__.py +++ b/SCons/Tool/__init__.py @@ -184,13 +184,16 @@ class Tool: if debug: sys.stderr.write("Spec Found? .%s :%s\n" % (self.name, spec)) if spec is None: - error_string = "No module named %s" % self.name - raise SCons.Errors.SConsEnvironmentError(error_string) + sconstools = os.path.normpath(sys.modules['SCons.Tool'].__path__[0]) + if self.toolpath: + sconstools = ", ".join(self.toolpath) + ", " + sconstools + error_string = "No tool module '%s' found in %s" % (self.name, sconstools) + raise SCons.Errors.UserError(error_string) module = importlib.util.module_from_spec(spec) if module is None: if debug: print("MODULE IS NONE:%s" % self.name) - error_string = "No module named %s" % self.name + error_string = "Tool module '%s' failed import" % self.name raise SCons.Errors.SConsEnvironmentError(error_string) # Don't reload a tool we already loaded. |