Skip to content

Commit bb8f452

Browse files
committed
Fix bug when RelatedLocation was used with a query ID
1 parent 5f2e5ab commit bb8f452

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

csharp/ql/test/utils/inline-tests/PathProblemQueryRelatedLocs.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ testFailures
1111
| InlineTests.cs:37:28:37:38 | // ... | Missing result: Source |
1212
| InlineTests.cs:38:24:38:32 | // ... | Missing result: Sink |
1313
| InlineTests.cs:39:33:39:42 | // ... | Missing result: Alert |
14-
| InlineTests.cs:93:34:93:90 | // ... | Missing result: RelatedLocation[path-problem-query-with-related-loc] |
14+
| InlineTests.cs:99:19:99:27 | "Related" | Unexpected result: RelatedLocation |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#select
2+
| InlineTests.cs:22:13:22:21 | "Alert:1" | This is a problem with $@ | InlineTests.cs:21:23:21:31 | "Related" | a related location |
3+
| InlineTests.cs:26:13:26:21 | "Alert:1" | This is a problem with $@ | InlineTests.cs:25:19:25:27 | "Related" | a related location |
4+
testFailures
5+
| InlineTests.cs:6:26:6:35 | // ... | Missing result: Alert |
6+
| InlineTests.cs:12:34:12:43 | // ... | Missing result: Alert |
7+
| InlineTests.cs:25:19:25:27 | "Related" | Unexpected result: RelatedLocation |
8+
| InlineTests.cs:34:30:34:39 | // ... | Missing result: Alert |
9+
| InlineTests.cs:39:33:39:42 | // ... | Missing result: Alert |

shared/util/codeql/util/test/InlineExpectationsTest.qll

+8-1
Original file line numberDiff line numberDiff line change
@@ -892,12 +892,19 @@ module TestPostProcessing {
892892
not hasPathProblemSink(row, location, _, _)
893893
}
894894

895+
private predicate shouldReportRelatedLocations() {
896+
exists(string tag |
897+
hasExpectationWithValue(tag, _) and
898+
PathProblemSourceTestInput::tagMatches(tag, "RelatedLocation")
899+
)
900+
}
901+
895902
private predicate hasRelatedLocation(
896903
int row, TestLocation location, string element, string tag
897904
) {
898905
getQueryKind() = ["problem", "path-problem"] and
899906
location = getRelatedLocation(row, _, element) and
900-
hasExpectationWithValue("RelatedLocation", _) and
907+
shouldReportRelatedLocations() and
901908
tag = "RelatedLocation" and
902909
not hasAlert(row, location, _, _) and
903910
not hasPathProblemSource(row, location, _, _, _) and

0 commit comments

Comments
 (0)