From 3d8d340f2a6e48c6bb9d665231c4abd480ed020a 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 | 7 ++++++- cpp/ql/test/library-tests/basic_blocks/cfg.ql | 7 ++++++- cpp/ql/test/library-tests/c++_exceptions/graphable.ql | 7 ++++++- cpp/ql/test/library-tests/constexpr_if/cfg.ql | 7 ++++++- cpp/ql/test/library-tests/destructors/cfg.ql | 7 ++++++- cpp/ql/test/library-tests/lambdas/cfg/cfg.ql | 7 ++++++- cpp/ql/test/library-tests/pointsto/basic/sets.ql | 7 ++++++- cpp/ql/test/library-tests/sub_basic_blocks/cut.ql | 7 ++++++- cpp/ql/test/library-tests/sub_basic_blocks/no_cut.ql | 7 ++++++- cpp/ql/test/library-tests/virtual_functions/cfg/cfg.ql | 7 ++++++- cpp/ql/test/library-tests/vla/cfg.ql | 7 ++++++- cpp/ql/test/successor-tests/break_labels/cfg.ql | 7 ++++++- cpp/ql/test/successor-tests/conditional_destructors/cfg.ql | 7 ++++++- .../exceptionhandler/ellipsisexceptionhandler/graphable.ql | 7 ++++++- .../exceptionhandler/exceptionhandler/graphable.ql | 7 ++++++- cpp/ql/test/successor-tests/pruning/graphable.ql | 7 ++++++- cpp/ql/test/successor-tests/returnstmt/graphable.ql | 7 ++++++- .../stackvariables/stackvariables/graphable.ql | 7 ++++++- .../successor-tests/switchstmt/switchbody/graphable.ql | 7 ++++++- 19 files changed, 114 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 5371e2a39014..f078a70a66d0 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,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/library-tests/basic_blocks/cfg.ql +++ b/cpp/ql/test/library-tests/basic_blocks/cfg.ql @@ -1,4 +1,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/library-tests/c++_exceptions/graphable.ql +++ b/cpp/ql/test/library-tests/c++_exceptions/graphable.ql @@ -1,4 +1,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/library-tests/constexpr_if/cfg.ql +++ b/cpp/ql/test/library-tests/constexpr_if/cfg.ql @@ -1,4 +1,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/library-tests/destructors/cfg.ql +++ b/cpp/ql/test/library-tests/destructors/cfg.ql @@ -1,4 +1,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/library-tests/lambdas/cfg/cfg.ql +++ b/cpp/ql/test/library-tests/lambdas/cfg/cfg.ql @@ -1,4 +1,9 @@ -// 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 ebb1cb9134e7..98b952f3dfe1 100644 --- a/cpp/ql/test/library-tests/pointsto/basic/sets.ql +++ b/cpp/ql/test/library-tests/pointsto/basic/sets.ql @@ -1,4 +1,9 @@ -// 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 2d89bd3cf95a..3f081a904885 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,9 @@ -// 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 1f1a6b3eb779..84f74a26b920 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,9 @@ -// 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 19a82ba0de07..0e1f45caf193 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,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/library-tests/vla/cfg.ql +++ b/cpp/ql/test/library-tests/vla/cfg.ql @@ -1,4 +1,9 @@ -// 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 4698a25e8095..e9cbb93d0052 100644 --- a/cpp/ql/test/successor-tests/break_labels/cfg.ql +++ b/cpp/ql/test/successor-tests/break_labels/cfg.ql @@ -1,4 +1,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/successor-tests/conditional_destructors/cfg.ql +++ b/cpp/ql/test/successor-tests/conditional_destructors/cfg.ql @@ -1,4 +1,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/successor-tests/exceptionhandler/ellipsisexceptionhandler/graphable.ql +++ b/cpp/ql/test/successor-tests/exceptionhandler/ellipsisexceptionhandler/graphable.ql @@ -1,4 +1,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/successor-tests/exceptionhandler/exceptionhandler/graphable.ql +++ b/cpp/ql/test/successor-tests/exceptionhandler/exceptionhandler/graphable.ql @@ -1,4 +1,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/successor-tests/pruning/graphable.ql +++ b/cpp/ql/test/successor-tests/pruning/graphable.ql @@ -1,4 +1,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/successor-tests/returnstmt/graphable.ql +++ b/cpp/ql/test/successor-tests/returnstmt/graphable.ql @@ -1,4 +1,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/successor-tests/stackvariables/stackvariables/graphable.ql +++ b/cpp/ql/test/successor-tests/stackvariables/stackvariables/graphable.ql @@ -1,4 +1,9 @@ -// 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 19a82ba0de07..0e1f45caf193 100644 --- a/cpp/ql/test/successor-tests/switchstmt/switchbody/graphable.ql +++ b/cpp/ql/test/successor-tests/switchstmt/switchbody/graphable.ql @@ -1,4 +1,9 @@ -// query-type: graph +/** + * query-type: graph + * + * @kind graph-equivalence-test + */ + import cpp class DestructorCallEnhanced extends DestructorCall {