mirror of
https://github.com/github/codeql.git
synced 2026-04-26 01:05:15 +02:00
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.
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
#include "a.h"
|
||||
#define FOUR 4
|
||||
@@ -0,0 +1,3 @@
|
||||
int main() {
|
||||
return ONE + FOUR;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
#import "d.h"
|
||||
@@ -0,0 +1,3 @@
|
||||
int main() {
|
||||
return SEVENTEEN;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#if 1
|
||||
#pragma hdrstop
|
||||
extern int x;
|
||||
#define SEEN_F
|
||||
#endif
|
||||
@@ -0,0 +1,5 @@
|
||||
#ifdef SEEN_F
|
||||
static int g() {
|
||||
return 20;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "h1.h"
|
||||
#pragma hdrstop
|
||||
#include "h2.h"
|
||||
#define SEEN_H
|
||||
@@ -13,4 +13,3 @@ static int h2() {
|
||||
return 32;
|
||||
}
|
||||
#endif
|
||||
// semmle-extractor-options: --clang -include-pch ${testdir}/clang-pch.testproj/h.pch
|
||||
@@ -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',
|
||||
])
|
||||
@@ -0,0 +1 @@
|
||||
#include "a.h"
|
||||
@@ -0,0 +1,6 @@
|
||||
#pragma hdrstop
|
||||
#include "b.h"
|
||||
|
||||
int b() {
|
||||
return A;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "d.h"
|
||||
#include "c.h"
|
||||
|
||||
int c() {
|
||||
return A;
|
||||
}
|
||||
@@ -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',
|
||||
])
|
||||
@@ -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.
|
||||
@@ -1,3 +0,0 @@
|
||||
#include "a.h"
|
||||
#define FOUR 4
|
||||
// semmle-extractor-options: --clang -emit-pch -o ${testdir}/clang-pch.testproj/a.pch
|
||||
@@ -1,4 +0,0 @@
|
||||
int main() {
|
||||
return ONE + FOUR;
|
||||
}
|
||||
// semmle-extractor-options: --clang -include ${testdir}/clang-pch.testproj/a -Iextra_dummy_path
|
||||
@@ -1,2 +0,0 @@
|
||||
#import "d.h"
|
||||
// semmle-extractor-options: --clang -emit-pch -o ${testdir}/clang-pch.testproj/d.pch
|
||||
@@ -1,4 +0,0 @@
|
||||
int main() {
|
||||
return SEVENTEEN;
|
||||
}
|
||||
// semmle-extractor-options: --clang -include-pch ${testdir}/clang-pch.testproj/d.pch
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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.
|
||||
@@ -1,2 +0,0 @@
|
||||
#include "a.h"
|
||||
// semmle-extractor-options: --microsoft /Yca.h /Fp${testdir}/microsoft-pch.testproj/a.pch
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user