From f233a5a133218e58a89383cab3a571e8d7ea0588 Mon Sep 17 00:00:00 2001 From: Henning Makholm Date: Tue, 22 Oct 2024 19:56:15 +0200 Subject: [PATCH] Supplement 'query-type: graph' with actual query metadata A number of CPP library tests contain `// query-type: graph` annotations that make the test driver compare the output from the test query in a special mode. (This feature is not used by other languages). It's somewhat awkward in the implementation of `codeql test run` that this annotation is not an ordinary item of query metadata -- essentially it means that _every_ test query has to be opened and read an extra time to look for this annotation. I'd like to move towards using ordinary query metadata for this, since the QL compiler already parses it anyway. For the time being, give the annotation in both old and new syntaxes, until a CLI that recognizes both has been released. --- cpp/ql/test/library-tests/basic_blocks/bb_cfg.ql | 5 ++++- cpp/ql/test/library-tests/basic_blocks/cfg.ql | 5 ++++- cpp/ql/test/library-tests/c++_exceptions/graphable.ql | 5 ++++- cpp/ql/test/library-tests/constexpr_if/cfg.ql | 5 ++++- cpp/ql/test/library-tests/destructors/cfg.ql | 5 ++++- cpp/ql/test/library-tests/lambdas/cfg/cfg.ql | 5 ++++- cpp/ql/test/library-tests/pointsto/basic/sets.ql | 5 ++++- cpp/ql/test/library-tests/sub_basic_blocks/cut.ql | 5 ++++- cpp/ql/test/library-tests/sub_basic_blocks/no_cut.ql | 5 ++++- cpp/ql/test/library-tests/virtual_functions/cfg/cfg.ql | 5 ++++- cpp/ql/test/library-tests/vla/cfg.ql | 5 ++++- cpp/ql/test/successor-tests/break_labels/cfg.ql | 5 ++++- cpp/ql/test/successor-tests/conditional_destructors/cfg.ql | 5 ++++- .../exceptionhandler/ellipsisexceptionhandler/graphable.ql | 5 ++++- .../exceptionhandler/exceptionhandler/graphable.ql | 5 ++++- cpp/ql/test/successor-tests/pruning/graphable.ql | 5 ++++- cpp/ql/test/successor-tests/returnstmt/graphable.ql | 5 ++++- .../stackvariables/stackvariables/graphable.ql | 5 ++++- .../test/successor-tests/switchstmt/switchbody/graphable.ql | 5 ++++- 19 files changed, 76 insertions(+), 19 deletions(-) diff --git a/cpp/ql/test/library-tests/basic_blocks/bb_cfg.ql b/cpp/ql/test/library-tests/basic_blocks/bb_cfg.ql index 5371e2a39014e..7c42e44907277 100644 --- a/cpp/ql/test/library-tests/basic_blocks/bb_cfg.ql +++ b/cpp/ql/test/library-tests/basic_blocks/bb_cfg.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/library-tests/basic_blocks/cfg.ql b/cpp/ql/test/library-tests/basic_blocks/cfg.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/library-tests/basic_blocks/cfg.ql +++ b/cpp/ql/test/library-tests/basic_blocks/cfg.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/library-tests/c++_exceptions/graphable.ql b/cpp/ql/test/library-tests/c++_exceptions/graphable.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/library-tests/c++_exceptions/graphable.ql +++ b/cpp/ql/test/library-tests/c++_exceptions/graphable.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/library-tests/constexpr_if/cfg.ql b/cpp/ql/test/library-tests/constexpr_if/cfg.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/library-tests/constexpr_if/cfg.ql +++ b/cpp/ql/test/library-tests/constexpr_if/cfg.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/library-tests/destructors/cfg.ql b/cpp/ql/test/library-tests/destructors/cfg.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/library-tests/destructors/cfg.ql +++ b/cpp/ql/test/library-tests/destructors/cfg.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/library-tests/lambdas/cfg/cfg.ql b/cpp/ql/test/library-tests/lambdas/cfg/cfg.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/library-tests/lambdas/cfg/cfg.ql +++ b/cpp/ql/test/library-tests/lambdas/cfg/cfg.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/library-tests/pointsto/basic/sets.ql b/cpp/ql/test/library-tests/pointsto/basic/sets.ql index ebb1cb9134e70..4852082a20f58 100644 --- a/cpp/ql/test/library-tests/pointsto/basic/sets.ql +++ b/cpp/ql/test/library-tests/pointsto/basic/sets.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp import semmle.code.cpp.pointsto.PointsTo diff --git a/cpp/ql/test/library-tests/sub_basic_blocks/cut.ql b/cpp/ql/test/library-tests/sub_basic_blocks/cut.ql index 2d89bd3cf95ac..ea60bf51d18ac 100644 --- a/cpp/ql/test/library-tests/sub_basic_blocks/cut.ql +++ b/cpp/ql/test/library-tests/sub_basic_blocks/cut.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import sbb_test class CutCall extends SubBasicBlockCutNode { diff --git a/cpp/ql/test/library-tests/sub_basic_blocks/no_cut.ql b/cpp/ql/test/library-tests/sub_basic_blocks/no_cut.ql index 1f1a6b3eb7793..599bd7a339224 100644 --- a/cpp/ql/test/library-tests/sub_basic_blocks/no_cut.ql +++ b/cpp/ql/test/library-tests/sub_basic_blocks/no_cut.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import sbb_test // Note: no instance of `SubBasicBlockCutNode` diff --git a/cpp/ql/test/library-tests/virtual_functions/cfg/cfg.ql b/cpp/ql/test/library-tests/virtual_functions/cfg/cfg.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/library-tests/virtual_functions/cfg/cfg.ql +++ b/cpp/ql/test/library-tests/virtual_functions/cfg/cfg.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/library-tests/vla/cfg.ql b/cpp/ql/test/library-tests/vla/cfg.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/library-tests/vla/cfg.ql +++ b/cpp/ql/test/library-tests/vla/cfg.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/successor-tests/break_labels/cfg.ql b/cpp/ql/test/successor-tests/break_labels/cfg.ql index 4698a25e80951..f5a363efb1345 100644 --- a/cpp/ql/test/successor-tests/break_labels/cfg.ql +++ b/cpp/ql/test/successor-tests/break_labels/cfg.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/successor-tests/conditional_destructors/cfg.ql b/cpp/ql/test/successor-tests/conditional_destructors/cfg.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/successor-tests/conditional_destructors/cfg.ql +++ b/cpp/ql/test/successor-tests/conditional_destructors/cfg.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/successor-tests/exceptionhandler/ellipsisexceptionhandler/graphable.ql b/cpp/ql/test/successor-tests/exceptionhandler/ellipsisexceptionhandler/graphable.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/successor-tests/exceptionhandler/ellipsisexceptionhandler/graphable.ql +++ b/cpp/ql/test/successor-tests/exceptionhandler/ellipsisexceptionhandler/graphable.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/successor-tests/exceptionhandler/exceptionhandler/graphable.ql b/cpp/ql/test/successor-tests/exceptionhandler/exceptionhandler/graphable.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/successor-tests/exceptionhandler/exceptionhandler/graphable.ql +++ b/cpp/ql/test/successor-tests/exceptionhandler/exceptionhandler/graphable.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/successor-tests/pruning/graphable.ql b/cpp/ql/test/successor-tests/pruning/graphable.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/successor-tests/pruning/graphable.ql +++ b/cpp/ql/test/successor-tests/pruning/graphable.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/successor-tests/returnstmt/graphable.ql b/cpp/ql/test/successor-tests/returnstmt/graphable.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/successor-tests/returnstmt/graphable.ql +++ b/cpp/ql/test/successor-tests/returnstmt/graphable.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/successor-tests/stackvariables/stackvariables/graphable.ql b/cpp/ql/test/successor-tests/stackvariables/stackvariables/graphable.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/successor-tests/stackvariables/stackvariables/graphable.ql +++ b/cpp/ql/test/successor-tests/stackvariables/stackvariables/graphable.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall { diff --git a/cpp/ql/test/successor-tests/switchstmt/switchbody/graphable.ql b/cpp/ql/test/successor-tests/switchstmt/switchbody/graphable.ql index 19a82ba0de074..0d90f15b2e873 100644 --- a/cpp/ql/test/successor-tests/switchstmt/switchbody/graphable.ql +++ b/cpp/ql/test/successor-tests/switchstmt/switchbody/graphable.ql @@ -1,4 +1,7 @@ -// query-type: graph +/** + * query-type: graph + * @kind graph-equivalence-test + */ import cpp class DestructorCallEnhanced extends DestructorCall {