Codegen: use one generated test file per directory

This collapses all generated test QL sources into a single one per
directory, using query predicates to run the different tests.

This should improve the time required to run generated tests.
This commit is contained in:
Paolo Tranquilli
2025-06-25 11:44:54 +02:00
parent 3d9e2f5438
commit 6bbf1e3bc1
1753 changed files with 7752 additions and 7850 deletions

View File

@@ -2,12 +2,28 @@
import codeql.rust.elements
import TestUtils
from StructExprField x, int getNumberOfAttrs, string hasExpr, string hasIdentifier
where
query predicate instances(
StructExprField x, string getNumberOfAttrs__label, int getNumberOfAttrs, string hasExpr__label,
string hasExpr, string hasIdentifier__label, string hasIdentifier
) {
toBeTested(x) and
not x.isUnknown() and
getNumberOfAttrs__label = "getNumberOfAttrs:" and
getNumberOfAttrs = x.getNumberOfAttrs() and
hasExpr__label = "hasExpr:" and
(if x.hasExpr() then hasExpr = "yes" else hasExpr = "no") and
hasIdentifier__label = "hasIdentifier:" and
if x.hasIdentifier() then hasIdentifier = "yes" else hasIdentifier = "no"
select x, "getNumberOfAttrs:", getNumberOfAttrs, "hasExpr:", hasExpr, "hasIdentifier:",
hasIdentifier
}
query predicate getAttr(StructExprField x, int index, Attr getAttr) {
toBeTested(x) and not x.isUnknown() and getAttr = x.getAttr(index)
}
query predicate getExpr(StructExprField x, Expr getExpr) {
toBeTested(x) and not x.isUnknown() and getExpr = x.getExpr()
}
query predicate getIdentifier(StructExprField x, NameRef getIdentifier) {
toBeTested(x) and not x.isUnknown() and getIdentifier = x.getIdentifier()
}