Skip to content

Commit

Permalink
Run individual tests from the test view
Browse files Browse the repository at this point in the history
I added the ability to run individual tests from the test view. If the
user clicks the run button for a single test, CTest Lab only runs that
test via the ctest command.

closes #21
  • Loading branch information
brobeson committed Oct 9, 2022
1 parent 376f6fc commit 06cd15f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ This file documents all notable changes to the CTest Lab extension.
[#15](https://github.com/brobeson/ctest-lab/issues/15)
- Parse test results from `ctest` command output:
[#17](https://github.com/brobeson/ctest-lab/issues/15)
- Run individual tests from the test view:
[#21](https://github.com/brobeson/ctest-lab/issues/21)

### Removed

Expand Down
14 changes: 11 additions & 3 deletions src/test_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export async function run_tests(
test_queue.forEach((test) => run.started(test));

try {
const command_result = await run_all_tests(signal, log);
const command_result = await runCtestCommand(
signal,
log,
test_queue.length === 1 ? test_queue[0].label : undefined
);
const result_data = await test_results.load_test_results(
`${get_build_directory()}/${test_results_file}`
);
Expand All @@ -51,13 +55,17 @@ export async function run_tests(
run.end();
}

async function run_all_tests(
async function runCtestCommand(
signal: AbortSignal,
log: vscode.OutputChannel
log: vscode.OutputChannel,
testName?: string
): Promise<{ output: string; code: number | null }> {
return new Promise((resolve, reject) => {
const command = "ctest";
const args = ["--output-on-failure", "--output-junit", test_results_file];
if (testName) {
args.push("--tests-regex", testName);
}
log.appendLine(command + " " + args.join(" "));
const process = spawn(command, args, {
signal,
Expand Down

0 comments on commit 06cd15f

Please sign in to comment.