Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4268b39

Browse files
committed
Add logs channel. Add fail logs
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent1a00b00 commit4268b39

File tree

3 files changed

+29
-17
lines changed

3 files changed

+29
-17
lines changed

‎src/services/testRunner/formatOutput.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import { ParserOutput, Fail } from './parser'
44
// export const formatSuccessOutput = (tap: ParserOutput): string => {}
55

66
exportconstformatFailOutput=(tap:ParserOutput):string=>{
7-
letoutput=`TESTS\n`
7+
letoutput=`FAILEDTESTS\n`
88
tap.failed.forEach((fail:Fail)=>{
9-
constdetails=fail.details ?`\n${fail.details}\n\n` :''
10-
output+=` ✘${fail.message}\n${details}`
9+
constdetails=fail.details ?`\n${fail.details}\n` :''
10+
constlogs=fail.logs ?`\n${fail.logs.join('\n')}\n` :''
11+
constresult=`${logs}${fail.message}\n${details}`
12+
output+=result
1113
})
1214
returnoutput
1315
}

‎src/services/testRunner/index.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ interface TestRunnerConfig {
2121
command:string
2222
}
2323

24+
constfailChannelName='CodeRoad (Tests)'
25+
constlogChannelName='CodeRoad (Logs)'
26+
2427
constcreateTestRunner=(config:TestRunnerConfig,callbacks:Callbacks)=>{
2528
returnasync(payload:Payload,onSuccess?:()=>void):Promise<void>=>{
2629
conststartTime=throttle()
@@ -52,25 +55,28 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
5255
const{ stdout, stderr}=result
5356

5457
consttap=parser(stdout||'')
58+
59+
displayOutput({channel:logChannelName,text:tap.logs.join('\n'),show:false})
60+
5561
if(stderr){
5662
// FAIL also trigger stderr
5763
if(stdout&&stdout.length&&!tap.ok){
5864
constfirstFailMessage=tap.failed[0].message
5965
callbacks.onFail(payload,firstFailMessage)
6066
constoutput=formatFailOutput(tap)
61-
displayOutput(output)
67+
displayOutput({channel:failChannelName,text:output,show:true})
6268
return
6369
}else{
6470
callbacks.onError(payload)
6571
// open terminal with error string
66-
displayOutput(stderr)
72+
displayOutput({channel:failChannelName,text:stderr,show:true})
6773
return
6874
}
6975
}
7076

7177
// PASS
7278
if(tap.ok){
73-
clearOutput()
79+
clearOutput(failChannelName)
7480
callbacks.onSuccess(payload)
7581
if(onSuccess){
7682
onSuccess()

‎src/services/testRunner/output.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
import*asvscodefrom'vscode'
22

3-
letchannel:vscode.OutputChannel
3+
constchannels:{key:string;value:vscode.OutputChannel}|{}={}
44

55
constgetOutputChannel=(name:string):vscode.OutputChannel=>{
6-
if(!channel){
7-
channel=vscode.window.createOutputChannel(name)
6+
if(!channels[name]){
7+
channels[name]=vscode.window.createOutputChannel(name)
88
}
9-
returnchannel
9+
returnchannels[name]
1010
}
1111

12-
constoutputChannelName='CodeRoad Output'
12+
interfaceDisplayOutput{
13+
channel:string
14+
text:string
15+
show?:boolean
16+
}
1317

14-
exportconstdisplayOutput=(text:string)=>{
15-
constchannel=getOutputChannel(outputChannelName)
18+
exportconstdisplayOutput=(params:DisplayOutput)=>{
19+
constchannel=getOutputChannel(params.channel)
1620
channel.clear()
17-
channel.show(true)
18-
channel.append(text)
21+
channel.show(params.show||false)
22+
channel.append(params.text)
1923
}
2024

21-
exportconstclearOutput=()=>{
22-
constchannel=getOutputChannel(outputChannelName)
25+
exportconstclearOutput=(channelName:string)=>{
26+
constchannel=getOutputChannel(channelName)
2327
channel.show(false)
2428
channel.clear()
2529
channel.hide()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp