Skip to content

Commit ce8912d

Browse files
committed
Test: Handle 'problems' result set as an alias for '#select'
1 parent 303b11e commit ce8912d

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,9 @@ private string expectationPattern() {
583583
)
584584
}
585585

586+
/** Gets the string `#select` or `problems`, which are equivalent result sets for a `problem` or `path-problem` query. */
587+
private string mainResultSet() { result = ["#select", "problems"] }
588+
586589
/**
587590
* Provides logic for creating a `@kind test-postprocess` query that checks
588591
* inline test expectations using `$ Alert` markers.
@@ -650,8 +653,8 @@ module TestPostProcessing {
650653
*/
651654
private string getSourceTag(int row) {
652655
getQueryKind() = "path-problem" and
653-
exists(string loc | queryResults("#select", row, 2, loc) |
654-
if queryResults("#select", row, 0, loc) then result = "Alert" else result = "Source"
656+
exists(string loc | queryResults(mainResultSet(), row, 2, loc) |
657+
if queryResults(mainResultSet(), row, 0, loc) then result = "Alert" else result = "Source"
655658
)
656659
}
657660

@@ -663,8 +666,8 @@ module TestPostProcessing {
663666
*/
664667
private string getSinkTag(int row) {
665668
getQueryKind() = "path-problem" and
666-
exists(string loc | queryResults("#select", row, 4, loc) |
667-
if queryResults("#select", row, 0, loc) then result = "Alert" else result = "Sink"
669+
exists(string loc | queryResults(mainResultSet(), row, 4, loc) |
670+
if queryResults(mainResultSet(), row, 0, loc) then result = "Alert" else result = "Sink"
668671
)
669672
}
670673

@@ -717,8 +720,8 @@ module TestPostProcessing {
717720
) {
718721
getQueryKind() = "path-problem" and
719722
exists(string loc |
720-
queryResults("#select", row, 2, loc) and
721-
queryResults("#select", row, 3, element) and
723+
queryResults(mainResultSet(), row, 2, loc) and
724+
queryResults(mainResultSet(), row, 3, element) and
722725
tag = getSourceTag(row) and
723726
value = "" and
724727
Input2::getRelativeUrl(location) = loc
@@ -757,8 +760,8 @@ module TestPostProcessing {
757760
) {
758761
getQueryKind() = "path-problem" and
759762
exists(string loc |
760-
queryResults("#select", row, 4, loc) and
761-
queryResults("#select", row, 5, element) and
763+
queryResults(mainResultSet(), row, 4, loc) and
764+
queryResults(mainResultSet(), row, 5, element) and
762765
tag = getSinkTag(row) and
763766
Input2::getRelativeUrl(location) = loc
764767
)
@@ -767,8 +770,8 @@ module TestPostProcessing {
767770
private predicate hasAlert(int row, Input::Location location, string element, string tag) {
768771
getQueryKind() = ["problem", "path-problem"] and
769772
exists(string loc |
770-
queryResults("#select", row, 0, loc) and
771-
queryResults("#select", row, 2, element) and
773+
queryResults(mainResultSet(), row, 0, loc) and
774+
queryResults(mainResultSet(), row, 2, element) and
772775
tag = "Alert" and
773776
Input2::getRelativeUrl(location) = loc and
774777
not hasPathProblemSource(row, location, _, _, _) and

0 commit comments

Comments
 (0)