Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
99ebad25
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,发现更多精彩内容 >>
提交
99ebad25
编写于
9月 12, 2016
作者:
D
Daniel Imms
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add back createTerminalEnv tests
上级
51833724
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
52 addition
and
119 deletion
+52
-119
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
...bench/parts/terminal/electron-browser/terminalInstance.ts
+8
-8
src/vs/workbench/parts/terminal/test/terminalInstance.test.ts
...vs/workbench/parts/terminal/test/terminalInstance.test.ts
+44
-52
src/vs/workbench/parts/terminal/test/terminalService.test.ts
src/vs/workbench/parts/terminal/test/terminalService.test.ts
+0
-59
未找到文件。
src/vs/workbench/parts/terminal/electron-browser/terminalInstance.ts
浏览文件 @
99ebad25
...
...
@@ -213,7 +213,7 @@ export class TerminalInstance implements ITerminalInstance {
private
createProcess
(
workspace
:
IWorkspace
,
name
?:
string
,
shellPath
?:
string
)
{
let
locale
=
this
.
configHelper
.
isSetLocaleVariables
()
?
platform
.
locale
:
undefined
;
let
shell
=
shellPath
?
{
executable
:
shellPath
,
args
:
[]
}
:
this
.
configHelper
.
getShell
();
let
env
=
this
.
createTerminalEnv
(
process
.
env
,
shell
,
workspace
,
locale
);
let
env
=
TerminalInstance
.
createTerminalEnv
(
process
.
env
,
shell
,
workspace
,
locale
);
this
.
_title
=
name
?
name
:
''
;
this
.
process
=
cp
.
fork
(
'
./terminalProcess
'
,
[],
{
env
:
env
,
...
...
@@ -240,21 +240,21 @@ export class TerminalInstance implements ITerminalInstance {
});
}
public
createTerminalEnv
(
parentEnv
:
IStringDictionary
<
string
>
,
shell
:
IShell
,
workspace
:
IWorkspace
,
locale
?:
string
):
IStringDictionary
<
string
>
{
let
env
=
this
.
cloneEnv
(
parentEnv
);
public
static
createTerminalEnv
(
parentEnv
:
IStringDictionary
<
string
>
,
shell
:
IShell
,
workspace
:
IWorkspace
,
locale
?:
string
):
IStringDictionary
<
string
>
{
let
env
=
TerminalInstance
.
cloneEnv
(
parentEnv
);
env
[
'
PTYPID
'
]
=
process
.
pid
.
toString
();
env
[
'
PTYSHELL
'
]
=
shell
.
executable
;
shell
.
args
.
forEach
((
arg
,
i
)
=>
{
env
[
`PTYSHELLARG
${
i
}
`
]
=
arg
;
});
env
[
'
PTYCWD
'
]
=
this
.
sanitizeCwd
(
workspace
?
workspace
.
resource
.
fsPath
:
os
.
homedir
());
env
[
'
PTYCWD
'
]
=
TerminalInstance
.
sanitizeCwd
(
workspace
?
workspace
.
resource
.
fsPath
:
os
.
homedir
());
if
(
locale
)
{
env
[
'
LANG
'
]
=
this
.
getLangEnvVariable
(
locale
);
env
[
'
LANG
'
]
=
TerminalInstance
.
getLangEnvVariable
(
locale
);
}
return
env
;
}
private
sanitizeCwd
(
cwd
:
string
)
{
private
s
tatic
s
anitizeCwd
(
cwd
:
string
)
{
// Make the drive letter uppercase on Windows (see #9448)
if
(
platform
.
platform
===
platform
.
Platform
.
Windows
&&
cwd
&&
cwd
[
1
]
===
'
:
'
)
{
return
cwd
[
0
].
toUpperCase
()
+
cwd
.
substr
(
1
);
...
...
@@ -262,7 +262,7 @@ export class TerminalInstance implements ITerminalInstance {
return
cwd
;
}
private
cloneEnv
(
env
:
IStringDictionary
<
string
>
):
IStringDictionary
<
string
>
{
private
static
cloneEnv
(
env
:
IStringDictionary
<
string
>
):
IStringDictionary
<
string
>
{
let
newEnv
:
IStringDictionary
<
string
>
=
Object
.
create
(
null
);
Object
.
keys
(
env
).
forEach
((
key
)
=>
{
newEnv
[
key
]
=
env
[
key
];
...
...
@@ -270,7 +270,7 @@ export class TerminalInstance implements ITerminalInstance {
return
newEnv
;
}
private
getLangEnvVariable
(
locale
:
string
)
{
private
static
getLangEnvVariable
(
locale
:
string
)
{
const
parts
=
locale
.
split
(
'
-
'
);
const
n
=
parts
.
length
;
if
(
n
>
1
)
{
...
...
src/vs/workbench/parts/terminal/test/terminalInstance.test.ts
浏览文件 @
99ebad25
...
...
@@ -69,58 +69,50 @@ suite('Workbench - TerminalInstance', () => {
});
});
// test('TerminalInstance - createTerminalEnv', function () {
// let terminalConfigHelper = instantiationService.createInstance(TerminalConfigHelper, Platform.Linux);
// let terminalInstance = instantiationService.createInstance(TerminalInstance,
// /*terminalFocusContextKey*/null,
// /*onExitCallback*/() => {},
// /*configHelper*/terminalConfigHelper,
// /*container*/null,
// /*workspace*/null,
// /*name*/'',
// /*shellPath*/'');
// const shell1 = {
// executable: '/bin/foosh',
// args: ['-bar', 'baz']
// };
// const parentEnv1: IStringDictionary<string> = <any>{
// ok: true
// };
// const env1 = terminalInstance.createTerminalEnv(parentEnv1, shell1, null, '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'], os.homedir(), 'PTYCWD is equal to the home folder');
// assert.equal(env1['LANG'], 'en_AU.UTF-8', 'LANG is equal to the requested locale with UTF-8');
// const shell2 = {
// executable: '/bin/foosh',
// args: []
// };
// const parentEnv2: IStringDictionary<string> = <any>{
// LANG: 'en_US.UTF-8'
// };
// const workspace2: IWorkspace = <any>{
// resource: {
// fsPath: '/my/dev/folder'
// }
// };
// const env2 = terminalInstance.createTerminalEnv(parentEnv2, shell2, workspace2, 'en-au');
// assert.ok(!('PTYSHELLARG0' in env2), 'PTYSHELLARG0 is unset');
// assert.equal(env2['PTYCWD'], '/my/dev/folder', 'PTYCWD is equal to the workspace folder');
// 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, null);
// assert.ok(!('LANG' in env3), 'LANG is unset');
// const env4 = terminalInstance.createTerminalEnv(parentEnv2, shell1, null, null);
// assert.equal(env4['LANG'], 'en_US.UTF-8', 'LANG is equal to the parent environment\'s LANG');
// });
test
(
'
TerminalInstance - createTerminalEnv
'
,
function
()
{
let
terminalConfigHelper
=
instantiationService
.
createInstance
(
TerminalConfigHelper
,
platform
.
Platform
.
Linux
);
const
shell1
=
{
executable
:
'
/bin/foosh
'
,
args
:
[
'
-bar
'
,
'
baz
'
]
};
const
parentEnv1
:
IStringDictionary
<
string
>
=
<
any
>
{
ok
:
true
};
const
env1
=
TerminalInstance
.
createTerminalEnv
(
parentEnv1
,
shell1
,
null
,
'
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
'
],
os
.
homedir
(),
'
PTYCWD is equal to the home folder
'
);
assert
.
equal
(
env1
[
'
LANG
'
],
'
en_AU.UTF-8
'
,
'
LANG is equal to the requested locale with UTF-8
'
);
const
shell2
=
{
executable
:
'
/bin/foosh
'
,
args
:
[]
};
const
parentEnv2
:
IStringDictionary
<
string
>
=
<
any
>
{
LANG
:
'
en_US.UTF-8
'
};
const
workspace2
:
IWorkspace
=
<
any
>
{
resource
:
{
fsPath
:
'
/my/dev/folder
'
}
};
const
env2
=
TerminalInstance
.
createTerminalEnv
(
parentEnv2
,
shell2
,
workspace2
,
'
en-au
'
);
assert
.
ok
(
!
(
'
PTYSHELLARG0
'
in
env2
),
'
PTYSHELLARG0 is unset
'
);
assert
.
equal
(
env2
[
'
PTYCWD
'
],
'
/my/dev/folder
'
,
'
PTYCWD is equal to the workspace folder
'
);
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
,
null
);
assert
.
ok
(
!
(
'
LANG
'
in
env3
),
'
LANG is unset
'
);
const
env4
=
TerminalInstance
.
createTerminalEnv
(
parentEnv2
,
shell1
,
null
,
null
);
assert
.
equal
(
env4
[
'
LANG
'
],
'
en_US.UTF-8
'
,
'
LANG is equal to the parent environment
\'
s LANG
'
);
});
});
function
createTerminalInstance
(
instantiationService
:
TestInstantiationService
,
terminalConfig
:
any
):
TerminalInstance
{
...
...
src/vs/workbench/parts/terminal/test/terminalService.test.ts
已删除
100644 → 0
浏览文件 @
51833724
/*---------------------------------------------------------------------------------------------
* 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
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
IWorkspace
}
from
'
vs/platform/workspace/common/workspace
'
;
//import {TerminalService} from 'vs/workbench/parts/terminal/electron-browser/terminalService';
suite
(
'
Workbench - TerminalService
'
,
()
=>
{
// test('TerminalService - createTerminalEnv', function () {
// const shell1 = {
// executable: '/bin/foosh',
// args: ['-bar', 'baz']
// };
// const parentEnv1: IStringDictionary<string> = <any>{
// ok: true
// };
// const env1 = TerminalService.createTerminalEnv(parentEnv1, shell1, null, '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'], os.homedir(), 'PTYCWD is equal to the home folder');
// assert.equal(env1['LANG'], 'en_AU.UTF-8', 'LANG is equal to the requested locale with UTF-8');
// const shell2 = {
// executable: '/bin/foosh',
// args: []
// };
// const parentEnv2: IStringDictionary<string> = <any>{
// LANG: 'en_US.UTF-8'
// };
// const workspace2: IWorkspace = <any>{
// resource: {
// fsPath: '/my/dev/folder'
// }
// };
// const env2 = TerminalService.createTerminalEnv(parentEnv2, shell2, workspace2, 'en-au');
// assert.ok(!('PTYSHELLARG0' in env2), 'PTYSHELLARG0 is unset');
// assert.equal(env2['PTYCWD'], '/my/dev/folder', 'PTYCWD is equal to the workspace folder');
// assert.equal(env2['LANG'], 'en_AU.UTF-8', 'LANG is equal to the requested locale with UTF-8');
// const env3 = TerminalService.createTerminalEnv(parentEnv1, shell1, null, null);
// assert.ok(!('LANG' in env3), 'LANG is unset');
// const env4 = TerminalService.createTerminalEnv(parentEnv2, shell1, null, null);
// assert.equal(env4['LANG'], 'en_US.UTF-8', 'LANG is equal to the parent environment\'s LANG');
// });
});
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录