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

Commit80cde2a

Browse files
authored
fix(reporters): write buffered stdout/stderr on process exit (#6932)
1 parenta5bbc0a commit80cde2a

File tree

5 files changed

+28
-54
lines changed

5 files changed

+28
-54
lines changed

‎packages/vitest/LICENSE.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,30 +1245,6 @@ Repository: git://github.com/feross/run-parallel.git
12451245
12461246
---------------------------------------
12471247

1248-
##signal-exit
1249-
License: ISC
1250-
By: Ben Coe
1251-
Repository:https://github.com/tapjs/signal-exit.git
1252-
1253-
>The ISC License
1254-
>
1255-
>Copyright (c) 2015, Contributors
1256-
>
1257-
>Permission to use, copy, modify, and/or distribute this software
1258-
>for any purpose with or without fee is hereby granted, provided
1259-
>that the above copyright notice and this permission notice
1260-
>appear in all copies.
1261-
>
1262-
>THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1263-
>WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
1264-
>OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
1265-
>LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
1266-
>OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
1267-
>WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
1268-
>ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1269-
1270-
---------------------------------------
1271-
12721248
##sisteransi
12731249
License: MIT
12741250
By: Terkel Gjervig

‎packages/vitest/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
"expect-type":"^1.1.0",
163163
"magic-string":"^0.30.12",
164164
"pathe":"^1.1.2",
165-
"restore-cursor":"^5.1.0",
166165
"std-env":"^3.8.0",
167166
"tinybench":"^2.9.0",
168167
"tinyexec":"^0.3.1",

‎packages/vitest/src/node/reporters/base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export abstract class BaseReporter implements Reporter {
140140
}
141141

142142
elseif(this.renderSucceed||anyFailed){
143-
this.log(`${c.green(c.dim(F_CHECK))}${getTestName(test,c.dim(' > '))}`)
143+
this.log(`${c.dim(getStateSymbol(test))}${getTestName(test,c.dim(' > '))}`)
144144
}
145145
}
146146
}

‎packages/vitest/src/node/reporters/renderers/windowedRenderer.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
importtype{Writable}from'node:stream'
22
importtype{Vitest}from'../../core'
33
import{stripVTControlCharacters}from'node:util'
4-
importrestoreCursorfrom'restore-cursor'
54

65
constDEFAULT_RENDER_INTERVAL=16
76

@@ -49,9 +48,9 @@ export class WindowRenderer {
4948
this.cleanups.push(
5049
this.interceptStream(process.stdout,'output'),
5150
this.interceptStream(process.stderr,'error'),
51+
this.addProcessExitListeners(),
5252
)
5353

54-
restoreCursor()
5554
this.write(HIDE_CURSOR,'output')
5655

5756
this.start()
@@ -175,6 +174,32 @@ export class WindowRenderer {
175174
privatewrite(message:string,type:'output'|'error'='output'){
176175
(this.streams[type]asWritable['write'])(message)
177176
}
177+
178+
privateaddProcessExitListeners(){
179+
constonExit=(signal?:string|number,exitCode?:number)=>{
180+
// Write buffered content on unexpected exits, e.g. direct `process.exit()` calls
181+
this.flushBuffer()
182+
this.stop()
183+
184+
// Interrupted signals don't set exit code automatically.
185+
// Use same exit code as node: https://nodejs.org/api/process.html#signal-events
186+
if(process.exitCode===undefined){
187+
process.exitCode=exitCode!==undefined ?(128+exitCode) :Number(signal)
188+
}
189+
190+
process.exit()
191+
}
192+
193+
process.once('SIGINT',onExit)
194+
process.once('SIGTERM',onExit)
195+
process.once('exit',onExit)
196+
197+
returnfunctioncleanup(){
198+
process.off('SIGINT',onExit)
199+
process.off('SIGTERM',onExit)
200+
process.off('exit',onExit)
201+
}
202+
}
178203
}
179204

180205
/** Calculate the actual row count needed to render `rows` into `stream` */

‎pnpm-lock.yaml

Lines changed: 0 additions & 26 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp