Skip to content

Commit d4e9712

Browse files
committed
identify test pattern, fix #386
1 parent 81c631a commit d4e9712

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

‎src/client/unittests/unittest/collector.ts‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
'use strict';
2-
import {execPythonFile} from './../../common/utils';
3-
import {TestFile, TestsToRun, TestSuite, TestFunction, FlattenedTestFunction, Tests, TestStatus, FlattenedTestSuite} from '../common/contracts';
4-
import * as os from 'os';
5-
import {flattenTestFiles, updateResults} from '../common/testUtils';
2+
import { execPythonFile } from './../../common/utils';
3+
import { TestFile, Tests, TestStatus } from '../common/contracts';
4+
import { flattenTestFiles } from '../common/testUtils';
65
import * as vscode from 'vscode';
76
import * as path from 'path';
8-
import {PythonSettings} from '../../common/configSettings';
7+
import { PythonSettings } from '../../common/configSettings';
98

109
const pythonSettings = PythonSettings.getInstance();
1110

1211
export function discoverTests(rootDirectory: string, args: string[], token: vscode.CancellationToken): Promise<Tests> {
1312
let startDirectory = '.';
1413
let pattern = 'test*.py';
1514
const indexOfStartDir = args.findIndex(arg => arg.indexOf('-s') === 0);
16-
if (indexOfStartDir > 0) {
15+
if (indexOfStartDir >= 0) {
1716
const startDir = args[indexOfStartDir].trim();
1817
if (startDir.trim() === '-s' && args.length >= indexOfStartDir) {
1918
// Assume the next items is the directory
2019
startDirectory = args[indexOfStartDir + 1];
2120
}
2221
else {
2322
startDirectory = startDir.substring(2).trim();
24-
if (startDirectory.startsWith('=')) {
23+
if (startDirectory.startsWith('=') || startDirectory.startsWith(' ')) {
2524
startDirectory = startDirectory.substring(1);
2625
}
2726
}
2827
}
2928
const indexOfPattern = args.findIndex(arg => arg.indexOf('-p') === 0);
30-
if (indexOfPattern > 0) {
29+
if (indexOfPattern >= 0) {
3130
const patternValue = args[indexOfPattern].trim();
32-
if (patternValue.trim() === '-s' && args.length >= indexOfPattern) {
31+
if (patternValue.trim() === '-p' && args.length >= indexOfPattern) {
3332
// Assume the next items is the directory
3433
pattern = args[indexOfPattern + 1];
3534
}
@@ -91,7 +90,7 @@ for suite in suites._tests:
9190
function parseTestIds(rootDirectory: string, testIds: string[]): Tests {
9291
const testFiles: TestFile[] = [];
9392
testIds.forEach(testId => {
94-
addTestId(rootDirectory, testId, testFiles)
93+
addTestId(rootDirectory, testId, testFiles);
9594
});
9695

9796
return flattenTestFiles(testFiles);

0 commit comments

Comments
 (0)