Skip to content

Add Windows integration tests showing that subst is handled inconsistently#22087

Merged
jketema merged 2 commits into
github:mainfrom
jketema:subst
Jul 1, 2026
Merged

Add Windows integration tests showing that subst is handled inconsistently#22087
jketema merged 2 commits into
github:mainfrom
jketema:subst

Conversation

@jketema

@jketema jketema commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

This shows that we do not consistently handle this across the CLI and the various extractors. All tests are: extract a file, check if the extracted file is relative to the source root, where the source root is a subst drive.

@github-actions github-actions Bot added C# JS Java Python Go Ruby Rust Pull requests that update Rust code labels Jun 29, 2026
@jketema jketema force-pushed the subst branch 3 times, most recently from 3c83d27 to 8e05251 Compare June 29, 2026 15:31
@jketema jketema changed the title Add Windows integration tests showing that subst is handled inconsistently Add Windows integration tests showing that subst is handled inconsistently Jun 29, 2026
@jketema jketema marked this pull request as ready for review June 29, 2026 15:55
Copilot AI review requested due to automatic review settings June 29, 2026 15:55
@jketema jketema requested review from a team as code owners June 29, 2026 15:55

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.

Pull request overview

Adds new Windows-only integration tests across multiple language packs to demonstrate inconsistent handling of subst-mapped source roots when extracting files and evaluating whether file paths are treated as relative to the source root.

Changes:

  • Introduce new subst integration-test directories for Rust, Ruby, Python, JavaScript, Go, Java/Kotlin, and C#.
  • For each test: create a database with source_root on a subst drive, then run a small query and compare .expected results to show (in)consistencies.
  • Add minimal source files per language to drive extraction on Windows.
Show a summary per file
File Description
rust/ql/integration-tests/subst/test.py Windows integration test that creates a Rust DB with a subst-drive source root.
rust/ql/integration-tests/subst/file.ql Query selecting files and whether a relative path exists (test oracle).
rust/ql/integration-tests/subst/file.expected Expected results for Rust extraction under subst.
rust/ql/integration-tests/subst/code/test.rs Minimal Rust source for extraction.
ruby/ql/integration-tests/subst/test.py Windows integration test that creates a Ruby DB with a subst-drive source root.
ruby/ql/integration-tests/subst/file.ql Query selecting files and whether a relative path exists (test oracle).
ruby/ql/integration-tests/subst/file.expected Expected results for Ruby extraction under subst.
ruby/ql/integration-tests/subst/code/test.rb Minimal Ruby source for extraction.
python/ql/integration-tests/subst/test.py Windows integration test that creates a Python DB with a subst-drive source root.
python/ql/integration-tests/subst/file.ql Query selecting files and whether a relative path exists (test oracle).
python/ql/integration-tests/subst/file.expected Expected results for Python extraction under subst.
python/ql/integration-tests/subst/code/main.py Minimal Python source for extraction.
javascript/ql/integration-tests/subst/test.py Windows integration test that creates a JavaScript DB with a subst-drive source root.
javascript/ql/integration-tests/subst/file.ql Query selecting files and whether a relative path exists (test oracle).
javascript/ql/integration-tests/subst/file.expected Expected results for JavaScript extraction under subst.
javascript/ql/integration-tests/subst/code/test.ts Minimal TypeScript source for extraction.
javascript/ql/integration-tests/subst/code/main.js Minimal JavaScript source for extraction.
java/ql/integration-tests/java/subst/test.py Windows integration test that creates a Java/Kotlin DB with a subst-drive source root.
java/ql/integration-tests/java/subst/file.ql Query selecting files and whether a relative path exists (test oracle).
java/ql/integration-tests/java/subst/file.expected Expected results for Java/Kotlin extraction under subst.
java/ql/integration-tests/java/subst/code/test2.kt Minimal Kotlin source for extraction.
java/ql/integration-tests/java/subst/code/test1.java Minimal Java source for extraction.
go/ql/integration-tests/subst/test.py Windows integration test that creates a Go DB with a subst-drive source root.
go/ql/integration-tests/subst/file.ql Query selecting files and whether a relative path exists (test oracle).
go/ql/integration-tests/subst/file.expected Expected results for Go extraction under subst.
go/ql/integration-tests/subst/code/main.go Minimal Go source for extraction.
csharp/ql/integration-tests/windows/subst/test.py Windows integration test that creates a C# DB with a subst-drive source root.
csharp/ql/integration-tests/windows/subst/file.ql Query selecting files and whether a relative path exists (test oracle).
csharp/ql/integration-tests/windows/subst/file.expected Expected results for C# extraction under subst.
csharp/ql/integration-tests/windows/subst/code/Program.cs Minimal C# program used for extraction/build.
csharp/ql/integration-tests/windows/subst/code/global.json .NET SDK pin for the test project.
csharp/ql/integration-tests/windows/subst/code/dotnet_build.csproj Minimal .NET project configuration for extraction/build.

Review details

  • Files reviewed: 32/32 changed files
  • Comments generated: 1
  • Review effort level: Low

@@ -0,0 +1,4 @@
class Program

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

IdrissRio
IdrissRio previously approved these changes Jul 1, 2026

@IdrissRio IdrissRio 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.

Suggestion: It might be worth adding addd comment explaining that some of the .expected files intentionally capture the current, inconsistent behavior. Otherwise, when subst handling is eventually unified, a maintainer regenerating the expectations has no indication that the previous values were documenting a known inconsistency rather than the intended behavior.

From the tests I would say that go, java and javascript handle subst correctly, while puthon, ruby, rust and csharp(?) no.
For those I would add a comment in test.py.

Otherwise LGTM 👍

@@ -0,0 +1,4 @@
class test {

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.

Lowercase test hurts a bit 😆
No need to change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed, since I was changing things anyway.

where
not f.getURL().matches("file:///modules/%") and
not f.getURL().matches("file:///!unknown-binary-location/kotlin/%") and
not f.getURL().matches("%/semmle-code/semmle-code/%") and

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.

Thinking out loud: are we okay with leaking some of the internal structure of our private repository? Could we use a different filter instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let me have a look. Note that we do leak this in other places already, but not in tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@jketema

jketema commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

From the tests I would say that go, java and javascript handle subst correctly

Depends a bit on your perspective, but if you consider a subst drive a symbolic link, then those are exactly the ones that are wrong.

@IdrissRio

Copy link
Copy Markdown
Contributor

but if you consider a subst drive a symbolic link, then those are exactly the ones that are wrong.

That makes perfect sense. Then I would approach it the other way around and add a comment to those test files.

@jketema

jketema commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

That makes perfect sense. Then I would approach it the other way around and add a comment to those test files.

The implication in that case is though that every single one is wrong at the moment.

@IdrissRio

IdrissRio commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

I see. Maybe adding a link to the issue (as a comment) would help here instead of writing down what is right or wrong.

IdrissRio
IdrissRio previously approved these changes Jul 1, 2026

@IdrissRio IdrissRio 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.

Thanks for answering all my questions.

@jketema jketema merged commit d664d17 into github:main Jul 1, 2026
73 of 74 checks passed
@jketema jketema deleted the subst branch July 1, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C# Go Java JS Python Ruby Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants