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
4 changes: 1 addition & 3 deletions resources/dark/status-error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions resources/dark/status-ok.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions resources/dark/status-unknown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/dark/stop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/light/status-error.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/light/status-ok.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions resources/light/status-unknown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion resources/light/stop.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/client/unittests/common/managers/baseTestManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { EventName } from '../../../telemetry/constants';
import { sendTelemetryEvent } from '../../../telemetry/index';
import { TestDiscoverytTelemetry, TestRunTelemetry } from '../../../telemetry/types';
import { IPythonUnitTestMessage, IUnitTestDiagnosticService, WorkspaceTestStatus } from '../../types';
import { copyTestResults } from '../testUtils';
import { copyDesiredTestResults } from '../testUtils';
import { CANCELLATION_REASON, CommandSource, TEST_OUTPUT_CHANNEL } from './../constants';
import {
ITestCollectionStorageService,
Expand Down Expand Up @@ -175,7 +175,7 @@ export abstract class BaseTestManager implements ITestManager {
if (clearTestStatus) {
this.resetTestResults();
} else if (existingTests) {
copyTestResults(existingTests, tests);
copyDesiredTestResults(existingTests, tests);
this._testResultsService.updateResults(tests);
}
this.testCollectionStorage.storeTests(wkspace, tests);
Expand Down
7 changes: 7 additions & 0 deletions src/client/unittests/common/services/testResultsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class TestResultsService implements ITestResultsService {
let totalTime = 0;
let allFilesPassed = true;
let noFilesRan = true;
testFolder.functionsPassed = testFolder.functionsFailed = testFolder.functionsDidNotRun = 0;

testFolder.testFiles.forEach(fl => {
totalTime += fl.time;
Expand All @@ -50,6 +51,7 @@ export class TestResultsService implements ITestResultsService {

testFolder.functionsFailed! += fl.functionsFailed!;
testFolder.functionsPassed! += fl.functionsPassed!;
testFolder.functionsDidNotRun! += fl.functionsDidNotRun!;
});

let allFoldersPassed = true;
Expand All @@ -67,6 +69,7 @@ export class TestResultsService implements ITestResultsService {

testFolder.functionsFailed! += folder.functionsFailed!;
testFolder.functionsPassed! += folder.functionsPassed!;
testFolder.functionsDidNotRun! += folder.functionsDidNotRun!;
});

testFolder.time = totalTime;
Expand All @@ -82,6 +85,7 @@ export class TestResultsService implements ITestResultsService {
let totalTime = 0;
let allFunctionsPassed = true;
let noFunctionsRan = true;
test.functionsPassed = test.functionsFailed = test.functionsDidNotRun = 0;

test.functions.forEach(fn => {
totalTime += fn.time;
Expand All @@ -93,6 +97,8 @@ export class TestResultsService implements ITestResultsService {
test.functionsFailed! += 1;
allFunctionsPassed = false;
}
} else {
test.functionsDidNotRun! += 1;
}
});

Expand All @@ -111,6 +117,7 @@ export class TestResultsService implements ITestResultsService {

test.functionsFailed! += suite.functionsFailed!;
test.functionsPassed! += suite.functionsPassed!;
test.functionsDidNotRun! += suite.functionsDidNotRun!;
});

test.time = totalTime;
Expand Down
14 changes: 10 additions & 4 deletions src/client/unittests/common/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class TestsHelper implements ITestsHelper {
newPath = path.join(parentPath, currentName);
}
if (!folderMap.has(newPath)) {
const testFolder: TestFolder = { resource, name: newPath, testFiles: [], folders: [], nameToRun: newPath, time: 0 };
const testFolder: TestFolder = { resource, name: newPath, testFiles: [], folders: [], nameToRun: newPath, time: 0, functionsPassed: 0, functionsFailed: 0, functionsDidNotRun: 0 };
folderMap.set(newPath, testFolder);
if (parentFolder) {
parentFolder!.folders.push(testFolder);
Expand Down Expand Up @@ -198,7 +198,7 @@ export class TestsHelper implements ITestsHelper {
}

// Just return this as a test file.
return { testFile: [{ resource: Uri.file(rootDirectory), name: name, nameToRun: name, functions: [], suites: [], xmlName: name, fullPath: '', time: 0 }] };
return { testFile: [{ resource: Uri.file(rootDirectory), name: name, nameToRun: name, functions: [], suites: [], xmlName: name, fullPath: '', time: 0, functionsPassed: 0, functionsFailed: 0, functionsDidNotRun: 0 }] };
}
public displayTestErrorMessage(message: string) {
this.appShell.showErrorMessage(message, constants.Button_Text_Tests_View_Output).then(action => {
Expand Down Expand Up @@ -482,7 +482,7 @@ export function isSubtestsParent(suite: TestSuite): boolean {
return subtestParent.asSuite === suite;
}

export function copyTestResults(source: Tests, target: Tests): void {
export function copyDesiredTestResults(source: Tests, target: Tests): void {
copyResultsForFolders(source.testFolders, target.testFolders);
}

Expand All @@ -494,6 +494,8 @@ function copyResultsForFolders(source: TestFolder[], target: TestFolder[]): void
}
copyValueTypes<TestFolder>(sourceFolder, targetFolder);
copyResultsForFiles(sourceFolder.testFiles, targetFolder.testFiles);
// These should be reinitialized
targetFolder.functionsPassed = targetFolder.functionsDidNotRun = targetFolder.functionsFailed = 0;
});
}
function copyResultsForFiles(source: TestFile[], target: TestFile[]): void {
Expand All @@ -505,6 +507,8 @@ function copyResultsForFiles(source: TestFile[], target: TestFile[]): void {
copyValueTypes<TestFile>(sourceFile, targetFile);
copyResultsForFunctions(sourceFile.functions, targetFile.functions);
copyResultsForSuites(sourceFile.suites, targetFile.suites);
// These should be reinitialized
targetFile.functionsPassed = targetFile.functionsDidNotRun = targetFile.functionsFailed = 0;
});
}

Expand All @@ -529,6 +533,8 @@ function copyResultsForSuites(source: TestSuite[], target: TestSuite[]): void {
copyValueTypes<TestSuite>(sourceSuite, targetSuite);
copyResultsForFunctions(sourceSuite.functions, targetSuite.functions);
copyResultsForSuites(sourceSuite.suites, targetSuite.suites);
// These should be reinitialized
targetSuite.functionsPassed = targetSuite.functionsDidNotRun = targetSuite.functionsFailed = 0;
});
}

