Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
8697d1b3
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8697d1b3
编写于
4月 16, 2018
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add back terminal env/cwd tests
上级
036a087a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
168 addition
and
215 deletion
+168
-215
src/vs/workbench/parts/terminal/test/electron-browser/terminalEnvironment.test.ts
...erminal/test/electron-browser/terminalEnvironment.test.ts
+168
-0
src/vs/workbench/parts/terminal/test/electron-browser/terminalInstance.test.ts
...s/terminal/test/electron-browser/terminalInstance.test.ts
+0
-215
未找到文件。
src/vs/workbench/parts/terminal/test/electron-browser/terminalEnvironment.test.ts
0 → 100644
浏览文件 @
8697d1b3
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
*
as
assert
from
'
assert
'
;
import
*
as
os
from
'
os
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
terminalEnvironment
from
'
vs/workbench/parts/terminal/electron-browser/terminalEnvironment
'
;
import
Uri
from
'
vs/base/common/uri
'
;
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
IShellLaunchConfig
,
ITerminalConfigHelper
}
from
'
vs/workbench/parts/terminal/common/terminal
'
;
suite
(
'
Workbench - TerminalEnvironment
'
,
()
=>
{
test
(
'
createTerminalEnv
'
,
function
()
{
const
shell1
=
{
executable
:
'
/bin/foosh
'
,
args
:
[
'
-bar
'
,
'
baz
'
]
};
const
parentEnv1
:
IStringDictionary
<
string
>
=
{
ok
:
true
}
as
any
;
const
env1
=
terminalEnvironment
.
createTerminalEnv
(
parentEnv1
,
shell1
,
'
/foo
'
,
'
en-au
'
);
assert
.
ok
(
env1
[
'
ok
'
],
'
Parent environment is copied
'
);
assert
.
deepStrictEqual
(
parentEnv1
,
{
ok
:
true
},
'
Parent environment is unchanged
'
);
assert
.
equal
(
env1
[
'
PTYPID
'
],
process
.
pid
.
toString
(),
'
PTYPID is equal to the current PID
'
);
assert
.
equal
(
env1
[
'
PTYSHELL
'
],
'
/bin/foosh
'
,
'
PTYSHELL is equal to the provided shell
'
);
assert
.
equal
(
env1
[
'
PTYSHELLARG0
'
],
'
-bar
'
,
'
PTYSHELLARG0 is equal to the first shell argument
'
);
assert
.
equal
(
env1
[
'
PTYSHELLARG1
'
],
'
baz
'
,
'
PTYSHELLARG1 is equal to the first shell argument
'
);
assert
.
ok
(
!
(
'
PTYSHELLARG2
'
in
env1
),
'
PTYSHELLARG2 is unset
'
);
assert
.
equal
(
env1
[
'
PTYCWD
'
],
'
/foo
'
,
'
PTYCWD is equal to requested cwd
'
);
assert
.
equal
(
env1
[
'
LANG
'
],
'
en_AU.UTF-8
'
,
'
LANG is equal to the requested locale with UTF-8
'
);
const
shell2
:
IShellLaunchConfig
=
{
executable
:
'
/bin/foosh
'
,
args
:
[]
};
const
parentEnv2
:
IStringDictionary
<
string
>
=
{
LANG
:
'
en_US.UTF-8
'
};
const
env2
=
terminalEnvironment
.
createTerminalEnv
(
parentEnv2
,
shell2
,
'
/foo
'
,
'
en-au
'
);
assert
.
ok
(
!
(
'
PTYSHELLARG0
'
in
env2
),
'
PTYSHELLARG0 is unset
'
);
assert
.
equal
(
env2
[
'
PTYCWD
'
],
'
/foo
'
,
'
PTYCWD is equal to /foo
'
);
assert
.
equal
(
env2
[
'
LANG
'
],
'
en_AU.UTF-8
'
,
'
LANG is equal to the requested locale with UTF-8
'
);
const
env3
=
terminalEnvironment
.
createTerminalEnv
(
parentEnv1
,
shell1
,
'
/
'
,
null
);
assert
.
equal
(
env3
[
'
LANG
'
],
'
en_US.UTF-8
'
,
'
LANG is equal to en_US.UTF-8 as fallback.
'
);
// More info on issue #14586
const
env4
=
terminalEnvironment
.
createTerminalEnv
(
parentEnv2
,
shell1
,
'
/
'
,
null
);
assert
.
equal
(
env4
[
'
LANG
'
],
'
en_US.UTF-8
'
,
'
LANG is equal to the parent environment
\'
s LANG
'
);
});
suite
(
'
mergeEnvironments
'
,
()
=>
{
test
(
'
should add keys
'
,
()
=>
{
const
parent
=
{
a
:
'
b
'
};
const
other
=
{
c
:
'
d
'
};
terminalEnvironment
.
mergeEnvironments
(
parent
,
other
);
assert
.
deepEqual
(
parent
,
{
a
:
'
b
'
,
c
:
'
d
'
});
});
test
(
'
should add keys ignoring case on Windows
'
,
()
=>
{
if
(
!
platform
.
isWindows
)
{
return
;
}
const
parent
=
{
a
:
'
b
'
};
const
other
=
{
A
:
'
c
'
};
terminalEnvironment
.
mergeEnvironments
(
parent
,
other
);
assert
.
deepEqual
(
parent
,
{
a
:
'
c
'
});
});
test
(
'
null values should delete keys from the parent env
'
,
()
=>
{
const
parent
=
{
a
:
'
b
'
,
c
:
'
d
'
};
const
other
:
IStringDictionary
<
string
>
=
{
a
:
null
};
terminalEnvironment
.
mergeEnvironments
(
parent
,
other
);
assert
.
deepEqual
(
parent
,
{
c
:
'
d
'
});
});
test
(
'
null values should delete keys from the parent env ignoring case on Windows
'
,
()
=>
{
if
(
!
platform
.
isWindows
)
{
return
;
}
const
parent
=
{
a
:
'
b
'
,
c
:
'
d
'
};
const
other
:
IStringDictionary
<
string
>
=
{
A
:
null
};
terminalEnvironment
.
mergeEnvironments
(
parent
,
other
);
assert
.
deepEqual
(
parent
,
{
c
:
'
d
'
});
});
});
suite
(
'
getCwd
'
,
()
=>
{
let
configHelper
:
ITerminalConfigHelper
;
setup
(()
=>
{
configHelper
=
<
ITerminalConfigHelper
>
{
config
:
{
cwd
:
null
}
};
});
// This helper checks the paths in a cross-platform friendly manner
function
assertPathsMatch
(
a
:
string
,
b
:
string
):
void
{
assert
.
equal
(
Uri
.
file
(
a
).
fsPath
,
Uri
.
file
(
b
).
fsPath
);
}
test
(
'
should default to os.homedir() for an empty workspace
'
,
()
=>
{
assertPathsMatch
(
terminalEnvironment
.
getCwd
({
executable
:
null
,
args
:
[]
},
null
,
configHelper
),
os
.
homedir
());
});
test
(
'
should use to the workspace if it exists
'
,
()
=>
{
assertPathsMatch
(
terminalEnvironment
.
getCwd
({
executable
:
null
,
args
:
[]
},
Uri
.
file
(
'
/foo
'
),
configHelper
),
'
/foo
'
);
});
test
(
'
should use an absolute custom cwd as is
'
,
()
=>
{
configHelper
.
config
.
cwd
=
'
/foo
'
;
assertPathsMatch
(
terminalEnvironment
.
getCwd
({
executable
:
null
,
args
:
[]
},
null
,
configHelper
),
'
/foo
'
);
});
test
(
'
should normalize a relative custom cwd against the workspace path
'
,
()
=>
{
configHelper
.
config
.
cwd
=
'
foo
'
;
assertPathsMatch
(
terminalEnvironment
.
getCwd
({
executable
:
null
,
args
:
[]
},
Uri
.
file
(
'
/bar
'
),
configHelper
),
'
/bar/foo
'
);
configHelper
.
config
.
cwd
=
'
./foo
'
;
assertPathsMatch
(
terminalEnvironment
.
getCwd
({
executable
:
null
,
args
:
[]
},
Uri
.
file
(
'
/bar
'
),
configHelper
),
'
/bar/foo
'
);
configHelper
.
config
.
cwd
=
'
../foo
'
;
assertPathsMatch
(
terminalEnvironment
.
getCwd
({
executable
:
null
,
args
:
[]
},
Uri
.
file
(
'
/bar
'
),
configHelper
),
'
/foo
'
);
});
test
(
'
should fall back for relative a custom cwd that doesn
\'
t have a workspace
'
,
()
=>
{
configHelper
.
config
.
cwd
=
'
foo
'
;
assertPathsMatch
(
terminalEnvironment
.
getCwd
({
executable
:
null
,
args
:
[]
},
null
,
configHelper
),
os
.
homedir
());
configHelper
.
config
.
cwd
=
'
./foo
'
;
assertPathsMatch
(
terminalEnvironment
.
getCwd
({
executable
:
null
,
args
:
[]
},
null
,
configHelper
),
os
.
homedir
());
configHelper
.
config
.
cwd
=
'
../foo
'
;
assertPathsMatch
(
terminalEnvironment
.
getCwd
({
executable
:
null
,
args
:
[]
},
null
,
configHelper
),
os
.
homedir
());
});
test
(
'
should ignore custom cwd when told to ignore
'
,
()
=>
{
configHelper
.
config
.
cwd
=
'
/foo
'
;
assertPathsMatch
(
terminalEnvironment
.
getCwd
({
executable
:
null
,
args
:
[],
ignoreConfigurationCwd
:
true
},
Uri
.
file
(
'
/bar
'
),
configHelper
),
'
/bar
'
);
});
});
});
\ No newline at end of file
src/vs/workbench/parts/terminal/test/electron-browser/terminalInstance.test.ts
已删除
100644 → 0
浏览文件 @
036a087a
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// 'use strict';
// import * as assert from 'assert';
// import * as os from 'os';
// import * as platform from 'vs/base/common/platform';
// import Uri from 'vs/base/common/uri';
// import { IStringDictionary } from 'vs/base/common/collections';
// import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
// import { TerminalInstance } from 'vs/workbench/parts/terminal/electron-browser/terminalInstance';
// import { IShellLaunchConfig } from 'vs/workbench/parts/terminal/common/terminal';
// import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
// import { TestNotificationService, TestContextService, TestHistoryService } from 'vs/workbench/test/workbenchTestServices';
// import { MockContextKeyService, MockKeybindingService } from 'vs/platform/keybinding/test/common/mockKeybindingService';
// import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
// import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
// import { IHistoryService } from 'vs/workbench/services/history/common/history';
// import { TPromise } from 'vs/base/common/winjs.base';
// import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService';
// import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
// import { INotificationService } from 'vs/platform/notification/common/notification';
// import { ILogService, NullLogService } from 'vs/platform/log/common/log';
// class TestTerminalInstance extends TerminalInstance {
// public _getCwd(shell: IShellLaunchConfig, root: Uri): string {
// return super._getCwd(shell, root);
// }
// protected _createProcess(): void { }
// protected _createXterm(): TPromise<void> { return TPromise.as(void 0); }
// }
// suite('Workbench - TerminalInstance', () => {
// let instantiationService: TestInstantiationService;
// setup(() => {
// instantiationService = new TestInstantiationService();
// instantiationService.stub(INotificationService, new TestNotificationService());
// instantiationService.stub(IHistoryService, new TestHistoryService());
// });
// test('createTerminalEnv', function () {
// const shell1 = {
// executable: '/bin/foosh',
// args: ['-bar', 'baz']
// };
// const parentEnv1: IStringDictionary<string> = {
// ok: true
// } as any;
// const env1 = TerminalInstance.createTerminalEnv(parentEnv1, shell1, '/foo', 'en-au');
// assert.ok(env1['ok'], 'Parent environment is copied');
// assert.deepStrictEqual(parentEnv1, { ok: true }, 'Parent environment is unchanged');
// assert.equal(env1['PTYPID'], process.pid.toString(), 'PTYPID is equal to the current PID');
// assert.equal(env1['PTYSHELL'], '/bin/foosh', 'PTYSHELL is equal to the provided shell');
// assert.equal(env1['PTYSHELLARG0'], '-bar', 'PTYSHELLARG0 is equal to the first shell argument');
// assert.equal(env1['PTYSHELLARG1'], 'baz', 'PTYSHELLARG1 is equal to the first shell argument');
// assert.ok(!('PTYSHELLARG2' in env1), 'PTYSHELLARG2 is unset');
// assert.equal(env1['PTYCWD'], '/foo', 'PTYCWD is equal to requested cwd');
// assert.equal(env1['LANG'], 'en_AU.UTF-8', 'LANG is equal to the requested locale with UTF-8');
// const shell2: IShellLaunchConfig = {
// executable: '/bin/foosh',
// args: []
// };
// const parentEnv2: IStringDictionary<string> = {
// LANG: 'en_US.UTF-8'
// };
// const env2 = TerminalInstance.createTerminalEnv(parentEnv2, shell2, '/foo', 'en-au');
// assert.ok(!('PTYSHELLARG0' in env2), 'PTYSHELLARG0 is unset');
// assert.equal(env2['PTYCWD'], '/foo', 'PTYCWD is equal to /foo');
// assert.equal(env2['LANG'], 'en_AU.UTF-8', 'LANG is equal to the requested locale with UTF-8');
// const env3 = TerminalInstance.createTerminalEnv(parentEnv1, shell1, '/', null);
// assert.equal(env3['LANG'], 'en_US.UTF-8', 'LANG is equal to en_US.UTF-8 as fallback.'); // More info on issue #14586
// const env4 = TerminalInstance.createTerminalEnv(parentEnv2, shell1, '/', null);
// assert.equal(env4['LANG'], 'en_US.UTF-8', 'LANG is equal to the parent environment\'s LANG');
// });
// suite('mergeEnvironments', () => {
// test('should add keys', () => {
// const parent = {
// a: 'b'
// };
// const other = {
// c: 'd'
// };
// TerminalInstance.mergeEnvironments(parent, other);
// assert.deepEqual(parent, {
// a: 'b',
// c: 'd'
// });
// });
// test('should add keys ignoring case on Windows', () => {
// if (!platform.isWindows) {
// return;
// }
// const parent = {
// a: 'b'
// };
// const other = {
// A: 'c'
// };
// TerminalInstance.mergeEnvironments(parent, other);
// assert.deepEqual(parent, {
// a: 'c'
// });
// });
// test('null values should delete keys from the parent env', () => {
// const parent = {
// a: 'b',
// c: 'd'
// };
// const other: IStringDictionary<string> = {
// a: null
// };
// TerminalInstance.mergeEnvironments(parent, other);
// assert.deepEqual(parent, {
// c: 'd'
// });
// });
// test('null values should delete keys from the parent env ignoring case on Windows', () => {
// if (!platform.isWindows) {
// return;
// }
// const parent = {
// a: 'b',
// c: 'd'
// };
// const other: IStringDictionary<string> = {
// A: null
// };
// TerminalInstance.mergeEnvironments(parent, other);
// assert.deepEqual(parent, {
// c: 'd'
// });
// });
// });
// suite('_getCwd', () => {
// let instance: TestTerminalInstance;
// let instantiationService: TestInstantiationService;
// let configHelper: { config: { cwd: string } };
// setup(() => {
// let contextKeyService = new MockContextKeyService();
// let keybindingService = new MockKeybindingService();
// let terminalFocusContextKey = contextKeyService.createKey('test', false);
// instantiationService = new TestInstantiationService();
// instantiationService.stub(IConfigurationService, new TestConfigurationService());
// instantiationService.stub(INotificationService, new TestNotificationService());
// instantiationService.stub(IWorkspaceContextService, new TestContextService());
// instantiationService.stub(IKeybindingService, keybindingService);
// instantiationService.stub(IContextKeyService, contextKeyService);
// instantiationService.stub(IHistoryService, new TestHistoryService());
// instantiationService.stub(ILogService, new NullLogService());
// configHelper = {
// config: {
// cwd: null
// }
// };
// instance = instantiationService.createInstance(TestTerminalInstance, terminalFocusContextKey, configHelper, null, null);
// });
// // This helper checks the paths in a cross-platform friendly manner
// function assertPathsMatch(a: string, b: string): void {
// assert.equal(Uri.file(a).fsPath, Uri.file(b).fsPath);
// }
// test('should default to os.homedir() for an empty workspace', () => {
// assertPathsMatch(instance._getCwd({ executable: null, args: [] }, null), os.homedir());
// });
// test('should use to the workspace if it exists', () => {
// assertPathsMatch(instance._getCwd({ executable: null, args: [] }, Uri.file('/foo')), '/foo');
// });
// test('should use an absolute custom cwd as is', () => {
// configHelper.config.cwd = '/foo';
// assertPathsMatch(instance._getCwd({ executable: null, args: [] }, null), '/foo');
// });
// test('should normalize a relative custom cwd against the workspace path', () => {
// configHelper.config.cwd = 'foo';
// assertPathsMatch(instance._getCwd({ executable: null, args: [] }, Uri.file('/bar')), '/bar/foo');
// configHelper.config.cwd = './foo';
// assertPathsMatch(instance._getCwd({ executable: null, args: [] }, Uri.file('/bar')), '/bar/foo');
// configHelper.config.cwd = '../foo';
// assertPathsMatch(instance._getCwd({ executable: null, args: [] }, Uri.file('/bar'), ), '/foo');
// });
// test('should fall back for relative a custom cwd that doesn\'t have a workspace', () => {
// configHelper.config.cwd = 'foo';
// assertPathsMatch(instance._getCwd({ executable: null, args: [] }, null), os.homedir());
// configHelper.config.cwd = './foo';
// assertPathsMatch(instance._getCwd({ executable: null, args: [] }, null), os.homedir());
// configHelper.config.cwd = '../foo';
// assertPathsMatch(instance._getCwd({ executable: null, args: [] }, null), os.homedir());
// });
// test('should ignore custom cwd when told to ignore', () => {
// configHelper.config.cwd = '/foo';
// assertPathsMatch(instance._getCwd({ executable: null, args: [], ignoreConfigurationCwd: true }, Uri.file('/bar')), '/bar');
// });
// });
// });
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录