Skip to content

Commit

Permalink
Ensure we clear the output channel for a build due to a test (#3499)
Browse files Browse the repository at this point in the history
* clean output before build during tests

* another test entry point

* refactor style

* refactor

* update changelog

---------

Co-authored-by: snehara99 <[email protected]>
  • Loading branch information
gcampbell-msft and snehara99 authored Jan 2, 2024
1 parent e123bc2 commit a8703f2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Bug Fixes:
- Ensure that the output is cleared for `debugTarget` and `launchTarget` [#3489](https://github.com/microsoft/vscode-cmake-tools/issues/3489)
- Fix the inheritance of the `environment` for CMakePresets. [#3473](https://github.com/microsoft/vscode-cmake-tools/issues/3473)
- Removed an unnecessary `console.assert` [#3474](https://github.com/microsoft/vscode-cmake-tools/issues/3474)
- Make sure we clear the output on builds due to test when `Clear output before build` is enabled. [#1179](https://github.com/microsoft/vscode-cmake-tools/issues/1179)
- Ensure that, when switching between presets, the CMake executable is modified. [#2791](https://github.com/microsoft/vscode-cmake-tools/issues/2791)

## 1.16.32
Expand Down
5 changes: 4 additions & 1 deletion src/cmakeProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import { setContextValue } from './util';
import { VariantManager } from './variant';
import * as nls from 'vscode-nls';
import { ConfigurationWebview } from './cacheView';
import { enableFullFeatureSet, updateFullFeatureSet } from './extension';
import { enableFullFeatureSet, extensionManager, updateFullFeatureSet } from './extension';
import { CMakeCommunicationMode, ConfigurationReader, OptionConfig, UseCMakePresets } from './config';
import * as preset from '@cmt/preset';
import * as util from '@cmt/util';
Expand Down Expand Up @@ -1910,6 +1910,9 @@ export class CMakeProject {
}

private async preTest(): Promise<CMakeDriver> {
if (extensionManager !== undefined && extensionManager !== null) {
extensionManager.cleanOutputChannel();
}
const buildResult = await this.build(undefined, false, false);
if (buildResult !== 0) {
throw new Error(localize('build.failed', 'Build failed.'));
Expand Down
4 changes: 4 additions & 0 deletions src/ctest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { testArgs, TestPreset } from './preset';
import { expandString } from './expand';
import * as proc from '@cmt/proc';
import { ProjectController } from './projectController';
import { extensionManager } from './extension';

nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
Expand Down Expand Up @@ -957,6 +958,9 @@ export class CTestDriver implements vscode.Disposable {
status = 1;
} else {
try {
if (extensionManager !== undefined && extensionManager !== null) {
extensionManager.cleanOutputChannel();
}
const buildResult = await project.build(undefined, false, false);
if (buildResult !== 0) {
status = 2;
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ export class ExtensionManager implements vscode.Disposable {
}
}

private cleanOutputChannel() {
cleanOutputChannel() {
if (this.workspaceConfig.clearOutputBeforeBuild) {
log.clearOutputChannel();
}
Expand Down

0 comments on commit a8703f2

Please sign in to comment.