From 235d9b184dcc4ceb49f6fe952927c59a14303274 Mon Sep 17 00:00:00 2001 From: "Morten V. Pedersen" Date: Thu, 22 Jun 2023 23:01:19 +0200 Subject: [PATCH] Better error (#132) Minor: Add better error messages for mismatched dependencies. --- NEWS.rst | 1 + src/wurf/dependency_manager.py | 12 ++++++---- test/requirements.in | 7 +++--- test/requirements.txt | 44 +++++++++++++--------------------- wscript | 2 +- 5 files changed, 30 insertions(+), 36 deletions(-) diff --git a/NEWS.rst b/NEWS.rst index 28b21b3c..e16db8fb 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -6,6 +6,7 @@ of every change, see the Git log. Latest ------ +* Minor: Add better error messages for mismatched dependencies. * Minor: Recursively pull submodules * Minor: Adding ensure_build function to Waf's Context object. * Minor: Added a pip_compile helper function on Waf's Context object. diff --git a/src/wurf/dependency_manager.py b/src/wurf/dependency_manager.py index 82029dfe..2c79e4c8 100644 --- a/src/wurf/dependency_manager.py +++ b/src/wurf/dependency_manager.py @@ -110,6 +110,7 @@ def add_dependency(self, **kwargs): self.dependency_cache[dependency.name] = { "path": path, "recurse": dependency.recurse, + "added_by": self.ctx.path.abspath(), } def __skip_dependency(self, dependency): @@ -149,11 +150,14 @@ def __skip_dependency(self, dependency): if seen_dependency.sha1 != dependency.sha1: + current = self.ctx.path.abspath() + added_by = self.dependency_cache[dependency.name]["added_by"] + raise WurfError( - "SHA1 mismatch when adding:\n{}\n" - "the previous definition was:\n{}".format( - dependency, seen_dependency - ) + f"Adding {dependency.name} in {current}:\n" + f"First added by {added_by}:\n" + f"SHA1 mismatch:\n{dependency}\n" + f"the previous definition was:\n{seen_dependency}" ) # If the current dependency is non-optional and we have already diff --git a/test/requirements.in b/test/requirements.in index 15e785a5..e658aad3 100644 --- a/test/requirements.in +++ b/test/requirements.in @@ -1,6 +1,7 @@ # Pin pytest since it does not support Python 3.6 which we still use in some # some places -pytest==7.0.1 +#pytest#==7.0.1 +pytest mock vcrpy pytest-testdirectory @@ -11,5 +12,5 @@ schema # Pin dependencies of our dependencies since they dropped support # for python 3.6 which we still use in some places. Try removing this from time # to time :) -multidict==5.2.0 -tomli==1.2.3 \ No newline at end of file +#multidict==5.2.0 +#tomli==1.2.3 \ No newline at end of file diff --git a/test/requirements.txt b/test/requirements.txt index 944d3250..fc28a3bf 100644 --- a/test/requirements.txt +++ b/test/requirements.txt @@ -1,40 +1,32 @@ # -# This file is autogenerated by pip-compile with python 3.9 -# To update, run: +# This file is autogenerated by pip-compile with Python 3.11 +# by the following command: # # pip-compile --output-file=test/requirements.txt test/requirements.in # -attrs==21.4.0 - # via pytest contextlib2==21.6.0 # via schema -idna==3.3 +idna==3.4 # via yarl -iniconfig==1.1.1 +iniconfig==2.0.0 # via pytest -mock==4.0.3 +mock==5.0.2 # via -r test/requirements.in -multidict==5.2.0 - # via - # -r test/requirements.in - # yarl -packaging==21.3 - # via pytest -pluggy==1.0.0 +multidict==6.0.4 + # via yarl +packaging==23.1 # via pytest -py==1.11.0 +pluggy==1.2.0 # via pytest -pycodestyle==2.8.0 +pycodestyle==2.10.0 # via -r test/requirements.in -pyflakes==2.4.0 +pyflakes==3.0.1 # via -r test/requirements.in -pyparsing==3.0.7 - # via packaging -pytest==7.0.1 +pytest==7.3.2 # via # -r test/requirements.in # pytest-testdirectory -pytest-testdirectory==4.0.0 +pytest-testdirectory==5.0.0 # via -r test/requirements.in pyyaml==6.0 # via vcrpy @@ -42,13 +34,9 @@ schema==0.7.5 # via -r test/requirements.in six==1.16.0 # via vcrpy -tomli==1.2.3 - # via - # -r test/requirements.in - # pytest -vcrpy==4.1.1 +vcrpy==4.3.1 # via -r test/requirements.in -wrapt==1.14.0 +wrapt==1.15.0 # via vcrpy -yarl==1.7.2 +yarl==1.9.2 # via vcrpy diff --git a/wscript b/wscript index deea6abb..8981b17d 100644 --- a/wscript +++ b/wscript @@ -96,7 +96,7 @@ def _build_waf_binary(bld): # Run with ./waf --zones wurf to see the print waflib.Logs.debug("wurf: tools_dir={}".format(tools_dir)) - waf_extras = ["clang_compilation_database"] + waf_extras = ["clang_compilation_database", "c_dumbpreproc"] # Get the absolute path to all the tools (passed as input to the task) tools = ",".join(tools_dir + waf_extras)