legacy-query.test.ts: skip if CLI supports new query server

This commit is contained in:
Chuan-kai Lin
2023-07-27 09:10:04 -07:00
parent 396dc3e915
commit 72fa1c5583
2 changed files with 32 additions and 0 deletions

View File

@@ -111,11 +111,20 @@ describeWithCodeQL()("using the legacy query server", () => {
let qs: qsClient.QueryServerClient;
let cliServer: cli.CodeQLCliServer;
let supportNewQueryServer = false;
beforeAll(async () => {
const extension = await getActivatedExtension();
cliServer = extension.cliServer;
cliServer.quiet = true;
if (await cliServer.cliConstraints.supportsNewQueryServerForTests()) {
console.log(
"Skipping legacy-query tests: the CLI supports the new query server",
);
supportNewQueryServer = true;
}
qs = new QueryServerClient(
createMockApp({}),
{
@@ -145,10 +154,18 @@ describeWithCodeQL()("using the legacy query server", () => {
const parsedResults = new Checkpoint<void>();
it("should register the database if necessary", async () => {
if (supportNewQueryServer) {
return;
}
await qs.sendRequest(messages.registerDatabases, { databases: [db] });
});
it(`should be able to compile query ${queryName}`, async () => {
if (supportNewQueryServer) {
return;
}
expect(existsSync(queryTestCase.queryPath)).toBe(true);
try {
const qlProgram: messages.QlProgram = {
@@ -188,6 +205,10 @@ describeWithCodeQL()("using the legacy query server", () => {
});
it(`should be able to run query ${queryName}`, async () => {
if (supportNewQueryServer) {
return;
}
try {
await compilationSucceeded.done();
const callbackId = qs.registerCallback((_res) => {
@@ -217,6 +238,10 @@ describeWithCodeQL()("using the legacy query server", () => {
const actualResultSets: ResultSets = {};
it(`should be able to parse results of query ${queryName}`, async () => {
if (supportNewQueryServer) {
return;
}
await evaluationSucceeded.done();
const info = await cliServer.bqrsInfo(RESULTS_PATH);
@@ -231,6 +256,10 @@ describeWithCodeQL()("using the legacy query server", () => {
});
it(`should have correct results for query ${queryName}`, async () => {
if (supportNewQueryServer) {
return;
}
await parsedResults.done();
expect(actualResultSets).not.toEqual({});
expect(Object.keys(actualResultSets!).sort()).toEqual(

View File

@@ -114,6 +114,9 @@ describeWithCodeQL()("using the new query server", () => {
cliServer.quiet = true;
if (!(await cliServer.cliConstraints.supportsNewQueryServerForTests())) {
console.log(
"Skipping new-query tests: the CLI supports only the legacy query server",
);
supportNewQueryServer = false;
}
qs = new QueryServerClient(