|
1 | 1 | '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'; |
6 | 5 | import * as vscode from 'vscode'; |
7 | 6 | import * as path from 'path'; |
8 | | -import {PythonSettings} from '../../common/configSettings'; |
| 7 | +import { PythonSettings } from '../../common/configSettings'; |
9 | 8 |
|
10 | 9 | const pythonSettings = PythonSettings.getInstance(); |
11 | 10 |
|
12 | 11 | export function discoverTests(rootDirectory: string, args: string[], token: vscode.CancellationToken): Promise<Tests> { |
13 | 12 | let startDirectory = '.'; |
14 | 13 | let pattern = 'test*.py'; |
15 | 14 | const indexOfStartDir = args.findIndex(arg => arg.indexOf('-s') === 0); |
16 | | - if (indexOfStartDir > 0) { |
| 15 | + if (indexOfStartDir >= 0) { |
17 | 16 | const startDir = args[indexOfStartDir].trim(); |
18 | 17 | if (startDir.trim() === '-s' && args.length >= indexOfStartDir) { |
19 | 18 | // Assume the next items is the directory |
20 | 19 | startDirectory = args[indexOfStartDir + 1]; |
21 | 20 | } |
22 | 21 | else { |
23 | 22 | startDirectory = startDir.substring(2).trim(); |
24 | | - if (startDirectory.startsWith('=')) { |
| 23 | + if (startDirectory.startsWith('=') || startDirectory.startsWith(' ')) { |
25 | 24 | startDirectory = startDirectory.substring(1); |
26 | 25 | } |
27 | 26 | } |
28 | 27 | } |
29 | 28 | const indexOfPattern = args.findIndex(arg => arg.indexOf('-p') === 0); |
30 | | - if (indexOfPattern > 0) { |
| 29 | + if (indexOfPattern >= 0) { |
31 | 30 | const patternValue = args[indexOfPattern].trim(); |
32 | | - if (patternValue.trim() === '-s' && args.length >= indexOfPattern) { |
| 31 | + if (patternValue.trim() === '-p' && args.length >= indexOfPattern) { |
33 | 32 | // Assume the next items is the directory |
34 | 33 | pattern = args[indexOfPattern + 1]; |
35 | 34 | } |
@@ -91,7 +90,7 @@ for suite in suites._tests: |
91 | 90 | function parseTestIds(rootDirectory: string, testIds: string[]): Tests { |
92 | 91 | const testFiles: TestFile[] = []; |
93 | 92 | testIds.forEach(testId => { |
94 | | - addTestId(rootDirectory, testId, testFiles) |
| 93 | + addTestId(rootDirectory, testId, testFiles); |
95 | 94 | }); |
96 | 95 |
|
97 | 96 | return flattenTestFiles(testFiles); |
|
0 commit comments