From 7f9020282dae18959a3ee34c1f21bdf3c744496c Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Tue, 29 Apr 2025 13:16:40 +0200 Subject: [PATCH 1/3] C++: Turn header variant tests that use PCH files into integration tests These tests currently test a code path in the extractor that only exists for these tests. By turning them into integration tests, we actually use the code path that normal database creation uses. --- .../header-variant-tests/clang-pch/a.c | 2 ++ .../header-variant-tests/clang-pch/a.h | 0 .../header-variant-tests/clang-pch/b.c | 0 .../header-variant-tests/clang-pch/b.h | 0 .../header-variant-tests/clang-pch/c.c | 3 +++ .../clang-pch/clang-pch.expected | 0 .../header-variant-tests/clang-pch/clang-pch.ql | 0 .../header-variant-tests/clang-pch/d.c | 1 + .../header-variant-tests/clang-pch/d.h | 0 .../header-variant-tests/clang-pch/e.c | 3 +++ .../header-variant-tests/clang-pch/f.c | 5 +++++ .../header-variant-tests/clang-pch/g.c | 5 +++++ .../header-variant-tests/clang-pch/h.c | 4 ++++ .../header-variant-tests/clang-pch/h1.h | 0 .../header-variant-tests/clang-pch/h2.h | 0 .../header-variant-tests/clang-pch/i.c | 1 - .../header-variant-tests/clang-pch/test.py | 16 ++++++++++++++++ .../header-variant-tests/microsoft-pch/a.c | 1 + .../header-variant-tests/microsoft-pch/a.h | 0 .../header-variant-tests/microsoft-pch/b.c | 6 ++++++ .../header-variant-tests/microsoft-pch/c.c | 6 ++++++ .../microsoft-pch/microsoft-pch.expected | 0 .../microsoft-pch/microsoft-pch.ql | 0 .../header-variant-tests/microsoft-pch/test.py | 10 ++++++++++ cpp/ql/test/header-variant-tests/clang-pch/_.c | 3 --- cpp/ql/test/header-variant-tests/clang-pch/a.c | 3 --- cpp/ql/test/header-variant-tests/clang-pch/c.c | 4 ---- cpp/ql/test/header-variant-tests/clang-pch/d.c | 2 -- cpp/ql/test/header-variant-tests/clang-pch/e.c | 4 ---- cpp/ql/test/header-variant-tests/clang-pch/f.c | 6 ------ cpp/ql/test/header-variant-tests/clang-pch/g.c | 6 ------ cpp/ql/test/header-variant-tests/clang-pch/h.c | 5 ----- .../test/header-variant-tests/microsoft-pch/_.c | 3 --- .../test/header-variant-tests/microsoft-pch/a.c | 2 -- .../test/header-variant-tests/microsoft-pch/b.c | 7 ------- .../test/header-variant-tests/microsoft-pch/c.c | 7 ------- 36 files changed, 62 insertions(+), 53 deletions(-) create mode 100644 cpp/ql/integration-tests/header-variant-tests/clang-pch/a.c rename cpp/ql/{test => integration-tests}/header-variant-tests/clang-pch/a.h (100%) rename cpp/ql/{test => integration-tests}/header-variant-tests/clang-pch/b.c (100%) rename cpp/ql/{test => integration-tests}/header-variant-tests/clang-pch/b.h (100%) create mode 100644 cpp/ql/integration-tests/header-variant-tests/clang-pch/c.c rename cpp/ql/{test => integration-tests}/header-variant-tests/clang-pch/clang-pch.expected (100%) rename cpp/ql/{test => integration-tests}/header-variant-tests/clang-pch/clang-pch.ql (100%) create mode 100644 cpp/ql/integration-tests/header-variant-tests/clang-pch/d.c rename cpp/ql/{test => integration-tests}/header-variant-tests/clang-pch/d.h (100%) create mode 100644 cpp/ql/integration-tests/header-variant-tests/clang-pch/e.c create mode 100644 cpp/ql/integration-tests/header-variant-tests/clang-pch/f.c create mode 100644 cpp/ql/integration-tests/header-variant-tests/clang-pch/g.c create mode 100644 cpp/ql/integration-tests/header-variant-tests/clang-pch/h.c rename cpp/ql/{test => integration-tests}/header-variant-tests/clang-pch/h1.h (100%) rename cpp/ql/{test => integration-tests}/header-variant-tests/clang-pch/h2.h (100%) rename cpp/ql/{test => integration-tests}/header-variant-tests/clang-pch/i.c (64%) create mode 100644 cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py create mode 100644 cpp/ql/integration-tests/header-variant-tests/microsoft-pch/a.c rename cpp/ql/{test => integration-tests}/header-variant-tests/microsoft-pch/a.h (100%) create mode 100644 cpp/ql/integration-tests/header-variant-tests/microsoft-pch/b.c create mode 100644 cpp/ql/integration-tests/header-variant-tests/microsoft-pch/c.c rename cpp/ql/{test => integration-tests}/header-variant-tests/microsoft-pch/microsoft-pch.expected (100%) rename cpp/ql/{test => integration-tests}/header-variant-tests/microsoft-pch/microsoft-pch.ql (100%) create mode 100644 cpp/ql/integration-tests/header-variant-tests/microsoft-pch/test.py delete mode 100644 cpp/ql/test/header-variant-tests/clang-pch/_.c delete mode 100644 cpp/ql/test/header-variant-tests/clang-pch/a.c delete mode 100644 cpp/ql/test/header-variant-tests/clang-pch/c.c delete mode 100644 cpp/ql/test/header-variant-tests/clang-pch/d.c delete mode 100644 cpp/ql/test/header-variant-tests/clang-pch/e.c delete mode 100644 cpp/ql/test/header-variant-tests/clang-pch/f.c delete mode 100644 cpp/ql/test/header-variant-tests/clang-pch/g.c delete mode 100644 cpp/ql/test/header-variant-tests/clang-pch/h.c delete mode 100644 cpp/ql/test/header-variant-tests/microsoft-pch/_.c delete mode 100644 cpp/ql/test/header-variant-tests/microsoft-pch/a.c delete mode 100644 cpp/ql/test/header-variant-tests/microsoft-pch/b.c delete mode 100644 cpp/ql/test/header-variant-tests/microsoft-pch/c.c diff --git a/cpp/ql/integration-tests/header-variant-tests/clang-pch/a.c b/cpp/ql/integration-tests/header-variant-tests/clang-pch/a.c new file mode 100644 index 000000000000..f80dfe401603 --- /dev/null +++ b/cpp/ql/integration-tests/header-variant-tests/clang-pch/a.c @@ -0,0 +1,2 @@ +#include "a.h" +#define FOUR 4 diff --git a/cpp/ql/test/header-variant-tests/clang-pch/a.h b/cpp/ql/integration-tests/header-variant-tests/clang-pch/a.h similarity index 100% rename from cpp/ql/test/header-variant-tests/clang-pch/a.h rename to cpp/ql/integration-tests/header-variant-tests/clang-pch/a.h diff --git a/cpp/ql/test/header-variant-tests/clang-pch/b.c b/cpp/ql/integration-tests/header-variant-tests/clang-pch/b.c similarity index 100% rename from cpp/ql/test/header-variant-tests/clang-pch/b.c rename to cpp/ql/integration-tests/header-variant-tests/clang-pch/b.c diff --git a/cpp/ql/test/header-variant-tests/clang-pch/b.h b/cpp/ql/integration-tests/header-variant-tests/clang-pch/b.h similarity index 100% rename from cpp/ql/test/header-variant-tests/clang-pch/b.h rename to cpp/ql/integration-tests/header-variant-tests/clang-pch/b.h diff --git a/cpp/ql/integration-tests/header-variant-tests/clang-pch/c.c b/cpp/ql/integration-tests/header-variant-tests/clang-pch/c.c new file mode 100644 index 000000000000..e8c42c9c4b22 --- /dev/null +++ b/cpp/ql/integration-tests/header-variant-tests/clang-pch/c.c @@ -0,0 +1,3 @@ +int main() { + return ONE + FOUR; +} diff --git a/cpp/ql/test/header-variant-tests/clang-pch/clang-pch.expected b/cpp/ql/integration-tests/header-variant-tests/clang-pch/clang-pch.expected similarity index 100% rename from cpp/ql/test/header-variant-tests/clang-pch/clang-pch.expected rename to cpp/ql/integration-tests/header-variant-tests/clang-pch/clang-pch.expected diff --git a/cpp/ql/test/header-variant-tests/clang-pch/clang-pch.ql b/cpp/ql/integration-tests/header-variant-tests/clang-pch/clang-pch.ql similarity index 100% rename from cpp/ql/test/header-variant-tests/clang-pch/clang-pch.ql rename to cpp/ql/integration-tests/header-variant-tests/clang-pch/clang-pch.ql diff --git a/cpp/ql/integration-tests/header-variant-tests/clang-pch/d.c b/cpp/ql/integration-tests/header-variant-tests/clang-pch/d.c new file mode 100644 index 000000000000..35e2312fd892 --- /dev/null +++ b/cpp/ql/integration-tests/header-variant-tests/clang-pch/d.c @@ -0,0 +1 @@ +#import "d.h" diff --git a/cpp/ql/test/header-variant-tests/clang-pch/d.h b/cpp/ql/integration-tests/header-variant-tests/clang-pch/d.h similarity index 100% rename from cpp/ql/test/header-variant-tests/clang-pch/d.h rename to cpp/ql/integration-tests/header-variant-tests/clang-pch/d.h diff --git a/cpp/ql/integration-tests/header-variant-tests/clang-pch/e.c b/cpp/ql/integration-tests/header-variant-tests/clang-pch/e.c new file mode 100644 index 000000000000..571efb6f271a --- /dev/null +++ b/cpp/ql/integration-tests/header-variant-tests/clang-pch/e.c @@ -0,0 +1,3 @@ +int main() { + return SEVENTEEN; +} diff --git a/cpp/ql/integration-tests/header-variant-tests/clang-pch/f.c b/cpp/ql/integration-tests/header-variant-tests/clang-pch/f.c new file mode 100644 index 000000000000..613824dc7836 --- /dev/null +++ b/cpp/ql/integration-tests/header-variant-tests/clang-pch/f.c @@ -0,0 +1,5 @@ +#if 1 +#pragma hdrstop +extern int x; +#define SEEN_F +#endif diff --git a/cpp/ql/integration-tests/header-variant-tests/clang-pch/g.c b/cpp/ql/integration-tests/header-variant-tests/clang-pch/g.c new file mode 100644 index 000000000000..bf105c29e95f --- /dev/null +++ b/cpp/ql/integration-tests/header-variant-tests/clang-pch/g.c @@ -0,0 +1,5 @@ +#ifdef SEEN_F +static int g() { + return 20; +} +#endif diff --git a/cpp/ql/integration-tests/header-variant-tests/clang-pch/h.c b/cpp/ql/integration-tests/header-variant-tests/clang-pch/h.c new file mode 100644 index 000000000000..6f183a7070fc --- /dev/null +++ b/cpp/ql/integration-tests/header-variant-tests/clang-pch/h.c @@ -0,0 +1,4 @@ +#include "h1.h" +#pragma hdrstop +#include "h2.h" +#define SEEN_H diff --git a/cpp/ql/test/header-variant-tests/clang-pch/h1.h b/cpp/ql/integration-tests/header-variant-tests/clang-pch/h1.h similarity index 100% rename from cpp/ql/test/header-variant-tests/clang-pch/h1.h rename to cpp/ql/integration-tests/header-variant-tests/clang-pch/h1.h diff --git a/cpp/ql/test/header-variant-tests/clang-pch/h2.h b/cpp/ql/integration-tests/header-variant-tests/clang-pch/h2.h similarity index 100% rename from cpp/ql/test/header-variant-tests/clang-pch/h2.h rename to cpp/ql/integration-tests/header-variant-tests/clang-pch/h2.h diff --git a/cpp/ql/test/header-variant-tests/clang-pch/i.c b/cpp/ql/integration-tests/header-variant-tests/clang-pch/i.c similarity index 64% rename from cpp/ql/test/header-variant-tests/clang-pch/i.c rename to cpp/ql/integration-tests/header-variant-tests/clang-pch/i.c index 05aa74b3047b..1274d6750001 100644 --- a/cpp/ql/test/header-variant-tests/clang-pch/i.c +++ b/cpp/ql/integration-tests/header-variant-tests/clang-pch/i.c @@ -13,4 +13,3 @@ static int h2() { return 32; } #endif -// semmle-extractor-options: --clang -include-pch ${testdir}/clang-pch.testproj/h.pch diff --git a/cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py b/cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py new file mode 100644 index 000000000000..3cf2d42f7643 --- /dev/null +++ b/cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py @@ -0,0 +1,16 @@ +import os + + +def test(codeql, cpp): + os.mkdir("pch") + codeql.database.create(command=[ + f'"{cpp.get_tool("extractor")}" --mimic-clang -emit-pch -o pch/a.pch a.c', + f'"{cpp.get_tool("extractor")}" --mimic-clang -include-pch pch/a.pch -Iextra_dummy_path b.c', + f'"{cpp.get_tool("extractor")}" --mimic-clang -include pch/a -Iextra_dummy_path c.c', + f'"{cpp.get_tool("extractor")}" --mimic-clang -emit-pch -o pch/d.pch d.c', + f'"{cpp.get_tool("extractor")}" --mimic-clang -include-pch pch/d.pch e.c', + f'"{cpp.get_tool("extractor")}" --mimic-clang -emit-pch -o pch/f.pch f.c', + f'"{cpp.get_tool("extractor")}" --mimic-clang -include-pch pch/f.pch g.c', + f'"{cpp.get_tool("extractor")}" --mimic-clang -emit-pch -o pch/h.pch h.c', + f'"{cpp.get_tool("extractor")}" --mimic-clang -include-pch pch/h.pch i.c', + ]) diff --git a/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/a.c b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/a.c new file mode 100644 index 000000000000..2243de1baf9a --- /dev/null +++ b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/a.c @@ -0,0 +1 @@ +#include "a.h" diff --git a/cpp/ql/test/header-variant-tests/microsoft-pch/a.h b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/a.h similarity index 100% rename from cpp/ql/test/header-variant-tests/microsoft-pch/a.h rename to cpp/ql/integration-tests/header-variant-tests/microsoft-pch/a.h diff --git a/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/b.c b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/b.c new file mode 100644 index 000000000000..ef8f5d3ca55d --- /dev/null +++ b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/b.c @@ -0,0 +1,6 @@ +#pragma hdrstop +#include "b.h" + +int b() { + return A; +} diff --git a/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/c.c b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/c.c new file mode 100644 index 000000000000..b270ddd64780 --- /dev/null +++ b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/c.c @@ -0,0 +1,6 @@ +#include "d.h" +#include "c.h" + +int c() { + return A; +} diff --git a/cpp/ql/test/header-variant-tests/microsoft-pch/microsoft-pch.expected b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/microsoft-pch.expected similarity index 100% rename from cpp/ql/test/header-variant-tests/microsoft-pch/microsoft-pch.expected rename to cpp/ql/integration-tests/header-variant-tests/microsoft-pch/microsoft-pch.expected diff --git a/cpp/ql/test/header-variant-tests/microsoft-pch/microsoft-pch.ql b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/microsoft-pch.ql similarity index 100% rename from cpp/ql/test/header-variant-tests/microsoft-pch/microsoft-pch.ql rename to cpp/ql/integration-tests/header-variant-tests/microsoft-pch/microsoft-pch.ql diff --git a/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/test.py b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/test.py new file mode 100644 index 000000000000..eaa0fdb8786c --- /dev/null +++ b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/test.py @@ -0,0 +1,10 @@ +import os + + +def test(codeql, cpp): + os.mkdir("pch") + codeql.database.create(command=[ + f'"{cpp.get_tool("extractor")}" --mimic-cl /Yca.h /Fppch/a.pch a.c', + f'"{cpp.get_tool("extractor")}" --mimic-cl /Yub.h /Fppch/a.pch b.c', + f'"{cpp.get_tool("extractor")}" --mimic-cl /Yuc.h /Fppch/a.pch c.c', + ]) diff --git a/cpp/ql/test/header-variant-tests/clang-pch/_.c b/cpp/ql/test/header-variant-tests/clang-pch/_.c deleted file mode 100644 index 6186edd586f7..000000000000 --- a/cpp/ql/test/header-variant-tests/clang-pch/_.c +++ /dev/null @@ -1,3 +0,0 @@ -// This file exists to ensure that the output subdirectory exists prior to -// a.c being indexed, as said directory needs to exist for the PCH file to -// be created, and will be created by running the extractor. diff --git a/cpp/ql/test/header-variant-tests/clang-pch/a.c b/cpp/ql/test/header-variant-tests/clang-pch/a.c deleted file mode 100644 index 9164cdc19a58..000000000000 --- a/cpp/ql/test/header-variant-tests/clang-pch/a.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "a.h" -#define FOUR 4 -// semmle-extractor-options: --clang -emit-pch -o ${testdir}/clang-pch.testproj/a.pch diff --git a/cpp/ql/test/header-variant-tests/clang-pch/c.c b/cpp/ql/test/header-variant-tests/clang-pch/c.c deleted file mode 100644 index 0a8b97667137..000000000000 --- a/cpp/ql/test/header-variant-tests/clang-pch/c.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() { - return ONE + FOUR; -} -// semmle-extractor-options: --clang -include ${testdir}/clang-pch.testproj/a -Iextra_dummy_path diff --git a/cpp/ql/test/header-variant-tests/clang-pch/d.c b/cpp/ql/test/header-variant-tests/clang-pch/d.c deleted file mode 100644 index f81af3d1b63c..000000000000 --- a/cpp/ql/test/header-variant-tests/clang-pch/d.c +++ /dev/null @@ -1,2 +0,0 @@ -#import "d.h" -// semmle-extractor-options: --clang -emit-pch -o ${testdir}/clang-pch.testproj/d.pch diff --git a/cpp/ql/test/header-variant-tests/clang-pch/e.c b/cpp/ql/test/header-variant-tests/clang-pch/e.c deleted file mode 100644 index abdb59002009..000000000000 --- a/cpp/ql/test/header-variant-tests/clang-pch/e.c +++ /dev/null @@ -1,4 +0,0 @@ -int main() { - return SEVENTEEN; -} -// semmle-extractor-options: --clang -include-pch ${testdir}/clang-pch.testproj/d.pch diff --git a/cpp/ql/test/header-variant-tests/clang-pch/f.c b/cpp/ql/test/header-variant-tests/clang-pch/f.c deleted file mode 100644 index cca56931acd5..000000000000 --- a/cpp/ql/test/header-variant-tests/clang-pch/f.c +++ /dev/null @@ -1,6 +0,0 @@ -#if 1 -#pragma hdrstop -extern int x; -#define SEEN_F -#endif -// semmle-extractor-options: --clang -emit-pch -o ${testdir}/clang-pch.testproj/f.pch diff --git a/cpp/ql/test/header-variant-tests/clang-pch/g.c b/cpp/ql/test/header-variant-tests/clang-pch/g.c deleted file mode 100644 index b16ca33ab369..000000000000 --- a/cpp/ql/test/header-variant-tests/clang-pch/g.c +++ /dev/null @@ -1,6 +0,0 @@ -#ifdef SEEN_F -static int g() { - return 20; -} -#endif -// semmle-extractor-options: --clang -include-pch ${testdir}/clang-pch.testproj/f.pch diff --git a/cpp/ql/test/header-variant-tests/clang-pch/h.c b/cpp/ql/test/header-variant-tests/clang-pch/h.c deleted file mode 100644 index 7ffc9b6133c1..000000000000 --- a/cpp/ql/test/header-variant-tests/clang-pch/h.c +++ /dev/null @@ -1,5 +0,0 @@ -#include "h1.h" -#pragma hdrstop -#include "h2.h" -#define SEEN_H -// semmle-extractor-options: --clang -emit-pch -o ${testdir}/clang-pch.testproj/h.pch diff --git a/cpp/ql/test/header-variant-tests/microsoft-pch/_.c b/cpp/ql/test/header-variant-tests/microsoft-pch/_.c deleted file mode 100644 index 6186edd586f7..000000000000 --- a/cpp/ql/test/header-variant-tests/microsoft-pch/_.c +++ /dev/null @@ -1,3 +0,0 @@ -// This file exists to ensure that the output subdirectory exists prior to -// a.c being indexed, as said directory needs to exist for the PCH file to -// be created, and will be created by running the extractor. diff --git a/cpp/ql/test/header-variant-tests/microsoft-pch/a.c b/cpp/ql/test/header-variant-tests/microsoft-pch/a.c deleted file mode 100644 index ba41bafcaade..000000000000 --- a/cpp/ql/test/header-variant-tests/microsoft-pch/a.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "a.h" -// semmle-extractor-options: --microsoft /Yca.h /Fp${testdir}/microsoft-pch.testproj/a.pch diff --git a/cpp/ql/test/header-variant-tests/microsoft-pch/b.c b/cpp/ql/test/header-variant-tests/microsoft-pch/b.c deleted file mode 100644 index b6ea5085fd1f..000000000000 --- a/cpp/ql/test/header-variant-tests/microsoft-pch/b.c +++ /dev/null @@ -1,7 +0,0 @@ -#pragma hdrstop -#include "b.h" - -int b() { - return A; -} -// semmle-extractor-options: --microsoft /Yub.h /Fp${testdir}/microsoft-pch.testproj/a.pch diff --git a/cpp/ql/test/header-variant-tests/microsoft-pch/c.c b/cpp/ql/test/header-variant-tests/microsoft-pch/c.c deleted file mode 100644 index aaddbae8688d..000000000000 --- a/cpp/ql/test/header-variant-tests/microsoft-pch/c.c +++ /dev/null @@ -1,7 +0,0 @@ -#include "d.h" -#include "c.h" - -int c() { - return A; -} -// semmle-extractor-options: --microsoft /Yuc.h /Fp${testdir}/microsoft-pch.testproj/a.pch From edd18dc0521aa972fcee2a66b1aebf7fc44348a7 Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Wed, 30 Apr 2025 16:23:06 +0200 Subject: [PATCH 2/3] C++: Address review comment --- .../header-variant-tests/clang-pch/test.py | 19 ++++++++++--------- .../microsoft-pch/test.py | 7 ++++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py b/cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py index 3cf2d42f7643..d7bc5fe6352f 100644 --- a/cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py +++ b/cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py @@ -3,14 +3,15 @@ def test(codeql, cpp): os.mkdir("pch") + extractor = f"{cpp.get_tool("extractor")}" codeql.database.create(command=[ - f'"{cpp.get_tool("extractor")}" --mimic-clang -emit-pch -o pch/a.pch a.c', - f'"{cpp.get_tool("extractor")}" --mimic-clang -include-pch pch/a.pch -Iextra_dummy_path b.c', - f'"{cpp.get_tool("extractor")}" --mimic-clang -include pch/a -Iextra_dummy_path c.c', - f'"{cpp.get_tool("extractor")}" --mimic-clang -emit-pch -o pch/d.pch d.c', - f'"{cpp.get_tool("extractor")}" --mimic-clang -include-pch pch/d.pch e.c', - f'"{cpp.get_tool("extractor")}" --mimic-clang -emit-pch -o pch/f.pch f.c', - f'"{cpp.get_tool("extractor")}" --mimic-clang -include-pch pch/f.pch g.c', - f'"{cpp.get_tool("extractor")}" --mimic-clang -emit-pch -o pch/h.pch h.c', - f'"{cpp.get_tool("extractor")}" --mimic-clang -include-pch pch/h.pch i.c', + f'"{extractor}" --mimic-clang -emit-pch -o pch/a.pch a.c', + f'"{extractor}" --mimic-clang -include-pch pch/a.pch -Iextra_dummy_path b.c', + f'"{extractor}" --mimic-clang -include pch/a -Iextra_dummy_path c.c', + f'"{extractor}" --mimic-clang -emit-pch -o pch/d.pch d.c', + f'"{extractor}" --mimic-clang -include-pch pch/d.pch e.c', + f'"{extractor}" --mimic-clang -emit-pch -o pch/f.pch f.c', + f'"{extractor}" --mimic-clang -include-pch pch/f.pch g.c', + f'"{extractor}" --mimic-clang -emit-pch -o pch/h.pch h.c', + f'"{extractor}" --mimic-clang -include-pch pch/h.pch i.c', ]) diff --git a/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/test.py b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/test.py index eaa0fdb8786c..d734f0335f17 100644 --- a/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/test.py +++ b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/test.py @@ -3,8 +3,9 @@ def test(codeql, cpp): os.mkdir("pch") + extractor = f"{cpp.get_tool("extractor")}" codeql.database.create(command=[ - f'"{cpp.get_tool("extractor")}" --mimic-cl /Yca.h /Fppch/a.pch a.c', - f'"{cpp.get_tool("extractor")}" --mimic-cl /Yub.h /Fppch/a.pch b.c', - f'"{cpp.get_tool("extractor")}" --mimic-cl /Yuc.h /Fppch/a.pch c.c', + f'"{extractor}" --mimic-cl /Yca.h /Fppch/a.pch a.c', + f'"{extractor}" --mimic-cl /Yub.h /Fppch/a.pch b.c', + f'"{extractor}" --mimic-cl /Yuc.h /Fppch/a.pch c.c', ]) From 3423a1072ac2c39e91581f9d3d3241d185410321 Mon Sep 17 00:00:00 2001 From: Jeroen Ketema Date: Wed, 30 Apr 2025 19:10:35 +0200 Subject: [PATCH 3/3] C++: Address review comments --- cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py | 2 +- .../header-variant-tests/microsoft-pch/test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py b/cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py index d7bc5fe6352f..0a48fc3a79ce 100644 --- a/cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py +++ b/cpp/ql/integration-tests/header-variant-tests/clang-pch/test.py @@ -3,7 +3,7 @@ def test(codeql, cpp): os.mkdir("pch") - extractor = f"{cpp.get_tool("extractor")}" + extractor = cpp.get_tool("extractor") codeql.database.create(command=[ f'"{extractor}" --mimic-clang -emit-pch -o pch/a.pch a.c', f'"{extractor}" --mimic-clang -include-pch pch/a.pch -Iextra_dummy_path b.c', diff --git a/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/test.py b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/test.py index d734f0335f17..89bceec397e8 100644 --- a/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/test.py +++ b/cpp/ql/integration-tests/header-variant-tests/microsoft-pch/test.py @@ -3,7 +3,7 @@ def test(codeql, cpp): os.mkdir("pch") - extractor = f"{cpp.get_tool("extractor")}" + extractor = cpp.get_tool("extractor") codeql.database.create(command=[ f'"{extractor}" --mimic-cl /Yca.h /Fppch/a.pch a.c', f'"{extractor}" --mimic-cl /Yub.h /Fppch/a.pch b.c',