Expand All @@ -539,4 +545,4 @@ function copyValueTypes<T>(source: T, target: T): void {
target[key] = value;
}
});
}
}
8 changes: 4 additions & 4 deletions src/client/unittests/explorer/testTreeViewItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ export class TestTreeItem extends TreeItem {
return '';
}
const result = this.data as TestResult;
if (!result.status || result.status === TestStatus.Idle || result.status === TestStatus.Unknown || result.status === TestStatus.Skipped){
if (!result.status || result.status === TestStatus.Idle || result.status === TestStatus.Unknown || result.status === TestStatus.Skipped) {
return '';
}
if (this.testType !== TestType.testFunction) {
return `${result.functionsFailed} failed, ${result.functionsPassed} passed in ${result.time} seconds`;
return `${result.functionsFailed} failed, ${result.functionsPassed} passed in ${+result.time.toFixed(3)} seconds`;
}
switch (this.data.status) {
case TestStatus.Error:
case TestStatus.Fail: {
return `Failed in ${result.time} seconds`;
return `Failed in ${+result.time.toFixed(3)} seconds`;
}
case TestStatus.Pass: {
return `Passed in ${result.time} seconds`;
return `Passed in ${+result.time.toFixed(3)} seconds`;
}
case TestStatus.Discovering:
case TestStatus.Running: {
Expand Down
2 changes: 2 additions & 0 deletions src/test/common/variables/envVarsProvider.multiroot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ suite('Multiroot Environment Variables Provider', () => {
});

test('Change event will be raised when when .env file is created, modified and deleted', async function () {
// tslint:disable-next-line:no-invalid-this
this.skip();
// tslint:disable-next-line:no-invalid-this
this.timeout(20000);
const env3 = path.join(workspace4Path.fsPath, '.env3');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

import * as assert from 'assert';
import { copyTestResults } from '../../../../client/unittests/common/testUtils';
import { copyDesiredTestResults } from '../../../../client/unittests/common/testUtils';
import { FlattenedTestFunction, FlattenedTestSuite, TestFile, TestFolder, TestFunction, Tests, TestStatus, TestSuite, TestType } from '../../../../client/unittests/common/types';
import { createMockTestDataItem } from '../testUtils.unit.test';

Expand Down Expand Up @@ -114,7 +114,7 @@ suite('Unit Tests - Storage Service', () => {
assert.notDeepEqual(testData1.testFunctions[1].testFunction, testData2.testFunctions[1].testFunction);
assert.notDeepEqual(testData1.testFunctions[2].testFunction, testData2.testFunctions[2].testFunction);

copyTestResults(testData1, testData2);
copyDesiredTestResults(testData1, testData2);

// Function 1 is in a different suite now, hence should not get updated.
assert.notDeepEqual(testData1.testFunctions[0].testFunction, testData2.testFunctions[0].testFunction);
Expand Down