Skip to content

Inline expectations: Ignore results in files outside the source dir - #22592

Open
hvitved wants to merge 2 commits into
github:mainfrom
hvitved:inline-expectations-relative-restriction
Open

hvitved wants to merge 2 commits into
github:mainfrom
hvitved:inline-expectations-relative-restriction

Conversation

@hvitved

@hvitved hvitved commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Needed for #22593, where instead of restricting each inline expectation test to elements from source, it makes sense to do it centrally in the shared library.

@github-actions github-actions Bot added C# JS C++ Java Python Go Ruby QL-for-QL Rust Pull requests that update Rust code Swift Actions Analysis of GitHub Actions labels Sep 16, 2026
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Sep 16, 2026
@hvitved
hvitved marked this pull request as ready for review September 16, 2026 13:02
Copilot AI balanced review requested due to automatic review settings September 16, 2026 13:02
@hvitved
hvitved requested review from a team as code owners September 16, 2026 13:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new API leaves Kotlin implementations uncompilable, and external-file results can still bypass filtering.

Get a fresh assessment by requesting another Copilot review.

Review tier: Lite (auto)
Findings: 1 High severity

Note

Copilot is running an experiment and ran this review at Lite.

Open (1)
What changed in this PR

This PR centralizes source-directory filtering for inline expectation results by adding a shared getRelativeUrl contract.

Changes:

  • Adds shared source-location filtering.
  • Moves URL mapping into language-specific implementations.
  • Simplifies query wiring and updates Actions support.

Unresolved findings:

  • Critical (3 votes): Kotlin implementations lack the new required getRelativeUrl member and will fail to compile.
  • Moderate (1 vote): TestPostProcessing can still report results from external files.
File Summary
unified/​ql/​lib/​utils/​test/​internal/​InlineExpectationsTestImpl.qll Adds Unified URL mapping.
unified/​ql/​lib/​utils/​test/​InlineExpectationsTestQuery.ql Uses the shared adapter.
swift/​ql/​lib/​utils/​test/​internal/​InlineExpectationsTestImpl.qll Adds Swift URL mapping.
swift/​ql/​lib/​utils/​test/​InlineExpectationsTestQuery.ql Uses the shared adapter.
shared/​util/​codeql/​util/​test/​InlineExpectationsTest.qll Adds the shared contract and filtering.
rust/​ql/​lib/​utils/​test/​internal/​InlineExpectationsTestImpl.qll Adds Rust URL mapping.
rust/​ql/​lib/​utils/​test/​InlineExpectationsTestQuery.ql Uses the shared adapter.
ruby/​ql/​lib/​utils/​test/​internal/​InlineExpectationsTestImpl.qll Adds Ruby URL mapping.
ruby/​ql/​lib/​utils/​test/​InlineExpectationsTestQuery.ql Uses the shared adapter.
ql/​ql/​src/​utils/​test/​internal/​InlineExpectationsTestImpl.qll Adds QL URL mapping.
ql/​ql/​src/​utils/​test/​InlineExpectationsTestQuery.ql Uses the shared adapter.
python/​ql/​lib/​utils/​test/​internal/​InlineExpectationsTestImpl.qll Adds Python URL mapping.
python/​ql/​lib/​utils/​test/​InlineExpectationsTestQuery.ql Uses the shared adapter.
javascript/​ql/​lib/​utils/​test/​internal/​InlineExpectationsTestImpl.qll Adds JavaScript URL mapping.
javascript/​ql/​lib/​utils/​test/​InlineExpectationsTestQuery.ql Uses the shared adapter.
java/​ql/​lib/​utils/​test/​internal/​InlineExpectationsTestImpl.qll Adds Java URL mapping.
java/​ql/​lib/​utils/​test/​InlineExpectationsTestQuery.ql Uses the shared adapter.
go/​ql/​lib/​utils/​test/​internal/​InlineExpectationsTestImpl.qll Adds Go URL mapping.
go/​ql/​lib/​utils/​test/​InlineExpectationsTestQuery.ql Uses the shared adapter.
csharp/​ql/​lib/​utils/​test/​internal/​InlineExpectationsTestImpl.qll Adds C# URL mapping.
csharp/​ql/​lib/​utils/​test/​InlineExpectationsTestQuery.ql Uses the shared adapter.
cpp/​ql/​lib/​utils/​test/​internal/​InlineExpectationsTestImpl.qll Adds C++ URL mapping.
cpp/​ql/​lib/​utils/​test/​InlineExpectationsTestQuery.ql Uses the shared adapter.
actions/​ql/​test/​utils/​ActionsInlineExpectationsTestQuery.ql Adapts the Actions test wiring.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread shared/util/codeql/util/test/InlineExpectationsTest.qll
@hvitved
hvitved force-pushed the inline-expectations-relative-restriction branch from 4958c7f to 22cdf94 Compare September 16, 2026 13:25
@hvitved

hvitved commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author
Rerun has been triggered: 1 restarted 🚀

@hvitved
hvitved force-pushed the inline-expectations-relative-restriction branch from 22cdf94 to 7c8d3af Compare September 16, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Actions Analysis of GitHub Actions C# C++ Go Java JS Kotlin no-change-note-required This PR does not need a change note Python QL-for-QL Ruby Rust Pull requests that update Rust code Swift

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants