Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
06be9f40
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,发现更多精彩内容 >>
未验证
提交
06be9f40
编写于
11月 20, 2020
作者:
C
Connor Peet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
testing: tests and speed improvements
上级
38804630
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
86 addition
and
29 deletion
+86
-29
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+1
-1
src/vs/workbench/api/common/extHostTesting.ts
src/vs/workbench/api/common/extHostTesting.ts
+46
-26
src/vs/workbench/api/common/extHostTypes.ts
src/vs/workbench/api/common/extHostTypes.ts
+11
-0
src/vs/workbench/test/browser/api/extHostTesting.test.ts
src/vs/workbench/test/browser/api/extHostTesting.test.ts
+28
-2
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
06be9f40
...
...
@@ -2359,7 +2359,7 @@ declare module 'vscode' {
runnable
?:
boolean
;
/**
* Whether this test item can be debugged.
* Whether this test item can be debugged.
Defaults to `false` if not provided.
*/
debuggable
?:
boolean
;
...
...
src/vs/workbench/api/common/extHostTesting.ts
浏览文件 @
06be9f40
...
...
@@ -17,7 +17,7 @@ import { ExtHostTestingResource, ExtHostTestingShape, MainContext, MainThreadTes
import
{
IExtHostDocumentsAndEditors
}
from
'
vs/workbench/api/common/extHostDocumentsAndEditors
'
;
import
{
IExtHostRpcService
}
from
'
vs/workbench/api/common/extHostRpcService
'
;
import
{
TestItem
}
from
'
vs/workbench/api/common/extHostTypeConverters
'
;
import
{
Disposable
}
from
'
vs/workbench/api/common/extHostTypes
'
;
import
{
Disposable
,
RequiredTestItem
}
from
'
vs/workbench/api/common/extHostTypes
'
;
import
{
IExtHostWorkspace
}
from
'
vs/workbench/api/common/extHostWorkspace
'
;
import
{
AbstractIncrementalTestCollection
,
EMPTY_TEST_RESULT
,
IncrementalChangeCollector
,
IncrementalTestCollectionItem
,
InternalTestItem
,
RunTestForProviderRequest
,
RunTestsResult
,
TestDiffOpType
,
TestsDiff
}
from
'
vs/workbench/contrib/testing/common/testCollection
'
;
import
type
*
as
vscode
from
'
vscode
'
;
...
...
@@ -178,7 +178,7 @@ export class ExtHostTesting implements ExtHostTestingShape {
}
}
const
keyMap
:
{
[
K
in
keyof
Omit
<
Required
<
vscode
.
TestItem
>
,
'
children
'
>
]:
null
}
=
{
const
keyMap
:
{
[
K
in
keyof
Omit
<
Required
TestItem
,
'
children
'
>
]:
null
}
=
{
label
:
null
,
location
:
null
,
state
:
null
,
...
...
@@ -215,6 +215,9 @@ export interface OwnedCollectionTestItem extends InternalTestItem {
previousEquals
:
(
v
:
vscode
.
TestItem
)
=>
boolean
;
}
/**
* @private
*/
export
class
OwnedTestCollection
{
protected
readonly
testIdToInternal
=
new
Map
<
string
,
OwnedCollectionTestItem
>
();
...
...
@@ -542,11 +545,16 @@ export class MirroredTestCollection extends AbstractIncrementalTestCollection<Mi
/**
* Translates the item IDs to TestItems for exposure to extensions.
*/
public
getAllAsTestItem
(
itemIds
:
ReadonlyArray
<
string
>
):
vscode
.
TestItem
[]
{
return
itemIds
.
map
(
itemId
=>
{
public
getAllAsTestItem
(
itemIds
:
Iterable
<
string
>
):
vscode
.
TestItem
[]
{
let
output
:
vscode
.
TestItem
[]
=
[];
for
(
const
itemId
of
itemIds
)
{
const
item
=
this
.
items
.
get
(
itemId
);
return
item
&&
this
.
getPublicTestItem
(
item
);
}).
filter
(
isDefined
);
if
(
item
)
{
output
.
push
(
this
.
getPublicTestItem
(
item
));
}
}
return
output
;
}
/**
...
...
@@ -584,7 +592,7 @@ export class MirroredTestCollection extends AbstractIncrementalTestCollection<Mi
*/
public
getPublicTestItem
(
item
:
MirroredCollectionTestItem
):
vscode
.
TestItem
{
if
(
!
item
.
wrapped
)
{
item
.
wrapped
=
createMirrored
TestItem
(
item
,
this
);
item
.
wrapped
=
new
ExtHost
TestItem
(
item
,
this
);
}
return
item
.
wrapped
;
...
...
@@ -597,29 +605,41 @@ const getMirroredItemId = (item: vscode.TestItem) => {
const
MirroredItemId
=
Symbol
(
'
MirroredItemId
'
);
const
createMirroredTestItem
=
(
internal
:
MirroredCollectionTestItem
,
collection
:
MirroredTestCollection
):
vscode
.
TestItem
=>
{
const
obj
=
{};
class
ExtHostTestItem
implements
vscode
.
TestItem
,
RequiredTestItem
{
readonly
#
internal
:
MirroredCollectionTestItem
;
readonly
#
collection
:
MirroredTestCollection
;
Object
.
defineProperty
(
obj
,
MirroredItemId
,
{
enumerable
:
false
,
configurable
:
false
,
value
:
internal
.
id
,
});
public
get
label
()
{
return
this
.
#
internal
.
revived
.
label
;
}
public
get
description
()
{
return
this
.
#
internal
.
revived
.
description
;
}
public
get
state
()
{
return
this
.
#
internal
.
revived
.
state
;
}
public
get
location
()
{
return
this
.
#
internal
.
revived
.
location
;
}
public
get
runnable
()
{
return
this
.
#
internal
.
revived
.
runnable
??
true
;
}
public
get
debuggable
()
{
return
this
.
#
internal
.
revived
.
debuggable
??
false
;
}
public
get
children
()
{
return
this
.
#
collection
.
getAllAsTestItem
(
this
.
#
internal
.
children
);
}
Object
.
defineProperty
(
obj
,
'
children
'
,
{
enumerable
:
true
,
configurable
:
false
,
get
:
()
=>
collection
.
getAllAsTestItem
([...
internal
.
children
])
});
get
[
MirroredItemId
]()
{
return
this
.
#
internal
.
id
;
}
simpleProps
.
forEach
(
prop
=>
Object
.
defineProperty
(
obj
,
prop
,
{
enumerable
:
true
,
configurable
:
false
,
get
:
()
=>
internal
.
revived
[
prop
],
}));
constructor
(
internal
:
MirroredCollectionTestItem
,
collection
:
MirroredTestCollection
)
{
this
.
#
internal
=
internal
;
this
.
#
collection
=
collection
;
}
return
obj
as
any
;
};
public
toJSON
()
{
const
serialized
:
RequiredTestItem
=
{
label
:
this
.
label
,
description
:
this
.
description
,
state
:
this
.
state
,
location
:
this
.
location
,
runnable
:
this
.
runnable
,
debuggable
:
this
.
debuggable
,
children
:
this
.
children
.
map
(
c
=>
(
c
as
ExtHostTestItem
).
toJSON
()),
};
return
serialized
;
}
}
interface
IObserverData
{
observers
:
number
;
...
...
src/vs/workbench/api/common/extHostTypes.ts
浏览文件 @
06be9f40
...
...
@@ -2940,4 +2940,15 @@ export class TestState {
}
}
type
AllowedUndefined
=
'
description
'
|
'
location
'
;
/**
* Test item without any optional properties. Only some properties are
* permitted to be undefined, but they must still exist.
*/
export
type
RequiredTestItem
=
{
[
K
in
keyof
Required
<
vscode
.
TestItem
>
]:
K
extends
AllowedUndefined
?
vscode
.
TestItem
[
K
]
:
Required
<
vscode
.
TestItem
>
[
K
]
};
//#endregion
src/vs/workbench/test/browser/api/extHostTesting.test.ts
浏览文件 @
06be9f40
...
...
@@ -19,8 +19,16 @@ const stubTest = (label: string): TestItem => ({
description
:
''
});
const
simplify
=
(
item
:
TestItem
)
=>
{
if
(
'
toJSON
'
in
item
)
{
item
=
(
item
as
any
).
toJSON
();
}
return
{
...
item
,
children
:
undefined
};
};
const
assertTreesEqual
=
(
a
:
Readonly
<
TestItem
>
,
b
:
Readonly
<
TestItem
>
)
=>
{
assert
.
deepStrictEqual
(
{
...
a
,
children
:
undefined
},
{
...
b
,
children
:
undefined
}
);
assert
.
deepStrictEqual
(
simplify
(
a
),
simplify
(
b
)
);
const
aChildren
=
(
a
.
children
??
[]).
sort
();
const
bChildren
=
(
b
.
children
??
[]).
sort
();
...
...
@@ -274,11 +282,29 @@ suite('ExtHost Testing', () => {
single
.
onItemChange
(
tests
,
'
pid
'
);
m
.
apply
(
single
.
collectDiff
());
assert
.
deepS
trictEqual
(
m
.
changeEvent
.
commonChangeAncestor
?.
label
,
'
root
'
);
assert
.
s
trictEqual
(
m
.
changeEvent
.
commonChangeAncestor
?.
label
,
'
root
'
);
assertTreeListEqual
(
m
.
changeEvent
.
added
,
[
child
]);
assertTreeListEqual
(
m
.
changeEvent
.
removed
,
[]);
assertTreeListEqual
(
m
.
changeEvent
.
updated
,
[]);
});
test
(
'
gets the common ancestor (1)
'
,
()
=>
{
tests
.
children
!
[
0
].
children
!
[
0
].
label
=
'
za
'
;
tests
.
children
!
[
0
].
children
!
[
1
].
label
=
'
zb
'
;
single
.
onItemChange
(
tests
,
'
pid
'
);
m
.
apply
(
single
.
collectDiff
());
assert
.
strictEqual
(
m
.
changeEvent
.
commonChangeAncestor
?.
label
,
'
a
'
);
});
test
(
'
gets the common ancestor (2)
'
,
()
=>
{
tests
.
children
!
[
0
].
children
!
[
0
].
label
=
'
za
'
;
tests
.
children
!
[
1
].
label
=
'
ab
'
;
single
.
onItemChange
(
tests
,
'
pid
'
);
m
.
apply
(
single
.
collectDiff
());
assert
.
strictEqual
(
m
.
changeEvent
.
commonChangeAncestor
?.
label
,
'
root
'
);
});
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录