From 65b797d8cc3cffc01438fecb93388ea855666e3e Mon Sep 17 00:00:00 2001 From: Johan Ahlqvist Date: Tue, 15 Jan 2019 01:26:36 +0100 Subject: [PATCH] CTest controller is updated on reconfig (related to issue #212). src/cmake-tools.ts ================== * CMakeTools.configure now executes CTestDriver.reloadTests src/driver.ts ============= * new function CMakeDriver.testfilePath Returns the path to CTestTestfile.cmake in the build directory * CMakeDriver._cleanPriorConfiguration Added the removal of CTestTestfile.cmake from the build directory. --- src/cmake-tools.ts | 1 + src/driver.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/cmake-tools.ts b/src/cmake-tools.ts index dd3add4fff..9e17937d46 100644 --- a/src/cmake-tools.ts +++ b/src/cmake-tools.ts @@ -528,6 +528,7 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI { if (retc === 0) { await this._refreshCompileDatabase(drv.expansionOptions); } + await this._ctestController.reloadTests(drv); this._onReconfiguredEmitter.fire(); return retc; } finally { diff --git a/src/driver.ts b/src/driver.ts index 1d1f027a0f..978b5026fd 100644 --- a/src/driver.ts +++ b/src/driver.ts @@ -272,6 +272,7 @@ export abstract class CMakeDriver implements vscode.Disposable { protected async _cleanPriorConfiguration() { const build_dir = this.binaryDir; const cache = this.cachePath; + const test_file = this.testFilePath; const cmake_files = path.join(build_dir, 'CMakeFiles'); if (await fs.exists(cache)) { log.info('Removing ', cache); @@ -281,6 +282,10 @@ export abstract class CMakeDriver implements vscode.Disposable { log.info('Removing ', cmake_files); await fs.rmdir(cmake_files); } + if (await fs.exists(test_file)) { + log.info('Removing ', test_file); + await fs.unlink(test_file); + } } /** @@ -411,6 +416,15 @@ export abstract class CMakeDriver implements vscode.Disposable { return util.lightNormalizePath(file); } + /** + * @brief Get the path to the CTestTestfile.cmake file in the build directory + */ + get testFilePath(): string { + // TODO: Test file path can change if build dir changes at runtime. + const file = path.join(this.binaryDir, 'CTestTestfile.cmake'); + return util.lightNormalizePath(file); + } + /** * Get the current build type, according to the current selected variant. *