feat(cli): Add slow test warning (#23874)

By default, uses a 60 second timeout, backing off 2x each time (can be
overridden using the hidden `DENO_SLOW_TEST_TIMEOUT` which we implement
only really for spec testing.

```
Deno.test(async function test() {
  await new Promise(r => setTimeout(r, 130_000));
});
```

```
$ target/debug/deno test /tmp/test_slow.ts 
Check file:///tmp/test_slow.ts
running 1 test from ../../../../../../tmp/test_slow.ts
test ...'test' is running very slowly (1m0s)
'test' is running very slowly (2m0s)
 ok (2m10s)

ok | 1 passed | 0 failed (2m10s)
```

---------

Signed-off-by: Matt Mastracci <matthew@mastracci.com>
Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
Matt Mastracci 2024-05-22 08:08:27 -06:00 committed by GitHub
parent 7ab7a14db7
commit 596a2996cf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 83 additions and 3 deletions

View file

@ -353,6 +353,9 @@ impl TestRun {
test::TestEvent::Output(_, output) => {
reporter.report_output(&output);
}
test::TestEvent::Slow(id, elapsed) => {
reporter.report_slow(tests.read().get(&id).unwrap(), elapsed);
}
test::TestEvent::Result(id, result, elapsed) => {
if tests_with_result.insert(id) {
let description = tests.read().get(&id).unwrap().clone();
@ -610,6 +613,8 @@ impl LspTestReporter {
self.progress(lsp_custom::TestRunProgressMessage::Started { test });
}
fn report_slow(&mut self, _desc: &test::TestDescription, _elapsed: u64) {}
fn report_output(&mut self, output: &[u8]) {
let test = self
.current_test