-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apply_fixes: Improve dependency discovery heuristic
Our old logic fails when multiple dependencies provide a header file with the same name at different paths. The new logic is robust against this due to looking for the full include path. Looking at the file name is now only a fallback used to resolve cases where include path manipulation makes a simple include path match impossible.
- Loading branch information
Showing
11 changed files
with
177 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...ing_dependency/test_suggest_missing_dep_based_on_fallback_logic_using_header_file_name.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from result import Result, Success | ||
from test_case import TestCaseBase | ||
|
||
|
||
class TestCase(TestCaseBase): | ||
@property | ||
def test_target(self) -> str: | ||
return "//:use_manipulated_bar" | ||
|
||
def execute_test_logic(self) -> Result: | ||
self._create_reports() | ||
self._run_automatic_fix(extra_args=["--fix-missing-deps"]) | ||
|
||
target_deps = self._get_target_attribute(target=self.test_target, attribute="deps") | ||
if (expected := {"//:manipulated_bar_provider", "//libs:manipulated_bar"}) != target_deps: | ||
return self._make_unexpected_deps_error(expected_deps=expected, actual_deps=target_deps) | ||
return Success() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// Show that multiple files 'foo.h' in the dependency graph are no issue | ||
#include "other_lib/foo.h" | ||
|
||
int doFoo() { | ||
return 1337; | ||
return doOtherFoo() + 1337; | ||
} |
7 changes: 7 additions & 0 deletions
7
test/apply_fixes/missing_dependency/workspace/other_lib/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# We use this library to prove that multiple header with the same name existing in the dependency is not a problem if | ||
# they are included with their full path | ||
cc_library( | ||
name = "other_lib", | ||
hdrs = ["foo.h"], | ||
visibility = ["//visibility:public"], | ||
) |
3 changes: 3 additions & 0 deletions
3
test/apply_fixes/missing_dependency/workspace/other_lib/foo.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
int doOtherFoo() { | ||
return 1234; | ||
} |
5 changes: 5 additions & 0 deletions
5
test/apply_fixes/missing_dependency/workspace/use_manipulated_bar.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "new/path/sub/bar.h" | ||
|
||
int useBar() { | ||
return doBar(); | ||
} |