From a43c5cee615ba273822bb5a70b226b75b555f4c9 Mon Sep 17 00:00:00 2001 From: Asger F Date: Tue, 30 Jun 2026 12:43:41 +0200 Subject: [PATCH 1/2] unified: Add inline expectation test library --- .../lib/utils/test/InlineExpectationsTest.qll | 8 +++++++ .../utils/test/InlineExpectationsTestQuery.ql | 21 +++++++++++++++++++ .../internal/InlineExpectationsTestImpl.qll | 12 +++++++++++ 3 files changed, 41 insertions(+) create mode 100644 unified/ql/lib/utils/test/InlineExpectationsTest.qll create mode 100644 unified/ql/lib/utils/test/InlineExpectationsTestQuery.ql create mode 100644 unified/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll diff --git a/unified/ql/lib/utils/test/InlineExpectationsTest.qll b/unified/ql/lib/utils/test/InlineExpectationsTest.qll new file mode 100644 index 000000000000..7b331deb9458 --- /dev/null +++ b/unified/ql/lib/utils/test/InlineExpectationsTest.qll @@ -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 diff --git a/unified/ql/lib/utils/test/InlineExpectationsTestQuery.ql b/unified/ql/lib/utils/test/InlineExpectationsTestQuery.ql new file mode 100644 index 000000000000..039194bc2e38 --- /dev/null +++ b/unified/ql/lib/utils/test/InlineExpectationsTestQuery.ql @@ -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 + +private module Input implements T::TestPostProcessing::InputSig { + 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 + ) + } +} diff --git a/unified/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll b/unified/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll new file mode 100644 index 000000000000..748a9b1a6c59 --- /dev/null +++ b/unified/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll @@ -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 contents of the given comment, _without_ the preceding comment marker (`//`). */ + string getContents() { result = this.getCommentText() } + } + + class Location = U::Location; +} From a9617f18a17d4daf9cd01ecd7a016adf56093242 Mon Sep 17 00:00:00 2001 From: Asger F Date: Tue, 30 Jun 2026 15:48:15 +0200 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unified/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll b/unified/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll index 748a9b1a6c59..b73301687412 100644 --- a/unified/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll +++ b/unified/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll @@ -4,7 +4,7 @@ private import codeql.util.test.InlineExpectationsTest module Impl implements InlineExpectationsTestSig { class ExpectationComment extends U::Comment { - /** Gets the contents of the given comment, _without_ the preceding comment marker (`//`). */ + /** Gets the text inside this comment, without the surrounding comment delimiters. */ string getContents() { result = this.getCommentText() } }