Add additionalArgs option to launch.json

This commit is contained in:
Dave Bartolomeo
2023-10-06 18:03:10 -04:00
parent 2410d2bfdd
commit 705a7975c5
11 changed files with 40 additions and 0 deletions

View File

@@ -22,6 +22,7 @@ export interface QLDebugArgs {
extensionPacks?: string[] | string;
quickEval?: boolean;
noDebug?: boolean;
additionalArgs?: Record<string, any>;
}
/**
@@ -120,6 +121,7 @@ export class QLDebugConfigurationProvider
extensionPacks,
quickEvalContext,
noDebug: qlConfiguration.noDebug ?? false,
additionalArgs: qlConfiguration.additionalArgs ?? {},
};
return resultConfiguration;

View File

@@ -70,6 +70,8 @@ export interface LaunchConfig {
quickEvalContext: QuickEvalContext | undefined;
/** Run the query without debugging it. */
noDebug: boolean;
/** Undocumented: Additional arguments to be passed to the `runQuery` API on the query server. */
additionalArgs: Record<string, any>;
}
export interface LaunchRequest extends Request, DebugProtocol.LaunchRequest {

View File

@@ -161,6 +161,7 @@ class RunningQuery extends DisposableObject {
true,
config.additionalPacks,
config.extensionPacks,
config.additionalArgs,
queryStorageDir,
undefined,
undefined,

View File

@@ -44,6 +44,7 @@ export async function runContextualQuery(
false,
getOnDiskWorkspaceFolders(),
undefined,
{},
queryStorageDir,
undefined,
templates,

View File

@@ -456,6 +456,7 @@ export class LocalQueries extends DisposableObject {
true,
additionalPacks,
extensionPacks,
{},
this.queryStorageDir,
undefined,
templates,

View File

@@ -41,6 +41,7 @@ export async function runQuery({
false,
additionalPacks,
extensionPacks,
{},
queryStorageDir,
undefined,
undefined,

View File

@@ -65,6 +65,7 @@ export class LegacyQueryRunner extends QueryRunner {
query: CoreQueryTarget,
additionalPacks: string[],
extensionPacks: string[] | undefined,
_additionalRunQueryArgs: Record<string, any>, // Ignored in legacy query server
generateEvalLog: boolean,
outputDir: QueryOutputDir,
progress: ProgressCallback,

View File

@@ -75,6 +75,7 @@ export class NewQueryRunner extends QueryRunner {
query: CoreQueryTarget,
additionalPacks: string[],
extensionPacks: string[] | undefined,
additionalRunQueryArgs: Record<string, any>,
generateEvalLog: boolean,
outputDir: QueryOutputDir,
progress: ProgressCallback,
@@ -89,6 +90,7 @@ export class NewQueryRunner extends QueryRunner {
generateEvalLog,
additionalPacks,
extensionPacks,
additionalRunQueryArgs,
outputDir,
progress,
token,

View File

@@ -75,6 +75,7 @@ export abstract class QueryRunner {
query: CoreQueryTarget,
additionalPacks: string[],
extensionPacks: string[] | undefined,
additionalRunQueryArgs: Record<string, any>,
generateEvalLog: boolean,
outputDir: QueryOutputDir,
progress: ProgressCallback,
@@ -107,6 +108,7 @@ export abstract class QueryRunner {
generateEvalLog: boolean,
additionalPacks: string[],
extensionPacks: string[] | undefined,
additionalRunQueryArgs: Record<string, any>,
queryStorageDir: string,
id = `${basename(query.queryPath)}-${nanoid()}`,
templates: Record<string, string> | undefined,
@@ -133,6 +135,7 @@ export abstract class QueryRunner {
query,
additionalPacks,
extensionPacks,
additionalRunQueryArgs,
generateEvalLog,
outputDir,
progress,

View File

@@ -27,6 +27,7 @@ export async function compileAndRunQueryAgainstDatabaseCore(
generateEvalLog: boolean,
additionalPacks: string[],
extensionPacks: string[] | undefined,
additionalRunQueryArgs: Record<string, any>,
outputDir: QueryOutputDir,
progress: ProgressCallback,
token: CancellationToken,
@@ -55,6 +56,8 @@ export async function compileAndRunQueryAgainstDatabaseCore(
logPath: evalLogPath,
target,
extensionPacks,
// Add any additional arguments without interpretation.
...additionalRunQueryArgs,
};
// Update the active query logger every time there is a new request to compile.

View File

@@ -177,4 +177,27 @@ describeWithCodeQL()("Debugger", () => {
expect(editor.document.isDirty).toBe(false);
});
});
it("should pass additionalArgs through to query server", async () => {
await withDebugController(appCommands, async (controller) => {
await controller.startDebugging(
{
query: quickEvalQueryPath,
additionalArgs: {
// Overrides the value passed to the query server
queryPath: simpleQueryPath,
},
},
true,
);
await controller.expectLaunched();
const result = await controller.expectSucceeded();
await controller.expectExited();
await controller.expectTerminated();
await controller.expectSessionClosed();
// Expect the number of results to be the same as if we had run the simple query, not the quick eval query.
expect(await getResultCount(result.results.outputDir, cli)).toBe(2);
});
});
});