Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 7 additions & 8 deletions src/zigTestRunnerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export default class ZigTestRunnerProvider {
}

private async buildTestBinary(run: vscode.TestRun, testFilePath: string, testDesc: string): Promise<string> {
const config = vscode.workspace.getConfiguration("zig");
const zigPath = zigProvider.getZigPath();
if (!zigPath) {
throw new Error("Unable to build test binary without Zig");
Expand All @@ -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<string[]>("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}`);
Expand Down