mirror of
https://github.com/github/codeql.git
synced 2026-07-01 17:45:36 +02:00
Merge pull request #22090 from asgerf/unified/inline-test-expectations
unified: Add inline expectation test library
This commit is contained in:
8
unified/ql/lib/utils/test/InlineExpectationsTest.qll
Normal file
8
unified/ql/lib/utils/test/InlineExpectationsTest.qll
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Inline expectation tests for unified.
|
||||
* See `shared/util/codeql/util/test/InlineExpectationsTest.qll`
|
||||
*/
|
||||
|
||||
private import codeql.util.test.InlineExpectationsTest
|
||||
private import internal.InlineExpectationsTestImpl
|
||||
import Make<Impl>
|
||||
21
unified/ql/lib/utils/test/InlineExpectationsTestQuery.ql
Normal file
21
unified/ql/lib/utils/test/InlineExpectationsTestQuery.ql
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* @kind test-postprocess
|
||||
*/
|
||||
|
||||
private import unified
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
private import unified as U
|
||||
private import U
|
||||
private import codeql.util.test.InlineExpectationsTest
|
||||
|
||||
module Impl implements InlineExpectationsTestSig {
|
||||
class ExpectationComment extends U::Comment {
|
||||
/** Gets the text inside this comment, without the surrounding comment delimiters. */
|
||||
string getContents() { result = this.getCommentText() }
|
||||
}
|
||||
|
||||
class Location = U::Location;
|
||||
}
|
||||
Reference in New Issue
Block a user