Add Windows integration tests showing that subst is handled inconsistently#22087
Conversation
3c83d27 to
8e05251
Compare
subst is handled inconsistently
There was a problem hiding this comment.
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
substintegration-test directories for Rust, Ruby, Python, JavaScript, Go, Java/Kotlin, and C#. - For each test: create a database with
source_rooton asubstdrive, then run a small query and compare.expectedresults 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 | |||
IdrissRio
left a comment
There was a problem hiding this comment.
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 { | |||
There was a problem hiding this comment.
Lowercase test hurts a bit 😆
No need to change.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Thinking out loud: are we okay with leaking some of the internal structure of our private repository? Could we use a different filter instead?
There was a problem hiding this comment.
Let me have a look. Note that we do leak this in other places already, but not in tests.
Depends a bit on your perspective, but if you consider a |
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. |
|
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
left a comment
There was a problem hiding this comment.
Thanks for answering all my questions.
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
substdrive.