Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to install modules using pip or conda #380

Merged
merged 151 commits into from
Dec 11, 2017
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
ecc1ca9
Fix Microsoft/vscode#37627 (#1368)
octref Nov 3, 2017
7c5778c
Version 0.7.0 of extension (#1381)
DonJayamanne Nov 9, 2017
9d1bf82
Update README.md
DonJayamanne Nov 9, 2017
ffba179
Update README.md
DonJayamanne Nov 9, 2017
905c713
sync fork with upstream
DonJayamanne Nov 10, 2017
acc2109
fix readme
DonJayamanne Nov 10, 2017
d470523
Merge branch 'master' of https://github.com/Microsoft/vscode-python
DonJayamanne Nov 16, 2017
d32a546
run without debugging
DonJayamanne Nov 15, 2017
3f14d0a
send terminated event when process ends and fix linters
DonJayamanne Nov 15, 2017
f37803f
gracefully handle program termination
DonJayamanne Nov 16, 2017
d69940e
use vscode infrastructure to launch code in terminals
DonJayamanne Nov 16, 2017
d392e8b
merged upstream
DonJayamanne Nov 16, 2017
11c9514
merged
DonJayamanne Nov 16, 2017
38befc0
ensure to check if launchArgs is not null
DonJayamanne Nov 16, 2017
bea91fc
ensure to check if launchArgs is not null
DonJayamanne Nov 16, 2017
0bb9054
ensure to check if launchArgs is not null
DonJayamanne Nov 16, 2017
a105a20
fix code review comments
DonJayamanne Nov 17, 2017
8b2fd7c
fixed code review comments
DonJayamanne Nov 17, 2017
5a7d21e
Merge branch 'master' into RunWithoutDebug
DonJayamanne Nov 17, 2017
acd90c5
Merge branch 'master' into RunWithoutDebug
DonJayamanne Nov 17, 2017
09b3359
fixes #250, do not copy all env variables
DonJayamanne Nov 17, 2017
9616eef
bug fix, launch using vscode and then fallback
DonJayamanne Nov 17, 2017
f9fe2a8
fix linter issue
DonJayamanne Nov 17, 2017
4963632
platform process services
DonJayamanne Nov 17, 2017
edbe63e
tests for decoder
DonJayamanne Nov 18, 2017
47acd08
tests for process service
DonJayamanne Nov 18, 2017
284e221
test to check source
DonJayamanne Nov 18, 2017
b27496b
tests for process utils
DonJayamanne Nov 20, 2017
92f775f
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 20, 2017
23fe3da
fix imports
DonJayamanne Nov 20, 2017
0277ca1
rename file
DonJayamanne Nov 20, 2017
bbc8290
environment variable parser
DonJayamanne Nov 21, 2017
29b5489
refactored variable services
DonJayamanne Nov 21, 2017
5e7a61b
environment variable caching service
DonJayamanne Nov 21, 2017
81af0e5
remove unwanted file
DonJayamanne Nov 21, 2017
e0ea914
process execution with unit tests
DonJayamanne Nov 21, 2017
f0c1978
process execution with unit tests
DonJayamanne Nov 21, 2017
32a6e53
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 21, 2017
4b30f2c
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 22, 2017
e396752
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 22, 2017
4c0bdb1
merged master
DonJayamanne Nov 22, 2017
3b71463
ensure env vars are always provided
DonJayamanne Nov 22, 2017
b5d9b1a
use range instead of xrange
DonJayamanne Nov 23, 2017
56ce88b
import reflect-metadata
DonJayamanne Nov 23, 2017
eff4792
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
4553c28
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
6382e96
added unit tests for python process and other services
DonJayamanne Nov 28, 2017
8ab2eb5
clean up of test runners and collectors
DonJayamanne Nov 28, 2017
39f272f
merged master
DonJayamanne Nov 28, 2017
b05a940
fix debugging unit tests and issue with used ports
DonJayamanne Nov 28, 2017
5049ed9
refactor code
DonJayamanne Nov 28, 2017
3c6520a
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
966e516
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
63d2d65
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
f6d469e
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
eced312
Merge branch 'master' into FixCodeExec
DonJayamanne Nov 29, 2017
ce930dc
fix for rx compilation issues
DonJayamanne Nov 29, 2017
53bbc1e
fixed linter issues and injected test debug launcher
DonJayamanne Nov 29, 2017
f0c4714
improvements to build scripts
DonJayamanne Nov 29, 2017
db0e778
update
DonJayamanne Nov 29, 2017
024509d
udpates to launc and tasks
DonJayamanne Nov 29, 2017
a32f846
add package-lock
DonJayamanne Nov 29, 2017
83a1ce5
fix linter errors
DonJayamanne Nov 29, 2017
560752b
add gulp-debounced-watch
DonJayamanne Nov 30, 2017
1addf10
refactor
DonJayamanne Nov 30, 2017
73c7c81
refactor unit tests to use DI
DonJayamanne Nov 30, 2017
07a8a18
read env variable instead on demand
DonJayamanne Nov 30, 2017
b4f5c10
refactor
DonJayamanne Nov 30, 2017
f14df93
fix #327, handle all promise rejections
DonJayamanne Nov 30, 2017
e856fe8
remove invalid item
DonJayamanne Nov 30, 2017
029e055
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 30, 2017
f0ba6d7
fixes to move interfaces around for DI
DonJayamanne Nov 30, 2017
6dcf879
improved bounce
DonJayamanne Nov 30, 2017
71c2531
bug fix
DonJayamanne Nov 30, 2017
e8c71c0
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 30, 2017
b5c51c4
merged master
DonJayamanne Nov 30, 2017
7e6ee4c
DI for unit tests
DonJayamanne Dec 1, 2017
51cf9d2
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 1, 2017
13df41b
perf improvement
DonJayamanne Dec 1, 2017
4968ebd
improvements
DonJayamanne Dec 1, 2017
7aadc43
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 1, 2017
aa4062e
incremental changes
DonJayamanne Dec 1, 2017
9ef2465
refactored
DonJayamanne Dec 1, 2017
0e15e8d
pytest tests
DonJayamanne Dec 1, 2017
5a60422
add tests for nosetests
DonJayamanne Dec 1, 2017
5cfb06f
added more nose tests
DonJayamanne Dec 2, 2017
b2b7dc6
better options
DonJayamanne Dec 2, 2017
35b8255
fix issue
DonJayamanne Dec 2, 2017
7854924
reduce tests
DonJayamanne Dec 2, 2017
d69fd1a
remove duplicate registration
DonJayamanne Dec 2, 2017
317cf88
use mock out put for format tests
DonJayamanne Dec 2, 2017
07e0710
debug
DonJayamanne Dec 2, 2017
9e0d27a
debug
DonJayamanne Dec 2, 2017
5a22791
Fix tests
DonJayamanne Dec 2, 2017
fec7d51
Merge branch 'master' into FixCodeExec
DonJayamanne Dec 2, 2017
0c4003f
Merge branch 'FixCodeExec' of https://github.com/DonJayamanne/pythonV…
DonJayamanne Dec 2, 2017
9d6194b
removed unused method
DonJayamanne Dec 2, 2017
34158ba
speed up gulp
DonJayamanne Dec 4, 2017
c823315
removed unwanted setting
DonJayamanne Dec 4, 2017
e349e56
ensure chai 4.0.6 is used in tsd
DonJayamanne Dec 4, 2017
a1fea85
fixes
DonJayamanne Dec 4, 2017
cb0a354
bitwise operations are allowed
DonJayamanne Dec 4, 2017
f0f5c59
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 4, 2017
c464a2a
merged
DonJayamanne Dec 4, 2017
011dca1
enforce eol in vscode
DonJayamanne Dec 4, 2017
bfb8036
enforce new line
DonJayamanne Dec 4, 2017
761f057
removed ts coding conventions
DonJayamanne Dec 4, 2017
b2b9da9
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 4, 2017
51b6c81
Use spaces instead of tabs
DonJayamanne Dec 4, 2017
7fd36fc
merged master
DonJayamanne Dec 4, 2017
ada46ba
added missing license headers and fix linter warnings
DonJayamanne Dec 4, 2017
c5e2d5d
fix code comments
DonJayamanne Dec 5, 2017
b756ee8
fix code comments
DonJayamanne Dec 5, 2017
30a4091
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 5, 2017
de14c78
merged
DonJayamanne Dec 5, 2017
22e90fb
use new execution framework in linters
DonJayamanne Dec 6, 2017
b16d2f9
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 6, 2017
d1079a2
merge master
DonJayamanne Dec 6, 2017
c0a2787
fix linter issues
DonJayamanne Dec 6, 2017
479a3c2
centralize creation of output channels
DonJayamanne Dec 6, 2017
514f654
bug fix
DonJayamanne Dec 6, 2017
2b3f2ef
code refactor
DonJayamanne Dec 6, 2017
51de97b
use new env vars parser with minor tweeks
DonJayamanne Dec 6, 2017
088fb6b
move installer into separate directory
DonJayamanne Dec 6, 2017
618421e
added conda installer
DonJayamanne Dec 7, 2017
0f24faa
add rope as a requirement for the tests
DonJayamanne Dec 7, 2017
c8db345
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 7, 2017
cf4fb98
merge master
DonJayamanne Dec 7, 2017
0a0fbb4
merge master
DonJayamanne Dec 7, 2017
951ce86
add conda module installer
DonJayamanne Dec 8, 2017
0df7f16
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 8, 2017
1e298d1
conda installer with necessary args
DonJayamanne Dec 8, 2017
a85724a
perf improvement
DonJayamanne Dec 8, 2017
7b30809
better ex handling
DonJayamanne Dec 8, 2017
b8b24f2
check conda versions
DonJayamanne Dec 8, 2017
ef33c16
fixes #378
DonJayamanne Dec 8, 2017
76e8fba
fix errors in conda installer
DonJayamanne Dec 9, 2017
3ccc881
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 9, 2017
cd328df
merge master
DonJayamanne Dec 9, 2017
2d859c9
fixed errors in merge
DonJayamanne Dec 9, 2017
d18575e
fixed unit tests
DonJayamanne Dec 9, 2017
c1ab174
Fixed tests
DonJayamanne Dec 9, 2017
bdf9ebd
remove unwanted test
DonJayamanne Dec 9, 2017
a5de30d
fix review comments, disable format check (not working on win)
DonJayamanne Dec 11, 2017
31b3dd7
Merge branch 'master' into CondaModuleInstaller
DonJayamanne Dec 11, 2017
4ae4cd7
Merge branch 'master' into CondaModuleInstaller
DonJayamanne Dec 11, 2017
e3ac25d
fixed typo
DonJayamanne Dec 11, 2017
33f4232
Merge branch 'CondaModuleInstaller' of https://github.com/DonJayamann…
DonJayamanne Dec 11, 2017
39f77bc
Fix unit test (send unicode output as unicode string)
DonJayamanne Dec 11, 2017
89373bb
reverted change to test oopsy
DonJayamanne Dec 11, 2017
b5a3bae
added missing period
DonJayamanne Dec 11, 2017
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: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ const hygiene = (options) => {
.pipe(filter(tslintFilter));

if (!options.skipFormatCheck) {
result = result
.pipe(formatting);
// result = result
Copy link
Member

Choose a reason for hiding this comment

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

Left in commented-out code.

// .pipe(formatting);
}

if (!options.skipLinter) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/installer/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export class Installer implements IInstaller {
if (channels.length === 1) {
return channels[0];
}
const placeHolder = `Select an options to install ${productName}`;
const placeHolder = `Select an option to install ${productName}`;
const options = channels.map(installer => {
return {
label: `Install using ${installer.displayName}`,
Expand Down
12 changes: 6 additions & 6 deletions src/client/common/platform/registry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { injectable } from 'inversify';
import 'reflect-metadata';
import * as Registry from 'winreg';
import { Architecture, Hive, IRegistry } from './types';
import { Architecture, IRegistry, RegistryHive } from './types';

enum RegistryArchitectures {
x86 = 'x86',
Expand All @@ -10,10 +10,10 @@ enum RegistryArchitectures {

@injectable()
export class RegistryImplementation implements IRegistry {
public async getKeys(key: string, hive: Hive, arch?: Architecture) {
public async getKeys(key: string, hive: RegistryHive, arch?: Architecture) {
return getRegistryKeys({ hive: translateHive(hive)!, arch: translateArchitecture(arch), key });
}
public async getValue(key: string, hive: Hive, arch?: Architecture, name: string = '') {
public async getValue(key: string, hive: RegistryHive, arch?: Architecture, name: string = '') {
return getRegistryValue({ hive: translateHive(hive)!, arch: translateArchitecture(arch), key }, name);
}
}
Expand Down Expand Up @@ -60,11 +60,11 @@ function translateArchitecture(arch?: Architecture): RegistryArchitectures | und
return;
}
}
function translateHive(hive: Hive): string | undefined {
function translateHive(hive: RegistryHive): string | undefined {
switch (hive) {
case Hive.HKCU:
case RegistryHive.HKCU:
return Registry.HKCU;
case Hive.HKLM:
case RegistryHive.HKLM:
return Registry.HKLM;
default:
return;
Expand Down
6 changes: 3 additions & 3 deletions src/client/common/platform/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ export enum Architecture {
x86 = 2,
x64 = 3
}
export enum Hive {
export enum RegistryHive {
HKCU, HKLM
}

export const IRegistry = Symbol('IRegistry');

export interface IRegistry {
getKeys(key: string, hive: Hive, arch?: Architecture): Promise<string[]>;
getValue(key: string, hive: Hive, arch?: Architecture, name?: string): Promise<string | undefined | null>;
getKeys(key: string, hive: RegistryHive, arch?: Architecture): Promise<string[]>;
getValue(key: string, hive: RegistryHive, arch?: Architecture, name?: string): Promise<string | undefined | null>;
}
2 changes: 1 addition & 1 deletion src/client/common/terminal/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class TerminalService implements ITerminalService {
this.terminal.show(false);

// Sometimes the terminal takes some time to start up before it can start accepting input.
// However if we have already sent text to the terminal, then no need to wait
// However if we have already sent text to the terminal, then no need to wait.
if (!this.textPreviouslySentToTerminal) {
await new Promise(resolve => setTimeout(resolve, 1000));
}
Expand Down
1 change: 0 additions & 1 deletion src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { registerTypes as commonRegisterTypes } from './common/serviceRegistry';
import { GLOBAL_MEMENTO, IDisposableRegistry, ILogger, IMemento, IOutputChannel, IPersistentStateFactory, WORKSPACE_MEMENTO } from './common/types';
import { registerTypes as variableRegisterTypes } from './common/variables/serviceRegistry';
import { SimpleConfigurationProvider } from './debugger';
import { FeedbackService } from './feedback';
import { registerTypes as formattersRegisterTypes } from './formatters/serviceRegistry';
import { InterpreterManager } from './interpreter';
import { SetInterpreterProvider } from './interpreter/configuration/setInterpreterProvider';
Expand Down
20 changes: 10 additions & 10 deletions src/client/interpreter/locators/services/windowsRegistryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { inject, injectable } from 'inversify';
import * as _ from 'lodash';
import * as path from 'path';
import { Uri } from 'vscode';
import { Architecture, Hive, IRegistry } from '../../../common/platform/types';
import { Architecture, IRegistry, RegistryHive } from '../../../common/platform/types';
import { Is64Bit } from '../../../common/types';
import { IInterpreterLocatorService, InterpreterType, PythonInterpreter } from '../../contracts';

Expand All @@ -18,7 +18,7 @@ const PythonCoreComany = 'PYTHONCORE';

type CompanyInterpreter = {
companyKey: string,
hive: Hive,
hive: RegistryHive,
arch?: Architecture
};

Expand All @@ -37,12 +37,12 @@ export class WindowsRegistryService implements IInterpreterLocatorService {
// https://github.com/python/peps/blob/master/pep-0514.txt#L357
const hkcuArch = this.is64Bit ? undefined : Architecture.x86;
const promises: Promise<CompanyInterpreter[]>[] = [
this.getCompanies(Hive.HKCU, hkcuArch),
this.getCompanies(Hive.HKLM, Architecture.x86)
this.getCompanies(RegistryHive.HKCU, hkcuArch),
this.getCompanies(RegistryHive.HKLM, Architecture.x86)
];
// https://github.com/Microsoft/PTVS/blob/ebfc4ca8bab234d453f15ee426af3b208f3c143c/Python/Product/Cookiecutter/Shared/Interpreters/PythonRegistrySearch.cs#L44
if (this.is64Bit) {
promises.push(this.getCompanies(Hive.HKLM, Architecture.x64));
promises.push(this.getCompanies(RegistryHive.HKLM, Architecture.x64));
}

const companies = await Promise.all<CompanyInterpreter[]>(promises);
Expand All @@ -65,19 +65,19 @@ export class WindowsRegistryService implements IInterpreterLocatorService {
return prev;
}, []);
}
private async getCompanies(hive: Hive, arch?: Architecture): Promise<CompanyInterpreter[]> {
private async getCompanies(hive: RegistryHive, arch?: Architecture): Promise<CompanyInterpreter[]> {
return this.registry.getKeys('\\Software\\Python', hive, arch)
.then(companyKeys => companyKeys
.filter(companyKey => CompaniesToIgnore.indexOf(path.basename(companyKey).toUpperCase()) === -1)
.map(companyKey => {
return { companyKey, hive, arch };
}));
}
private async getInterpretersForCompany(companyKey: string, hive: Hive, arch?: Architecture) {
private async getInterpretersForCompany(companyKey: string, hive: RegistryHive, arch?: Architecture) {
const tagKeys = await this.registry.getKeys(companyKey, hive, arch);
return Promise.all(tagKeys.map(tagKey => this.getInreterpreterDetailsForCompany(tagKey, companyKey, hive, arch)));
}
private getInreterpreterDetailsForCompany(tagKey: string, companyKey: string, hive: Hive, arch?: Architecture): Promise<PythonInterpreter | undefined | null> {
private getInreterpreterDetailsForCompany(tagKey: string, companyKey: string, hive: RegistryHive, arch?: Architecture): Promise<PythonInterpreter | undefined | null> {
const key = `${tagKey}\\InstallPath`;
type InterpreterInformation = null | undefined | {
installPath: string,
Expand Down Expand Up @@ -133,13 +133,13 @@ export class WindowsRegistryService implements IInterpreterLocatorService {
return null;
});
}
private async getInterpreterDisplayName(tagKey: string, companyKey: string, hive: Hive, arch?: Architecture) {
private async getInterpreterDisplayName(tagKey: string, companyKey: string, hive: RegistryHive, arch?: Architecture) {
const displayName = await this.registry.getValue(tagKey, hive, arch, 'DisplayName');
if (displayName && displayName.length > 0) {
return displayName;
}
}
private async getCompanyDisplayName(companyKey: string, hive: Hive, arch?: Architecture) {
private async getCompanyDisplayName(companyKey: string, hive: RegistryHive, arch?: Architecture) {
const displayName = await this.registry.getValue(companyKey, hive, arch, 'DisplayName');
if (displayName && displayName.length > 0) {
return displayName;
Expand Down
8 changes: 4 additions & 4 deletions src/client/linters/errorHandlers/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import { ModuleNotInstalledErrorHandler } from './notInstalled';
import { StandardErrorHandler } from './standard';

export class ErrorHandler implements IErrorHandler {
private handlder: BaseErrorHandler;
private handler: BaseErrorHandler;
constructor(product: Product, installer: IInstaller,
helper: ILinterHelper, logger: ILogger,
outputChannel: OutputChannel, serviceContainer: IServiceContainer) {
// Create chain of handlers.
const standardErrorHandler = new StandardErrorHandler(product, installer, helper, logger, outputChannel, serviceContainer);
this.handlder = new ModuleNotInstalledErrorHandler(product, installer, helper, logger, outputChannel, serviceContainer);
this.handlder.setNextHandler(standardErrorHandler);
this.handler = new ModuleNotInstalledErrorHandler(product, installer, helper, logger, outputChannel, serviceContainer);
this.handler.setNextHandler(standardErrorHandler);
}

public handleError(error: Error, resource: Uri, execInfo: ExecutionInfo): Promise<boolean> {
return this.handlder.handleError(error, resource, execInfo);
return this.handler.handleError(error, resource, execInfo);
}
}
24 changes: 16 additions & 8 deletions src/test/common/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,41 @@ suite('ChildProc', () => {
test('Stream Stdout', done => {
const output: string[] = [];
function handleOutput(data: string) {
output.push(data);
if (data.trim().length > 0) {
output.push(data.trim());
}
}
execPythonFile(undefined, 'python', ['-c', 'print(1)'], __dirname, false, handleOutput).then(() => {
assert.equal(output.length, 1, 'Ouput length incorrect');
assert.equal(output[0], `1${EOL}`, 'Ouput value incorrect');
assert.equal(output[0], '1', 'Ouput value incorrect');
}).then(done).catch(done);
});

test('Stream Stdout (Unicode)', async () => {
const output: string[] = [];
function handleOutput(data: string) {
output.push(data);
if (data.trim().length > 0) {
output.push(data.trim());
}
}
await execPythonFile(undefined, 'python', ['-c', 'print(\'öä\')'], __dirname, false, handleOutput);
assert.equal(output.length, 1, 'Ouput length incorrect');
assert.equal(output[0], `öä${EOL}`, 'Ouput value incorrect');
assert.equal(output[0], 'öä', 'Ouput value incorrect');
});

test('Stream Stdout with Threads', function (done) {
// tslint:disable-next-line:no-invalid-this
this.timeout(6000);
const output: string[] = [];
function handleOutput(data: string) {
output.push(data);
if (data.trim().length > 0) {
output.push(data.trim());
}
}
execPythonFile(undefined, 'python', ['-c', 'import sys\nprint(1)\nsys.__stdout__.flush()\nimport time\ntime.sleep(5)\nprint(2)'], __dirname, false, handleOutput).then(() => {
assert.equal(output.length, 2, 'Ouput length incorrect');
assert.equal(output[0], `1${EOL}`, 'First Ouput value incorrect');
assert.equal(output[1], `2${EOL}`, 'Second Ouput value incorrect');
assert.equal(output[0], '1', 'First Ouput value incorrect');
assert.equal(output[1], '2', 'Second Ouput value incorrect');
}).then(done).catch(done);
});

Expand All @@ -66,7 +72,9 @@ suite('ChildProc', () => {
const def = createDeferred<any>();
const output: string[] = [];
function handleOutput(data: string) {
output.push(data);
if (data.trim().length > 0) {
output.push(data.trim());
}
}
const cancellation = new vscode.CancellationTokenSource();
execPythonFile(undefined, 'python', ['-c', 'import sys\nprint(1)\nsys.__stdout__.flush()\nimport time\ntime.sleep(5)\nprint(2)'], __dirname, false, handleOutput, cancellation.token).then(() => {
Expand Down
10 changes: 5 additions & 5 deletions src/test/interpreters/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Architecture, Hive, IRegistry } from '../../client/common/platform/types';
import { Architecture, IRegistry, RegistryHive } from '../../client/common/platform/types';
import { IProcessService } from '../../client/common/process/types';
import { IInterpreterLocatorService, IInterpreterVersionService, InterpreterType, PythonInterpreter } from '../../client/interpreter/contracts';
import { CondaLocatorService } from '../../client/interpreter/locators/services/condaLocator';
Expand All @@ -15,10 +15,10 @@ export class MockProvider implements IInterpreterLocatorService {
}

export class MockRegistry implements IRegistry {
constructor(private keys: { key: string, hive: Hive, arch?: Architecture, values: string[] }[],
private values: { key: string, hive: Hive, arch?: Architecture, value: string, name?: string }[]) {
constructor(private keys: { key: string, hive: RegistryHive, arch?: Architecture, values: string[] }[],
private values: { key: string, hive: RegistryHive, arch?: Architecture, value: string, name?: string }[]) {
}
public async getKeys(key: string, hive: Hive, arch?: Architecture): Promise<string[]> {
public async getKeys(key: string, hive: RegistryHive, arch?: Architecture): Promise<string[]> {
const items = this.keys.find(item => {
if (typeof item.arch === 'number') {
return item.key === key && item.hive === hive && item.arch === arch;
Expand All @@ -28,7 +28,7 @@ export class MockRegistry implements IRegistry {

return items ? Promise.resolve(items.values) : Promise.resolve([]);
}
public async getValue(key: string, hive: Hive, arch?: Architecture, name?: string): Promise<string | undefined | null> {
public async getValue(key: string, hive: RegistryHive, arch?: Architecture, name?: string): Promise<string | undefined | null> {
const items = this.values.find(item => {
if (item.key !== key || item.hive !== hive) {
return false;
Expand Down
Loading