diff --git a/ql/ql/src/codeql_ql/ast/Yaml.qll b/ql/ql/src/codeql_ql/ast/Yaml.qll index 142820226a41..d5e80365ff4a 100644 --- a/ql/ql/src/codeql_ql/ast/Yaml.qll +++ b/ql/ql/src/codeql_ql/ast/Yaml.qll @@ -64,4 +64,15 @@ class QlRefDocument extends YamlDocument { value = n.lookup("postprocess").(YamlSequence).getElement(_) ) } + + predicate isPrintAst() { + this.getFile().getStem() = "PrintAst" + or + exists(YamlMapping n, YamlScalar value | + n.getDocument() = this and + value.getValue().matches("%PrintAst%") + | + value = n.lookup("query") + ) + } } diff --git a/ql/ql/src/queries/style/QlRefInlineExpectations.ql b/ql/ql/src/queries/style/QlRefInlineExpectations.ql index 870dd0f437c9..66c139f683f6 100644 --- a/ql/ql/src/queries/style/QlRefInlineExpectations.ql +++ b/ql/ql/src/queries/style/QlRefInlineExpectations.ql @@ -11,5 +11,7 @@ import ql import codeql_ql.ast.Yaml from QlRefDocument f -where not f.usesInlineExpectations() +where + not f.usesInlineExpectations() and + not f.isPrintAst() select f, "Query test does not use inline test expectations." diff --git a/ql/ql/test/queries/style/QlRefInlineExpectations/PrintAst.expected b/ql/ql/test/queries/style/QlRefInlineExpectations/PrintAst.expected new file mode 100644 index 000000000000..14a5f4f77197 --- /dev/null +++ b/ql/ql/test/queries/style/QlRefInlineExpectations/PrintAst.expected @@ -0,0 +1 @@ +| | diff --git a/ql/ql/test/queries/style/QlRefInlineExpectations/PrintAst.qlref b/ql/ql/test/queries/style/QlRefInlineExpectations/PrintAst.qlref new file mode 100644 index 000000000000..b6fe7e93204a --- /dev/null +++ b/ql/ql/test/queries/style/QlRefInlineExpectations/PrintAst.qlref @@ -0,0 +1 @@ +dummy/PrintAst.ql diff --git a/ql/ql/test/queries/style/QlRefInlineExpectations/Test4.expected b/ql/ql/test/queries/style/QlRefInlineExpectations/Test4.expected new file mode 100644 index 000000000000..14a5f4f77197 --- /dev/null +++ b/ql/ql/test/queries/style/QlRefInlineExpectations/Test4.expected @@ -0,0 +1 @@ +| | diff --git a/ql/ql/test/queries/style/QlRefInlineExpectations/Test4.qlref b/ql/ql/test/queries/style/QlRefInlineExpectations/Test4.qlref new file mode 100644 index 000000000000..43dd92b5c777 --- /dev/null +++ b/ql/ql/test/queries/style/QlRefInlineExpectations/Test4.qlref @@ -0,0 +1 @@ +query: dummy/PrintAst.ql diff --git a/ql/ql/test/queries/style/QlRefInlineExpectations/dummy/PrintAst.expected b/ql/ql/test/queries/style/QlRefInlineExpectations/dummy/PrintAst.expected new file mode 100644 index 000000000000..14a5f4f77197 --- /dev/null +++ b/ql/ql/test/queries/style/QlRefInlineExpectations/dummy/PrintAst.expected @@ -0,0 +1 @@ +| | diff --git a/ql/ql/test/queries/style/QlRefInlineExpectations/dummy/PrintAst.ql b/ql/ql/test/queries/style/QlRefInlineExpectations/dummy/PrintAst.ql new file mode 100644 index 000000000000..205315977441 --- /dev/null +++ b/ql/ql/test/queries/style/QlRefInlineExpectations/dummy/PrintAst.ql @@ -0,0 +1 @@ +select ""