Rust qlref inline-expectation audit: no safe conversions in current non-inline set#21974
Draft
Copilot wants to merge 1 commit into
Draft
Rust qlref inline-expectation audit: no safe conversions in current non-inline set#21974Copilot wants to merge 1 commit into
Copilot wants to merge 1 commit into
Conversation
Copilot
AI
changed the title
[WIP] Update CodeQL tests to inline expectations
Rust qlref inline-expectation audit: no safe conversions in current non-inline set
Jun 11, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This updates the Rust conversion effort by applying the qlref-to-inline-expectation criteria to all remaining non-inline
.qlreftests in scope. The current set contains no standard@kind problem/@kind path-problemcandidates that can be converted without making tests misleading or noisy.Scope and outcome
.qlreffiles not yet usingutils/test/InlineExpectationsTestQuery.ql.Skip classification applied
@kind diagnostic/@kind metricquery families.InlineFlow.qlrefunder taint source suites, where expectations are framework-driven (hasTaintFlow) rather than cleanAlert/Source/Sinkmapping.Formatting and safety constraints preserved
.expectedfiles edited.Example of a currently skipped pattern (framework-specific inline flow expectations, not standard Alert/Source/Sink conversion target):
Original prompt
Follow these instructions for Rust.
qlref conversion instructions
Here’s the repeatable recipe for converting a CodeQL language’s
.qlreftests to inline expectation tests.Overall Workflow
cdinto the language folder.Run
grep -rL "InlineExpectationsTestQuery" --include="*.qlref".Ignore generated
.actualfiles,.testprojcopies, and other generated artifacts.For each
.qlref, resolve the referenced query and read its metadata.Classify each test before editing:
-
convert nowfor standard@kind problemand@kind path-problem-
skipfor anything else, with a short concrete reason.expectedfile before converting:- If it is empty and the query is a standard
problemorpath-problemquery, usually convert by adding the postprocessor only. No source comments are needed.- If it is non-empty, add inline expectation comments to the source files at the expected result locations, then add the postprocessor to the
.qlref.Keep the existing
.expectedfile. Do not edit generated expected files by hand, even when converting.Edit only source files and
.qlreffiles.Maintain a skip list for tests not converted, with exact paths and short reasons.
Do not make a PR.
.qlrefFormattingFor a single postprocessor, use the compact form:
If the
.qlrefalready has other postprocessors, use list form:If the original
.qlrefwas a plain single-line query reference, convert it toquery:form only when addingpostprocess:.Always preserve existing postprocessors.
Expectation Comments
Use the language’s supported inline comment syntax from its inline expectation implementation. Typical tags are:
For example, in Java or Kotlin:
For
problemqueries, addAlertat each expected result location.For
path-problemqueries, add:Alertat the alert location.Sourceat the source location, unless the source is on the same line as the alert.Sinkat the sink location when it is a distinct relevant location.Multi-line result locations should be annotated on the end line.
If more than one result is expected on the same line for the same query, just use a single tag in the comment, for example:
Only add comments to real source files that belong to the test. Do not annotate generated copies, shared vendored fixtures, or shared stubs unless that is clearly the right ownership boundary for the test.
Empty
.expectedFilesIf a
problemorpath-problemtest already has an empty.expectedfile, the default conversion is:Leave
.expecteduntouched.Add
postprocess: utils/test/InlineExpectationsTestQuery.qlto the.qlref.Add no source comments unless the test actually has expected results that are currently represented elsewhere.
This is common in zero-result tests.
Query Ids
Do not add
[query-id]by default.Only qualify tags when needed, usually when more than one inline expectation test in the same effective test folder or database can see the same source comments. Then use the query’s metadata id:
Apply this to
Alert,Source, andSinkonly for the comments that need disambiguation.If you add query ids in a shared folder, validate the owner queries for those comments as well, not just the query you were editing.
Good Skip Reasons
Skip, or revert to non-inline, when conversion would make the test misleading, brittle, or noisy. Common reasons:
The query is not
@kind problemor@kind path-problem.The query is a telemetry, metrics, table, definitions, diagnostic, extractor-information, stub-generation, or tool-specific query.
The test is an AST dump or similar structural output test, such as
PrintAst.The selected result text is inside a string literal, raw string, heredoc, text block, XML literal, or multiline literal and adding a comment changes the selected text.
The expected location is inside documentation syntax where adding a comment changes what the query reports, such as Javadoc tags.
The
.expectedoutput is nonstandard enough that mechanical conversion is risky.Results are in shared stubs, generated copies, vendored files, or synthetic/test-project paths where inline comments would pollute shared fixtures.
The alert, source, or sink locations are too dense or ambiguous to make the source understandable.
The language’s inline expectation implementation does not support the source file or comment style needed.
The query uses a special result kind or framework behavior, such as alert-...
Created from VS Code.