Fix bug when RelatedLocation was used with a query ID

This commit is contained in:
Asger F
2025-02-25 14:52:32 +01:00
parent 5f2e5ab8c3
commit bb8f4529bf
3 changed files with 18 additions and 2 deletions

View File

@@ -11,4 +11,4 @@ testFailures
| InlineTests.cs:37:28:37:38 | // ... | Missing result: Source |
| InlineTests.cs:38:24:38:32 | // ... | Missing result: Sink |
| InlineTests.cs:39:33:39:42 | // ... | Missing result: Alert |
| InlineTests.cs:93:34:93:90 | // ... | Missing result: RelatedLocation[path-problem-query-with-related-loc] |
| InlineTests.cs:99:19:99:27 | "Related" | Unexpected result: RelatedLocation |

View File

@@ -0,0 +1,9 @@
#select
| InlineTests.cs:22:13:22:21 | "Alert:1" | This is a problem with $@ | InlineTests.cs:21:23:21:31 | "Related" | a related location |
| InlineTests.cs:26:13:26:21 | "Alert:1" | This is a problem with $@ | InlineTests.cs:25:19:25:27 | "Related" | a related location |
testFailures
| InlineTests.cs:6:26:6:35 | // ... | Missing result: Alert |
| InlineTests.cs:12:34:12:43 | // ... | Missing result: Alert |
| InlineTests.cs:25:19:25:27 | "Related" | Unexpected result: RelatedLocation |
| InlineTests.cs:34:30:34:39 | // ... | Missing result: Alert |
| InlineTests.cs:39:33:39:42 | // ... | Missing result: Alert |

View File

@@ -892,12 +892,19 @@ module TestPostProcessing {
not hasPathProblemSink(row, location, _, _)
}
private predicate shouldReportRelatedLocations() {
exists(string tag |
hasExpectationWithValue(tag, _) and
PathProblemSourceTestInput::tagMatches(tag, "RelatedLocation")
)
}
private predicate hasRelatedLocation(
int row, TestLocation location, string element, string tag
) {
getQueryKind() = ["problem", "path-problem"] and
location = getRelatedLocation(row, _, element) and
hasExpectationWithValue("RelatedLocation", _) and
shouldReportRelatedLocations() and
tag = "RelatedLocation" and
not hasAlert(row, location, _, _) and
not hasPathProblemSource(row, location, _, _, _) and