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
1 change: 1 addition & 0 deletions news/1 Enhancements/704.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disable the display of errors messages when rediscovering of tests fail in response to changes to files, e.g. don't show a message if there's a syntax error in the test code.
12 changes: 6 additions & 6 deletions src/client/unittests/display/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export class TestResultDisplay {
private discoverCounter = 0;
private ticker = ['|', '/', '-', '|', '/', '-', '\\'];
private progressTimeout;
private progressPrefix: string;
private progressPrefix!: string;
// tslint:disable-next-line:no-any
constructor(private outputChannel: vscode.OutputChannel, private onDidChange?: vscode.EventEmitter<any>) {
constructor(private onDidChange?: vscode.EventEmitter<any>) {
this.statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
}
public dispose() {
Expand All @@ -35,10 +35,10 @@ export class TestResultDisplay {
// tslint:disable-next-line:no-empty
.catch(() => { });
}
public displayDiscoverStatus(testDiscovery: Promise<Tests>) {
public displayDiscoverStatus(testDiscovery: Promise<Tests>, quietMode: boolean = false) {
this.displayProgress('Discovering Tests', 'Discovering Tests (Click to Stop)', constants.Commands.Tests_Ask_To_Stop_Discovery);
return testDiscovery.then(tests => {
this.updateWithDiscoverSuccess(tests);
this.updateWithDiscoverSuccess(tests, quietMode);
return tests;
}).catch(reason => {
this.updateWithDiscoverFailure(reason);
Expand Down Expand Up @@ -143,7 +143,7 @@ export class TestResultDisplay {
return def.promise;
}

private updateWithDiscoverSuccess(tests: Tests) {
private updateWithDiscoverSuccess(tests: Tests, quietMode: boolean = false) {
this.clearProgressTicker();
const haveTests = tests && (tests.testFunctions.length > 0);
this.statusBar.text = '$(zap) Run Tests';
Expand All @@ -154,7 +154,7 @@ export class TestResultDisplay {
this.onDidChange.fire();
}

if (!haveTests) {
if (!haveTests && !quietMode) {
vscode.window.showInformationMessage('No tests discovered, please check the configuration settings for the tests.', 'Disable Tests').then(item => {
if (item === 'Disable Tests') {
this.disableTests()
Expand Down
19 changes: 10 additions & 9 deletions src/client/unittests/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
import * as vscode from 'vscode';
// tslint:disable-next-line:no-duplicate-imports
import { Disposable, Uri, window, workspace } from 'vscode';
import { PythonSettings } from '../common/configSettings';
import * as constants from '../common/constants';
Expand Down Expand Up @@ -77,7 +78,7 @@ async function onDocumentSaved(doc: vscode.TextDocument): Promise<void> {
if (timeoutId) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(() => discoverTests(CommandSource.auto, doc.uri, true), 1000);
timeoutId = setTimeout(() => discoverTests(CommandSource.auto, doc.uri, true, false, true), 1000);
}

function dispose() {
Expand Down Expand Up @@ -157,7 +158,7 @@ async function selectAndRunTestMethod(cmdSource: CommandSource, resource: Uri, d
if (!selectedTestFn) {
return;
}
// tslint:disable-next-line:prefer-type-cast
// tslint:disable-next-line:prefer-type-cast no-object-literal-type-assertion
await runTestsImpl(cmdSource, testManager.workspaceFolder, { testFunction: [selectedTestFn.testFunction] } as TestsToRun, false, debug);
}
async function selectAndRunTestFile(cmdSource: CommandSource) {
Expand All @@ -177,7 +178,7 @@ async function selectAndRunTestFile(cmdSource: CommandSource) {
if (!selectedFile) {
return;
}
// tslint:disable-next-line:prefer-type-cast
// tslint:disable-next-line:prefer-type-cast no-object-literal-type-assertion
await runTestsImpl(cmdSource, testManager.workspaceFolder, { testFile: [selectedFile] } as TestsToRun);
}
async function runCurrentTestFile(cmdSource: CommandSource) {
Expand All @@ -200,7 +201,7 @@ async function runCurrentTestFile(cmdSource: CommandSource) {
if (testFiles.length < 1) {
return;
}
// tslint:disable-next-line:prefer-type-cast
// tslint:disable-next-line:prefer-type-cast no-object-literal-type-assertion
await runTestsImpl(cmdSource, testManager.workspaceFolder, { testFile: [testFiles[0]] } as TestsToRun);
}
async function displayStopUI(message: string) {
Expand Down Expand Up @@ -272,16 +273,16 @@ async function stopTests(resource: Uri) {
testManager.stop();
}
}
async function discoverTests(cmdSource: CommandSource, resource?: Uri, ignoreCache?: boolean, userInitiated?: boolean) {
async function discoverTests(cmdSource: CommandSource, resource?: Uri, ignoreCache?: boolean, userInitiated?: boolean, quietMode?: boolean) {
const testManager = await getTestManager(true, resource);
if (!testManager) {
return;
}

if (testManager && (testManager.status !== TestStatus.Discovering && testManager.status !== TestStatus.Running)) {
testResultDisplay = testResultDisplay ? testResultDisplay : new TestResultDisplay(outChannel, onDidChange);
const discoveryPromise = testManager.discoverTests(cmdSource, ignoreCache, false, userInitiated);
testResultDisplay.displayDiscoverStatus(discoveryPromise)
testResultDisplay = testResultDisplay ? testResultDisplay : new TestResultDisplay(onDidChange);
const discoveryPromise = testManager.discoverTests(cmdSource, ignoreCache, quietMode, userInitiated);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a change to this API, so I assume this is what false used to represent?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

testResultDisplay.displayDiscoverStatus(discoveryPromise, quietMode)
.catch(ex => console.error('Python Extension: displayDiscoverStatus', ex));
await discoveryPromise;
}
Expand All @@ -292,7 +293,7 @@ async function runTestsImpl(cmdSource: CommandSource, resource?: Uri, testsToRun
return;
}

testResultDisplay = testResultDisplay ? testResultDisplay : new TestResultDisplay(outChannel, onDidChange);
testResultDisplay = testResultDisplay ? testResultDisplay : new TestResultDisplay(onDidChange);
const promise = testManager.runTest(cmdSource, testsToRun, runFailedTests, debug)
.catch(reason => {
if (reason !== CANCELLATION_REASON) {
Expand Down