forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
41 lines (40 loc) · 1.84 KB
/
main.ts
File metadata and controls
41 lines (40 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
import { Uri } from 'vscode';
import { PythonSettings } from '../../common/configSettings';
import { Product } from '../../common/types';
import { IServiceContainer } from '../../ioc/types';
import { BaseTestManager } from '../common/managers/baseTestManager';
import { TestDiscoveryOptions, TestRunOptions, Tests, TestsToRun } from '../common/types';
import { runTest } from './runner';
export class TestManager extends BaseTestManager {
public get enabled() {
return PythonSettings.getInstance(this.workspaceFolder).unitTest.pyTestEnabled;
}
constructor(workspaceFolder: Uri, rootDirectory: string,
serviceContainer: IServiceContainer) {
super('pytest', Product.pytest, workspaceFolder, rootDirectory, serviceContainer);
}
public getDiscoveryOptions(ignoreCache: boolean): TestDiscoveryOptions {
const args = this.settings.unitTest.pyTestArgs.slice(0);
return {
workspaceFolder: this.workspaceFolder,
cwd: this.rootDirectory, args,
token: this.testDiscoveryCancellationToken!, ignoreCache,
outChannel: this.outputChannel
};
}
public async runTestImpl(tests: Tests, testsToRun?: TestsToRun, runFailedTests?: boolean, debug?: boolean): Promise<{}> {
const args = this.settings.unitTest.pyTestArgs.slice(0);
if (runFailedTests === true && args.indexOf('--lf') === -1 && args.indexOf('--last-failed') === -1) {
args.push('--last-failed');
}
const options: TestRunOptions = {
workspaceFolder: this.workspaceFolder,
cwd: this.rootDirectory,
tests, args, testsToRun, debug,
token: this.testRunnerCancellationToken!,
outChannel: this.outputChannel
};
return runTest(this.serviceContainer, this.testResultsService, options);
}
}