Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
f91663e8
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
f91663e8
编写于
7月 26, 2021
作者:
C
Connor Peet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
testing: add explicit 'peek error' action to testitems
Fixes #125240
上级
3b8141a1
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
59 addition
and
15 deletion
+59
-15
src/vs/workbench/contrib/testing/browser/testing.contribution.ts
...workbench/contrib/testing/browser/testing.contribution.ts
+17
-2
src/vs/workbench/contrib/testing/browser/testingDecorations.ts
...s/workbench/contrib/testing/browser/testingDecorations.ts
+11
-6
src/vs/workbench/contrib/testing/browser/testingExplorerView.ts
.../workbench/contrib/testing/browser/testingExplorerView.ts
+3
-3
src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts
...vs/workbench/contrib/testing/browser/testingOutputPeek.ts
+3
-2
src/vs/workbench/contrib/testing/common/testId.ts
src/vs/workbench/contrib/testing/common/testId.ts
+24
-1
src/vs/workbench/contrib/testing/common/testingPeekOpener.ts
src/vs/workbench/contrib/testing/common/testingPeekOpener.ts
+1
-1
未找到文件。
src/vs/workbench/contrib/testing/browser/testing.contribution.ts
浏览文件 @
f91663e8
...
@@ -30,6 +30,7 @@ import { testingConfiguation } from 'vs/workbench/contrib/testing/common/configu
...
@@ -30,6 +30,7 @@ import { testingConfiguation } from 'vs/workbench/contrib/testing/common/configu
import
{
Testing
}
from
'
vs/workbench/contrib/testing/common/constants
'
;
import
{
Testing
}
from
'
vs/workbench/contrib/testing/common/constants
'
;
import
{
identifyTest
,
ITestIdWithSrc
,
TestRunProfileBitset
}
from
'
vs/workbench/contrib/testing/common/testCollection
'
;
import
{
identifyTest
,
ITestIdWithSrc
,
TestRunProfileBitset
}
from
'
vs/workbench/contrib/testing/common/testCollection
'
;
import
{
ITestProfileService
,
TestProfileService
}
from
'
vs/workbench/contrib/testing/common/testConfigurationService
'
;
import
{
ITestProfileService
,
TestProfileService
}
from
'
vs/workbench/contrib/testing/common/testConfigurationService
'
;
import
{
TestId
,
TestPosition
}
from
'
vs/workbench/contrib/testing/common/testId
'
;
import
{
ITestingAutoRun
,
TestingAutoRun
}
from
'
vs/workbench/contrib/testing/common/testingAutoRun
'
;
import
{
ITestingAutoRun
,
TestingAutoRun
}
from
'
vs/workbench/contrib/testing/common/testingAutoRun
'
;
import
{
TestingContentProvider
}
from
'
vs/workbench/contrib/testing/common/testingContentProvider
'
;
import
{
TestingContentProvider
}
from
'
vs/workbench/contrib/testing/common/testingContentProvider
'
;
import
{
TestingContextKeys
}
from
'
vs/workbench/contrib/testing/common/testingContextKeys
'
;
import
{
TestingContextKeys
}
from
'
vs/workbench/contrib/testing/common/testingContextKeys
'
;
...
@@ -142,9 +143,23 @@ CommandsRegistry.registerCommand({
...
@@ -142,9 +143,23 @@ CommandsRegistry.registerCommand({
id
:
'
vscode.peekTestError
'
,
id
:
'
vscode.peekTestError
'
,
handler
:
async
(
accessor
:
ServicesAccessor
,
extId
:
string
)
=>
{
handler
:
async
(
accessor
:
ServicesAccessor
,
extId
:
string
)
=>
{
const
lookup
=
accessor
.
get
(
ITestResultService
).
getStateById
(
extId
);
const
lookup
=
accessor
.
get
(
ITestResultService
).
getStateById
(
extId
);
if
(
lookup
)
{
if
(
!
lookup
)
{
accessor
.
get
(
ITestingPeekOpener
).
tryPeekFirstError
(
lookup
[
0
],
lookup
[
1
])
;
return
false
;
}
}
const
[
result
,
ownState
]
=
lookup
;
const
opener
=
accessor
.
get
(
ITestingPeekOpener
);
if
(
opener
.
tryPeekFirstError
(
result
,
ownState
))
{
// fast path
return
true
;
}
for
(
const
test
of
result
.
tests
)
{
if
(
TestId
.
compare
(
ownState
.
item
.
extId
,
test
.
item
.
extId
)
===
TestPosition
.
IsChild
&&
opener
.
tryPeekFirstError
(
result
,
test
))
{
return
true
;
}
}
return
false
;
}
}
});
});
...
...
src/vs/workbench/contrib/testing/browser/testingDecorations.ts
浏览文件 @
f91663e8
...
@@ -32,10 +32,10 @@ import { DefaultGutterClickAction, getTestingConfiguration, TestingConfigKeys }
...
@@ -32,10 +32,10 @@ import { DefaultGutterClickAction, getTestingConfiguration, TestingConfigKeys }
import
{
labelForTestInState
}
from
'
vs/workbench/contrib/testing/common/constants
'
;
import
{
labelForTestInState
}
from
'
vs/workbench/contrib/testing/common/constants
'
;
import
{
identifyTest
,
IncrementalTestCollectionItem
,
InternalTestItem
,
IRichLocation
,
ITestMessage
,
ITestRunProfile
,
TestResultItem
,
TestResultState
,
TestRunProfileBitset
}
from
'
vs/workbench/contrib/testing/common/testCollection
'
;
import
{
identifyTest
,
IncrementalTestCollectionItem
,
InternalTestItem
,
IRichLocation
,
ITestMessage
,
ITestRunProfile
,
TestResultItem
,
TestResultState
,
TestRunProfileBitset
}
from
'
vs/workbench/contrib/testing/common/testCollection
'
;
import
{
ITestProfileService
}
from
'
vs/workbench/contrib/testing/common/testConfigurationService
'
;
import
{
ITestProfileService
}
from
'
vs/workbench/contrib/testing/common/testConfigurationService
'
;
import
{
maxPriority
}
from
'
vs/workbench/contrib/testing/common/testingStates
'
;
import
{
isFailedState
,
maxPriority
}
from
'
vs/workbench/contrib/testing/common/testingStates
'
;
import
{
buildTestUri
,
TestUriType
}
from
'
vs/workbench/contrib/testing/common/testingUri
'
;
import
{
buildTestUri
,
TestUriType
}
from
'
vs/workbench/contrib/testing/common/testingUri
'
;
import
{
ITestResultService
}
from
'
vs/workbench/contrib/testing/common/testResultService
'
;
import
{
ITestResultService
}
from
'
vs/workbench/contrib/testing/common/testResultService
'
;
import
{
I
MainThreadTestCollection
,
I
TestService
,
testsInFile
}
from
'
vs/workbench/contrib/testing/common/testService
'
;
import
{
ITestService
,
testsInFile
}
from
'
vs/workbench/contrib/testing/common/testService
'
;
function
isOriginalInDiffEditor
(
codeEditorService
:
ICodeEditorService
,
codeEditor
:
ICodeEditor
):
boolean
{
function
isOriginalInDiffEditor
(
codeEditorService
:
ICodeEditorService
,
codeEditor
:
ICodeEditor
):
boolean
{
const
diffEditors
=
codeEditorService
.
listDiffEditors
();
const
diffEditors
=
codeEditorService
.
listDiffEditors
();
...
@@ -402,7 +402,7 @@ abstract class RunTestDecoration extends Disposable {
...
@@ -402,7 +402,7 @@ abstract class RunTestDecoration extends Disposable {
/**
/**
* Gets context menu actions relevant for a singel test.
* Gets context menu actions relevant for a singel test.
*/
*/
protected
getTestContextMenuActions
(
collection
:
IMainThreadTestCollection
,
test
:
InternalTes
tItem
)
{
protected
getTestContextMenuActions
(
test
:
InternalTestItem
,
resultItem
?:
TestResul
tItem
)
{
const
testActions
:
IAction
[]
=
[];
const
testActions
:
IAction
[]
=
[];
const
capabilities
=
this
.
testProfileService
.
controllerCapabilities
(
test
.
controllerId
);
const
capabilities
=
this
.
testProfileService
.
controllerCapabilities
(
test
.
controllerId
);
if
(
capabilities
&
TestRunProfileBitset
.
Run
)
{
if
(
capabilities
&
TestRunProfileBitset
.
Run
)
{
...
@@ -437,6 +437,11 @@ abstract class RunTestDecoration extends Disposable {
...
@@ -437,6 +437,11 @@ abstract class RunTestDecoration extends Disposable {
}));
}));
}
}
if
(
resultItem
&&
isFailedState
(
resultItem
.
computedState
))
{
testActions
.
push
(
new
Action
(
'
testing.gutter.peekFailure
'
,
localize
(
'
peek failure
'
,
'
Peek Error
'
),
undefined
,
undefined
,
()
=>
this
.
commandService
.
executeCommand
(
'
vscode.peekTestError
'
,
test
.
item
.
extId
)));
}
testActions
.
push
(
new
Action
(
'
testing.gutter.reveal
'
,
localize
(
'
reveal test
'
,
'
Reveal in Test Explorer
'
),
undefined
,
undefined
,
testActions
.
push
(
new
Action
(
'
testing.gutter.reveal
'
,
localize
(
'
reveal test
'
,
'
Reveal in Test Explorer
'
),
undefined
,
undefined
,
()
=>
this
.
commandService
.
executeCommand
(
'
vscode.revealTestInExplorer
'
,
test
.
item
.
extId
)));
()
=>
this
.
commandService
.
executeCommand
(
'
vscode.revealTestInExplorer
'
,
test
.
item
.
extId
)));
...
@@ -476,8 +481,8 @@ class MultiRunTestDecoration extends RunTestDecoration implements ITestDecoratio
...
@@ -476,8 +481,8 @@ class MultiRunTestDecoration extends RunTestDecoration implements ITestDecoratio
allActions
.
push
(
new
Action
(
'
testing.gutter.debugAll
'
,
localize
(
'
debug all test
'
,
'
Debug All Tests
'
),
undefined
,
undefined
,
()
=>
this
.
defaultDebug
()));
allActions
.
push
(
new
Action
(
'
testing.gutter.debugAll
'
,
localize
(
'
debug all test
'
,
'
Debug All Tests
'
),
undefined
,
undefined
,
()
=>
this
.
defaultDebug
()));
}
}
const
testSubmenus
=
this
.
tests
.
map
(({
test
})
=>
const
testSubmenus
=
this
.
tests
.
map
(({
test
,
resultItem
})
=>
new
SubmenuAction
(
test
.
item
.
extId
,
test
.
item
.
label
,
this
.
getTestContextMenuActions
(
t
his
.
testService
.
collection
,
test
)));
new
SubmenuAction
(
test
.
item
.
extId
,
test
.
item
.
label
,
this
.
getTestContextMenuActions
(
t
est
,
resultItem
)));
return
Separator
.
join
(
allActions
,
testSubmenus
);
return
Separator
.
join
(
allActions
,
testSubmenus
);
}
}
...
@@ -519,7 +524,7 @@ class RunSingleTestDecoration extends RunTestDecoration implements ITestDecorati
...
@@ -519,7 +524,7 @@ class RunSingleTestDecoration extends RunTestDecoration implements ITestDecorati
}
}
protected
override
getContextMenuActions
(
e
:
IEditorMouseEvent
)
{
protected
override
getContextMenuActions
(
e
:
IEditorMouseEvent
)
{
return
this
.
getTestContextMenuActions
(
this
.
test
Service
.
collection
,
this
.
test
);
return
this
.
getTestContextMenuActions
(
this
.
test
,
this
.
resultItem
);
}
}
protected
override
defaultRun
()
{
protected
override
defaultRun
()
{
...
...
src/vs/workbench/contrib/testing/browser/testingExplorerView.ts
浏览文件 @
f91663e8
...
@@ -470,7 +470,7 @@ export class TestingExplorerViewModel extends Disposable {
...
@@ -470,7 +470,7 @@ export class TestingExplorerViewModel extends Disposable {
}
}
}));
}));
this
.
_register
(
this
.
tree
.
onDidChangeSelection
(
async
evt
=>
{
this
.
_register
(
this
.
tree
.
onDidChangeSelection
(
evt
=>
{
if
(
evt
.
browserEvent
instanceof
MouseEvent
&&
(
evt
.
browserEvent
.
altKey
||
evt
.
browserEvent
.
shiftKey
))
{
if
(
evt
.
browserEvent
instanceof
MouseEvent
&&
(
evt
.
browserEvent
.
altKey
||
evt
.
browserEvent
.
shiftKey
))
{
return
;
// don't focus when alt-clicking to multi select
return
;
// don't focus when alt-clicking to multi select
}
}
...
@@ -478,7 +478,7 @@ export class TestingExplorerViewModel extends Disposable {
...
@@ -478,7 +478,7 @@ export class TestingExplorerViewModel extends Disposable {
const
selected
=
evt
.
elements
[
0
];
const
selected
=
evt
.
elements
[
0
];
if
(
selected
&&
evt
.
browserEvent
&&
selected
instanceof
TestItemTreeElement
if
(
selected
&&
evt
.
browserEvent
&&
selected
instanceof
TestItemTreeElement
&&
selected
.
children
.
size
===
0
&&
selected
.
test
.
expand
===
TestItemExpandState
.
NotExpandable
)
{
&&
selected
.
children
.
size
===
0
&&
selected
.
test
.
expand
===
TestItemExpandState
.
NotExpandable
)
{
await
this
.
tryPeekError
(
selected
);
this
.
tryPeekError
(
selected
);
}
}
}));
}));
...
@@ -629,7 +629,7 @@ export class TestingExplorerViewModel extends Disposable {
...
@@ -629,7 +629,7 @@ export class TestingExplorerViewModel extends Disposable {
/**
/**
* Tries to peek the first test error, if the item is in a failed state.
* Tries to peek the first test error, if the item is in a failed state.
*/
*/
private
async
tryPeekError
(
item
:
TestItemTreeElement
)
{
private
tryPeekError
(
item
:
TestItemTreeElement
)
{
const
lookup
=
item
.
test
&&
this
.
testResults
.
getStateById
(
item
.
test
.
item
.
extId
);
const
lookup
=
item
.
test
&&
this
.
testResults
.
getStateById
(
item
.
test
.
item
.
extId
);
return
lookup
&&
lookup
[
1
].
tasks
.
some
(
s
=>
isFailedState
(
s
.
state
))
return
lookup
&&
lookup
[
1
].
tasks
.
some
(
s
=>
isFailedState
(
s
.
state
))
?
this
.
peekOpener
.
tryPeekFirstError
(
lookup
[
0
],
lookup
[
1
],
{
preserveFocus
:
true
})
?
this
.
peekOpener
.
tryPeekFirstError
(
lookup
[
0
],
lookup
[
1
],
{
preserveFocus
:
true
})
...
...
src/vs/workbench/contrib/testing/browser/testingOutputPeek.ts
浏览文件 @
f91663e8
...
@@ -154,14 +154,14 @@ export class TestingPeekOpener extends Disposable implements ITestingPeekOpener
...
@@ -154,14 +154,14 @@ export class TestingPeekOpener extends Disposable implements ITestingPeekOpener
}
}
/** @inheritdoc */
/** @inheritdoc */
public
async
tryPeekFirstError
(
result
:
ITestResult
,
test
:
TestResultItem
,
options
?:
Partial
<
ITextEditorOptions
>
)
{
public
tryPeekFirstError
(
result
:
ITestResult
,
test
:
TestResultItem
,
options
?:
Partial
<
ITextEditorOptions
>
)
{
const
candidate
=
this
.
getFailedCandidateMessage
(
test
);
const
candidate
=
this
.
getFailedCandidateMessage
(
test
);
if
(
!
candidate
)
{
if
(
!
candidate
)
{
return
false
;
return
false
;
}
}
const
message
=
candidate
.
message
;
const
message
=
candidate
.
message
;
return
this
.
showPeekFromUri
({
this
.
showPeekFromUri
({
type
:
TestUriType
.
ResultMessage
,
type
:
TestUriType
.
ResultMessage
,
documentUri
:
message
.
location
!
.
uri
,
documentUri
:
message
.
location
!
.
uri
,
taskIndex
:
candidate
.
taskId
,
taskIndex
:
candidate
.
taskId
,
...
@@ -169,6 +169,7 @@ export class TestingPeekOpener extends Disposable implements ITestingPeekOpener
...
@@ -169,6 +169,7 @@ export class TestingPeekOpener extends Disposable implements ITestingPeekOpener
resultId
:
result
.
id
,
resultId
:
result
.
id
,
testExtId
:
test
.
item
.
extId
,
testExtId
:
test
.
item
.
extId
,
},
{
selection
:
message
.
location
!
.
range
,
...
options
});
},
{
selection
:
message
.
location
!
.
range
,
...
options
});
return
true
;
}
}
/** @inheritdoc */
/** @inheritdoc */
...
...
src/vs/workbench/contrib/testing/common/testId.ts
浏览文件 @
f91663e8
...
@@ -69,6 +69,25 @@ export class TestId {
...
@@ -69,6 +69,25 @@ export class TestId {
return
base
.
toString
()
+
TestIdPathParts
.
Delimiter
+
b
;
return
base
.
toString
()
+
TestIdPathParts
.
Delimiter
+
b
;
}
}
/**
* Compares the position of the two ID strings.
*/
public
static
compare
(
a
:
string
,
b
:
string
)
{
if
(
a
===
b
)
{
return
TestPosition
.
IsSame
;
}
if
(
b
.
startsWith
(
a
+
TestIdPathParts
.
Delimiter
))
{
return
TestPosition
.
IsChild
;
}
if
(
a
.
startsWith
(
b
+
TestIdPathParts
.
Delimiter
))
{
return
TestPosition
.
IsParent
;
}
return
TestPosition
.
Disconnected
;
}
constructor
(
constructor
(
public
readonly
path
:
readonly
string
[],
public
readonly
path
:
readonly
string
[],
private
readonly
viewEnd
=
path
.
length
,
private
readonly
viewEnd
=
path
.
length
,
...
@@ -124,7 +143,11 @@ export class TestId {
...
@@ -124,7 +143,11 @@ export class TestId {
/**
/**
* Compares the other test ID with this one.
* Compares the other test ID with this one.
*/
*/
public
compare
(
other
:
TestId
)
{
public
compare
(
other
:
TestId
|
string
)
{
if
(
typeof
other
===
'
string
'
)
{
return
TestId
.
compare
(
this
.
toString
(),
other
);
}
for
(
let
i
=
0
;
i
<
other
.
viewEnd
&&
i
<
this
.
viewEnd
;
i
++
)
{
for
(
let
i
=
0
;
i
<
other
.
viewEnd
&&
i
<
this
.
viewEnd
;
i
++
)
{
if
(
other
.
path
[
i
]
!==
this
.
path
[
i
])
{
if
(
other
.
path
[
i
]
!==
this
.
path
[
i
])
{
return
TestPosition
.
Disconnected
;
return
TestPosition
.
Disconnected
;
...
...
src/vs/workbench/contrib/testing/common/testingPeekOpener.ts
浏览文件 @
f91663e8
...
@@ -15,7 +15,7 @@ export interface ITestingPeekOpener {
...
@@ -15,7 +15,7 @@ export interface ITestingPeekOpener {
* Tries to peek the first test error, if the item is in a failed state.
* Tries to peek the first test error, if the item is in a failed state.
* @returns a boolean indicating whether a peek was opened
* @returns a boolean indicating whether a peek was opened
*/
*/
tryPeekFirstError
(
result
:
ITestResult
,
test
:
TestResultItem
,
options
?:
Partial
<
ITextEditorOptions
>
):
Promise
<
boolean
>
;
tryPeekFirstError
(
result
:
ITestResult
,
test
:
TestResultItem
,
options
?:
Partial
<
ITextEditorOptions
>
):
boolean
;
/**
/**
* Opens the peek. Shows any available message.
* Opens the peek. Shows any available message.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录