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

Commit95f9621

Browse files
committed
configure test failure message
1 parent59f27f6 commit95f9621

File tree

4 files changed

+48
-8
lines changed

4 files changed

+48
-8
lines changed

‎src/editor/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ export const createCommands = ({extensionPath, workspaceState, workspaceRoot}: C
5959
vscode.window.showInformationMessage('PASS')
6060
webview.send({type:'TEST_PASS', payload})
6161
},
62-
onFail:(payload:Payload)=>{
62+
onFail:(payload:Payload,message:string)=>{
6363
// send test fail message back to client
64-
vscode.window.showWarningMessage('FAIL')
64+
vscode.window.showWarningMessage(`FAIL:${message}`)
6565
webview.send({type:'TEST_FAIL', payload})
6666
},
6767
onError:(payload:Payload)=>{

‎src/services/testRunner/index.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface Payload {
99

1010
interfaceCallbacks{
1111
onSuccess(payload:Payload):void
12-
onFail(payload:Payload):void
12+
onFail(payload:Payload,message:string):void
1313
onRun(payload:Payload):void
1414
onError(payload:Payload):void
1515
}
@@ -55,12 +55,16 @@ const createTestRunner = (config: TestRunnerConfig, callbacks: Callbacks) => {
5555
callbacks.onSuccess(payload)
5656
if(onSuccess){onSuccess()}
5757
}else{
58-
// TODO: parse failure message
58+
59+
// TODO: consider logging output to channel
5960
// open terminal with failed test string
6061
// const channel = getOutputChannel(outputChannelName)
6162
// channel.show(false)
62-
// channel.appendLine(testsFailed.message)
63-
callbacks.onFail(payload)
63+
// channel.appendLine(tap.message)
64+
65+
66+
constmessage=tap.message ?tap.message :''
67+
callbacks.onFail(payload,message)
6468
}
6569
}
6670
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
importparserfrom'./parser'
2+
3+
4+
5+
describe('parser',()=>{
6+
test('should detect success',()=>{
7+
constexample=`
8+
1..2
9+
ok 1 - Should pass
10+
ok 2 - Should also pass
11+
`
12+
expect(parser(example)).toEqual({ok:true})
13+
})
14+
test('should detect failure',()=>{
15+
constexample=`
16+
1..3
17+
ok 1 - Should pass
18+
not ok 2 - This one fails
19+
ok 3 - Also passes
20+
`
21+
expect(parser(example).ok).toBe(false)
22+
})
23+
test('should return failure message',()=>{
24+
constexample=`
25+
1..4
26+
ok 1 - Should pass
27+
not ok 2 - First to fail
28+
ok 3 - Also passes
29+
not ok 4 - Second to fail
30+
`
31+
expect(parser(example).message).toBe('First to fail')
32+
})
33+
})

‎src/services/testRunner/parser.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
interfaceParserOutput{
22
ok:boolean
3+
message?:string
34
}
45

56
constparser=(text:string):ParserOutput=>{
67
constlines=text.split('\n')
78
for(constlineoflines){
8-
if(line.match(/^notok/)){
9-
return{ok:false}
9+
// parse failed test
10+
constmatch=line.match(/^notok\d+-(.+)+/)
11+
if(!!match){
12+
return{ok:false,message:match[1]}
1013
}
1114
}
1215
return{ok:true}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp