-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Shared: Post-processing query for inline test expectations #17548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hvitved
merged 15 commits into
github:main
from
hvitved:shared/inline-test-post-process
Oct 31, 2024
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b111194
Shared: Simplify `PrettyPrintModels.ql`
hvitved e7a3e6b
Shared: Post-processing query for inline test expectations
hvitved 8ba80fd
C#: Post-processing query for inline test expectations
hvitved e2b614d
Java: Post-processing query for inline test expectations
hvitved 5b5ca05
Ruby: Post-processing query for inline test expectations
hvitved 4561770
Swift: Post-processing query for inline test expectations
hvitved 540b433
Go: Post-processing query for inline test expectations
hvitved 4750b0d
C++: Post-processing query for inline test expectations
hvitved e5f2bbb
Python: Post-processing query for inline test expectations
hvitved 1259b7e
JS: Post-processing query for inline test expectations
hvitved dd520fe
Rust: Post-processing query for inline test expectations
hvitved baeffa2
Update rust/ql/test/query-tests/unusedentities/unreachable.rs
hvitved cc94c42
Address review comments
hvitved ff9811b
C#: Add tests for the inline test post-processor
hvitved 495c92d
Shared: Also take query ID into account in `PathProblemSourceTestInput`
hvitved File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /** | ||
| * @kind test-postprocess | ||
| */ | ||
|
|
||
| private import cpp | ||
| private import codeql.util.test.InlineExpectationsTest as T | ||
| private import internal.InlineExpectationsTestImpl | ||
| import T::TestPostProcessing | ||
| import T::TestPostProcessing::Make<Impl, Input> | ||
|
|
||
| private module Input implements T::TestPostProcessing::InputSig<Impl> { | ||
| string getRelativeUrl(Location location) { | ||
| exists(File f, int startline, int startcolumn, int endline, int endcolumn | | ||
| location.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and | ||
| f = location.getFile() | ||
| | | ||
| result = | ||
| f.getRelativePath() + ":" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn | ||
| ) | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
cpp/ql/test/TestUtilities/internal/InlineExpectationsTestImpl.qll
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import cpp as C | ||
| private import codeql.util.test.InlineExpectationsTest | ||
|
|
||
| module Impl implements InlineExpectationsTestSig { | ||
| private newtype TExpectationComment = MkExpectationComment(C::CppStyleComment c) | ||
|
|
||
| /** | ||
| * A class representing a line comment in the CPP style. | ||
| * Unlike the `CppStyleComment` class, however, the string returned by `getContents` does _not_ | ||
| * include the preceding comment marker (`//`). | ||
| */ | ||
| class ExpectationComment extends TExpectationComment { | ||
| C::CppStyleComment comment; | ||
|
|
||
| ExpectationComment() { this = MkExpectationComment(comment) } | ||
|
|
||
| /** Returns the contents of the given comment, _without_ the preceding comment marker (`//`). */ | ||
| string getContents() { result = comment.getContents().suffix(2) } | ||
|
|
||
| /** Gets a textual representation of this element. */ | ||
| string toString() { result = comment.toString() } | ||
|
|
||
| /** Gets the location of this comment. */ | ||
| Location getLocation() { result = comment.getLocation() } | ||
| } | ||
|
|
||
| class Location = C::Location; | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| Critical/SizeCheck.ql | ||
| query: Critical/SizeCheck.ql | ||
| postprocess: TestUtilities/InlineExpectationsTestQuery.ql |
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
3 changes: 2 additions & 1 deletion
3
cpp/ql/test/query-tests/Security/CWE/CWE-022/semmle/tests/TaintedPath.qlref
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| Security/CWE/CWE-022/TaintedPath.ql | ||
| query: Security/CWE/CWE-022/TaintedPath.ql | ||
| postprocess: TestUtilities/InlineExpectationsTestQuery.ql |
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
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
21 changes: 21 additions & 0 deletions
21
csharp/ql/test/TestUtilities/InlineExpectationsTestQuery.ql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /** | ||
| * @kind test-postprocess | ||
| */ | ||
|
|
||
| private import csharp | ||
| private import codeql.util.test.InlineExpectationsTest as T | ||
| private import internal.InlineExpectationsTestImpl | ||
| import T::TestPostProcessing | ||
| import T::TestPostProcessing::Make<Impl, Input> | ||
|
|
||
| private module Input implements T::TestPostProcessing::InputSig<Impl> { | ||
| string getRelativeUrl(Location location) { | ||
| exists(File f, int startline, int startcolumn, int endline, int endcolumn | | ||
| location.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and | ||
| f = location.getFile() | ||
| | | ||
| result = | ||
| f.getRelativePath() + ":" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn | ||
| ) | ||
| } | ||
| } |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.