Skip to content

Commit

Permalink
Pass build config when running tests
Browse files Browse the repository at this point in the history
(Fixes issue #31)
  • Loading branch information
fredericbonnet committed May 22, 2021
1 parent 375daa5 commit 27d6e6c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/cmake-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,12 @@ export class CmakeAdapter implements TestAdapter {
// Get & substitute config settings
const [
buildDir,
buildConfig,
extraCtestRunArgs,
suiteDelimiter,
] = await this.getConfigStrings([
'buildDir',
'buildConfig',
'extraCtestRunArgs',
'suiteDelimiter',
]);
Expand All @@ -320,12 +322,13 @@ export class CmakeAdapter implements TestAdapter {
const testIndexes = this.getTestIndexes(tests, suiteDelimiter);

// Run tests
const cwd = path.resolve(this.workspaceFolder.uri.fsPath, buildDir);
const dir = path.resolve(this.workspaceFolder.uri.fsPath, buildDir);
this.currentTestProcess = scheduleCmakeTestProcess(
this.ctestPath,
cwd,
dir,
testIndexes,
parallelJobs,
buildConfig,
extraCtestRunArgs
);
let outputs: string[][] = [];
Expand Down
11 changes: 10 additions & 1 deletion src/cmake-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,15 @@ export function loadCmakeTests(
* @param cwd CMake build directory to run the command within
* @param testIndexes Test indexes to run (empty for all)
* @param parallelJobs Number of jobs to run in parallel
* @param buildConfig Build configuration (may be empty)
* @param extraArgs Extra arguments passed to CTest
*/
export function scheduleCmakeTestProcess(
ctestPath: string,
cwd: string,
testIndexes: number[],
parallelJobs: number,
buildConfig?: string,
extraArgs: string = ''
): CmakeTestProcess {
// Build options
Expand All @@ -161,7 +163,14 @@ export function scheduleCmakeTestProcess(

const testProcess = child_process.spawn(
ctestPath,
['-V', ...jobs, ...testList, ...args],

[
...(!!buildConfig ? ['--build-config', buildConfig] : []),
'-V',
...jobs,
...testList,
...args,
],
{ cwd }
);
if (!testProcess.pid) {
Expand Down

0 comments on commit 27d6e6c

Please sign in to comment.