Improve searching for TestingBuildParams using the output file

When searching for an TestingBuildParams this change will compare the
supplied path against the value returned by PathRelativeToTop() as well
as the String() and Rel() values. In the event that it cannot find the
file it also formats the available outputs, one per line with both rel
and path relative to top.

Bug: 182885307
Test: m nothing
Change-Id: Icbd37018b9a028abf37e27d1bea12a407316e031
This commit is contained in:
Paul Duffin
2021-03-22 11:34:57 +00:00
parent 0eda26b96b
commit 4e6e35c561

View File

@@ -585,7 +585,7 @@ func (b baseTestingComponent) maybeBuildParamsFromOutput(file string) (TestingBu
outputs = append(outputs, p.Output)
}
for _, f := range outputs {
if f.String() == file || f.Rel() == file {
if f.String() == file || f.Rel() == file || PathRelativeToTop(f) == file {
return b.newTestingBuildParams(p), nil
}
searchedOutputs = append(searchedOutputs, f.Rel())
@@ -597,8 +597,8 @@ func (b baseTestingComponent) maybeBuildParamsFromOutput(file string) (TestingBu
func (b baseTestingComponent) buildParamsFromOutput(file string) TestingBuildParams {
p, searchedOutputs := b.maybeBuildParamsFromOutput(file)
if p.Rule == nil {
panic(fmt.Errorf("couldn't find output %q.\nall outputs: %v",
file, searchedOutputs))
panic(fmt.Errorf("couldn't find output %q.\nall outputs:\n %s\n",
file, strings.Join(searchedOutputs, "\n ")))
}
return p
}