diff --git a/package.json b/package.json index 211cc92..3394eef 100644 --- a/package.json +++ b/package.json @@ -150,6 +150,21 @@ ], "description": "Arguments to pass to 'zig' for running tests. Supported variables: ${filter}, ${path}." }, + "zig.debugTestArgs": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "test", + "${path}", + "--test-filter", + "${filter}", + "--test-no-exec", + "-femit-bin=${binaryPath}" + ], + "description": "Arguments to pass to 'zig' for debugging tests. Supported variables: ${filter}, ${path}, ${binaryPath}." + }, "zig.debugAdapter": { "scope": "resource", "type": "string", diff --git a/src/zigTestRunnerProvider.ts b/src/zigTestRunnerProvider.ts index 73a01a3..0c16c07 100644 --- a/src/zigTestRunnerProvider.ts +++ b/src/zigTestRunnerProvider.ts @@ -212,6 +212,7 @@ export default class ZigTestRunnerProvider { } private async buildTestBinary(run: vscode.TestRun, testFilePath: string, testDesc: string): Promise { + const config = vscode.workspace.getConfiguration("zig"); const zigPath = zigProvider.getZigPath(); if (!zigPath) { throw new Error("Unable to build test binary without Zig"); @@ -223,14 +224,12 @@ export default class ZigTestRunnerProvider { const binaryPath = path.join(outputDir, binaryName); await vscode.workspace.fs.createDirectory(vscode.Uri.file(outputDir)); - const { stdout, stderr } = await execFile(zigPath, [ - "test", - testFilePath, - "--test-filter", - testDesc, - "--test-no-exec", - `-femit-bin=${binaryPath}`, - ]); + const debugTestArgsConf = config.get("debugTestArgs") ?? []; + const args = debugTestArgsConf.map((arg) => + arg.replace("${filter}", testDesc).replace("${path}", testFilePath).replace("${binaryPath}", binaryPath), + ); + + const { stdout, stderr } = await execFile(zigPath, args, { cwd: wsFolder }); if (stderr) { run.appendOutput(stderr.replaceAll("\n", "\r\n")); throw new Error(`Failed to build test binary: ${stderr}`);