Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a7c94396
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,发现更多精彩内容 >>
提交
a7c94396
编写于
2月 20, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tests - more reliable tests on windows for workspaces main
上级
6309a773
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
29 addition
and
18 deletion
+29
-18
src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts
...rkspaces/test/electron-main/workspacesMainService.test.ts
+29
-18
未找到文件。
src/vs/platform/workspaces/test/electron-main/workspacesMainService.test.ts
浏览文件 @
a7c94396
...
@@ -18,6 +18,8 @@ import { WORKSPACE_EXTENSION, IWorkspaceSavedEvent, IWorkspaceIdentifier, IRawFi
...
@@ -18,6 +18,8 @@ import { WORKSPACE_EXTENSION, IWorkspaceSavedEvent, IWorkspaceIdentifier, IRawFi
import
{
ConsoleLogMainService
}
from
'
vs/platform/log/common/log
'
;
import
{
ConsoleLogMainService
}
from
'
vs/platform/log/common/log
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
getRandomTestPath
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
getRandomTestPath
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
normalizeDriveLetter
}
from
'
vs/base/common/labels
'
;
suite
(
'
WorkspacesMainService
'
,
()
=>
{
suite
(
'
WorkspacesMainService
'
,
()
=>
{
const
parentDir
=
getRandomTestPath
(
os
.
tmpdir
(),
'
vsctests
'
,
'
workspacesservice
'
);
const
parentDir
=
getRandomTestPath
(
os
.
tmpdir
(),
'
vsctests
'
,
'
workspacesservice
'
);
...
@@ -67,6 +69,15 @@ suite('WorkspacesMainService', () => {
...
@@ -67,6 +69,15 @@ suite('WorkspacesMainService', () => {
extfs
.
del
(
workspacesHome
,
os
.
tmpdir
(),
done
);
extfs
.
del
(
workspacesHome
,
os
.
tmpdir
(),
done
);
});
});
function
assertPathEquals
(
p1
:
string
,
p2
):
void
{
if
(
isWindows
)
{
p1
=
normalizeDriveLetter
(
p1
);
p2
=
normalizeDriveLetter
(
p2
);
}
assert
.
equal
(
p1
,
p2
);
}
test
(
'
createWorkspace (folders)
'
,
done
=>
{
test
(
'
createWorkspace (folders)
'
,
done
=>
{
return
createWorkspace
([
process
.
cwd
(),
os
.
tmpdir
()]).
then
(
workspace
=>
{
return
createWorkspace
([
process
.
cwd
(),
os
.
tmpdir
()]).
then
(
workspace
=>
{
assert
.
ok
(
workspace
);
assert
.
ok
(
workspace
);
...
@@ -75,8 +86,8 @@ suite('WorkspacesMainService', () => {
...
@@ -75,8 +86,8 @@ suite('WorkspacesMainService', () => {
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
workspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
workspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
assert
.
equal
(
ws
.
folders
.
length
,
2
);
//
assert
.
equal
(
ws
.
folders
.
length
,
2
);
//
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
path
,
process
.
cwd
());
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
path
,
process
.
cwd
());
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
path
,
os
.
tmpdir
());
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
path
,
os
.
tmpdir
());
assert
.
ok
(
!
(
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
name
);
assert
.
ok
(
!
(
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
name
);
assert
.
ok
(
!
(
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
name
);
assert
.
ok
(
!
(
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
name
);
...
@@ -93,8 +104,8 @@ suite('WorkspacesMainService', () => {
...
@@ -93,8 +104,8 @@ suite('WorkspacesMainService', () => {
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
workspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
workspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
assert
.
equal
(
ws
.
folders
.
length
,
2
);
//
assert
.
equal
(
ws
.
folders
.
length
,
2
);
//
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
path
,
process
.
cwd
());
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
path
,
process
.
cwd
());
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
path
,
os
.
tmpdir
());
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
path
,
os
.
tmpdir
());
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
name
,
'
currentworkingdirectory
'
);
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
name
,
'
currentworkingdirectory
'
);
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
name
,
'
tempdir
'
);
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
name
,
'
tempdir
'
);
...
@@ -127,8 +138,8 @@ suite('WorkspacesMainService', () => {
...
@@ -127,8 +138,8 @@ suite('WorkspacesMainService', () => {
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
workspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
workspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
assert
.
equal
(
ws
.
folders
.
length
,
2
);
assert
.
equal
(
ws
.
folders
.
length
,
2
);
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
path
,
process
.
cwd
());
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
path
,
process
.
cwd
());
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
path
,
os
.
tmpdir
());
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
path
,
os
.
tmpdir
());
assert
.
ok
(
!
(
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
name
);
assert
.
ok
(
!
(
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
name
);
assert
.
ok
(
!
(
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
name
);
assert
.
ok
(
!
(
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
name
);
...
@@ -142,8 +153,8 @@ suite('WorkspacesMainService', () => {
...
@@ -142,8 +153,8 @@ suite('WorkspacesMainService', () => {
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
workspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
workspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
assert
.
equal
(
ws
.
folders
.
length
,
2
);
assert
.
equal
(
ws
.
folders
.
length
,
2
);
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
path
,
process
.
cwd
());
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
path
,
process
.
cwd
());
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
path
,
os
.
tmpdir
());
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
path
,
os
.
tmpdir
());
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
name
,
'
currentworkingdirectory
'
);
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
name
,
'
currentworkingdirectory
'
);
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
name
,
'
tempdir
'
);
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
name
,
'
tempdir
'
);
...
@@ -253,12 +264,12 @@ suite('WorkspacesMainService', () => {
...
@@ -253,12 +264,12 @@ suite('WorkspacesMainService', () => {
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
savedWorkspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
savedWorkspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
assert
.
equal
(
ws
.
folders
.
length
,
3
);
assert
.
equal
(
ws
.
folders
.
length
,
3
);
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
path
,
process
.
cwd
());
// absolute
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
path
,
process
.
cwd
());
// absolute
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
path
,
'
.
'
);
// relative
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
path
,
'
.
'
);
// relative
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
2
]).
path
,
path
.
relative
(
path
.
dirname
(
workspaceConfigPath
),
path
.
join
(
os
.
tmpdir
(),
'
somefolder
'
)));
// relative
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
2
]).
path
,
path
.
relative
(
path
.
dirname
(
workspaceConfigPath
),
path
.
join
(
os
.
tmpdir
(),
'
somefolder
'
)));
// relative
assert
.
equal
(
savedWorkspace
,
savedEvent
.
workspace
);
assert
.
equal
(
savedWorkspace
,
savedEvent
.
workspace
);
assert
.
equal
(
workspace
.
configPath
,
savedEvent
.
oldConfigPath
);
assert
PathEquals
(
workspace
.
configPath
,
savedEvent
.
oldConfigPath
);
assert
.
deepEqual
(
deletedEvent
,
workspace
);
assert
.
deepEqual
(
deletedEvent
,
workspace
);
...
@@ -281,13 +292,13 @@ suite('WorkspacesMainService', () => {
...
@@ -281,13 +292,13 @@ suite('WorkspacesMainService', () => {
return
service
.
saveWorkspace
(
savedWorkspace
,
newWorkspaceConfigPath
).
then
(
newSavedWorkspace
=>
{
return
service
.
saveWorkspace
(
savedWorkspace
,
newWorkspaceConfigPath
).
then
(
newSavedWorkspace
=>
{
assert
.
ok
(
newSavedWorkspace
.
id
);
assert
.
ok
(
newSavedWorkspace
.
id
);
assert
.
notEqual
(
newSavedWorkspace
.
id
,
workspace
.
id
);
assert
.
notEqual
(
newSavedWorkspace
.
id
,
workspace
.
id
);
assert
.
equal
(
newSavedWorkspace
.
configPath
,
newWorkspaceConfigPath
);
assert
PathEquals
(
newSavedWorkspace
.
configPath
,
newWorkspaceConfigPath
);
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
newSavedWorkspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
newSavedWorkspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
assert
.
equal
(
ws
.
folders
.
length
,
3
);
assert
.
equal
(
ws
.
folders
.
length
,
3
);
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
path
,
process
.
cwd
());
// absolute path because outside of tmpdir
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
0
]).
path
,
process
.
cwd
());
// absolute path because outside of tmpdir
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
path
,
'
.
'
);
// relative path because inside of tmpdir
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
1
]).
path
,
'
.
'
);
// relative path because inside of tmpdir
assert
.
equal
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
2
]).
path
,
path
.
relative
(
path
.
dirname
(
workspaceConfigPath
),
path
.
join
(
os
.
tmpdir
(),
'
somefolder
'
)));
// relative
assert
PathEquals
((
<
IRawFileWorkspaceFolder
>
ws
.
folders
[
2
]).
path
,
path
.
relative
(
path
.
dirname
(
workspaceConfigPath
),
path
.
join
(
os
.
tmpdir
(),
'
somefolder
'
)));
// relative
extfs
.
delSync
(
workspaceConfigPath
);
extfs
.
delSync
(
workspaceConfigPath
);
extfs
.
delSync
(
newWorkspaceConfigPath
);
extfs
.
delSync
(
newWorkspaceConfigPath
);
...
@@ -310,7 +321,7 @@ suite('WorkspacesMainService', () => {
...
@@ -310,7 +321,7 @@ suite('WorkspacesMainService', () => {
return
service
.
saveWorkspace
(
savedWorkspace
,
newWorkspaceConfigPath
).
then
(
newSavedWorkspace
=>
{
return
service
.
saveWorkspace
(
savedWorkspace
,
newWorkspaceConfigPath
).
then
(
newSavedWorkspace
=>
{
assert
.
ok
(
newSavedWorkspace
.
id
);
assert
.
ok
(
newSavedWorkspace
.
id
);
assert
.
notEqual
(
newSavedWorkspace
.
id
,
workspace
.
id
);
assert
.
notEqual
(
newSavedWorkspace
.
id
,
workspace
.
id
);
assert
.
equal
(
newSavedWorkspace
.
configPath
,
newWorkspaceConfigPath
);
assert
PathEquals
(
newSavedWorkspace
.
configPath
,
newWorkspaceConfigPath
);
const
savedContents
=
fs
.
readFileSync
(
newSavedWorkspace
.
configPath
).
toString
();
const
savedContents
=
fs
.
readFileSync
(
newSavedWorkspace
.
configPath
).
toString
();
assert
.
equal
(
0
,
savedContents
.
indexOf
(
'
// this is a comment
'
));
assert
.
equal
(
0
,
savedContents
.
indexOf
(
'
// this is a comment
'
));
...
@@ -336,7 +347,7 @@ suite('WorkspacesMainService', () => {
...
@@ -336,7 +347,7 @@ suite('WorkspacesMainService', () => {
return
service
.
saveWorkspace
(
savedWorkspace
,
newWorkspaceConfigPath
).
then
(
newSavedWorkspace
=>
{
return
service
.
saveWorkspace
(
savedWorkspace
,
newWorkspaceConfigPath
).
then
(
newSavedWorkspace
=>
{
assert
.
ok
(
newSavedWorkspace
.
id
);
assert
.
ok
(
newSavedWorkspace
.
id
);
assert
.
notEqual
(
newSavedWorkspace
.
id
,
workspace
.
id
);
assert
.
notEqual
(
newSavedWorkspace
.
id
,
workspace
.
id
);
assert
.
equal
(
newSavedWorkspace
.
configPath
,
newWorkspaceConfigPath
);
assert
PathEquals
(
newSavedWorkspace
.
configPath
,
newWorkspaceConfigPath
);
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
newSavedWorkspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
const
ws
=
JSON
.
parse
(
fs
.
readFileSync
(
newSavedWorkspace
.
configPath
).
toString
())
as
IStoredWorkspace
;
assert
.
ok
(
ws
.
folders
.
every
(
f
=>
(
<
IRawFileWorkspaceFolder
>
f
).
path
.
indexOf
(
'
\\
'
)
<
0
));
assert
.
ok
(
ws
.
folders
.
every
(
f
=>
(
<
IRawFileWorkspaceFolder
>
f
).
path
.
indexOf
(
'
\\
'
)
<
0
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录