You can use query reference files to define the location of a query you want to run in tests.
CodeQL is available for the following repository types:
A query reference file is text file that defines the location of one query to test.
You use a query reference file when you want to tell the test run subcommand to run a query that’s not part of a test directory. There are two ways to specify queries that you want to run as tests:
test run
select
Each query reference file, .qlref, contains a single line that defines where to find one query. The location must be defined relative to the root of the CodeQL pack that contains the query. Usually, this is either the CodeQL pack that contains the .qlref, a CodeQL pack specified in the dependencies block for the test pack, or a transitive dependency of the CodeQL pack.
.qlref
dependencies
You should use forward slashes in the path on all operating systems to ensure compatibility between systems.
A query reference file to test a JavaScript alert query: DeadAngularJSEventListener.qlref
The qlpack.yml file, https://github.com/github/codeql/blob/main/javascript/ql/test/qlpack.yml, for the CodeQL pack at javascript/ql/test defines codeql/javascript-queries as a dependency. So the query reference file defines the location of the query relative to the codeql/javascript-queries CodeQL pack:
qlpack.yml
javascript/ql/test
codeql/javascript-queries
AngularJS/DeadAngularJSEventListener.ql
For another example, see