denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.05k stars 5.39k forks source link

Empty test name makes language server panic, test doesn't exit #17119

Open pkb-pmj opened 1 year ago

pkb-pmj commented 1 year ago

Describe the bug

If I write a valid test and a test with an empty name and run either of them, the test never exits. Looking at Deno Language Server output, it seems to panic:

Executing test run with arguments: deno test --allow-all --no-check --config deno.json

============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: macos x86_64
Version: 1.25.1
Args: ["/Users/admin/.deno/bin/deno", "lsp"]

thread '<unnamed>' panicked at 'assertion failed: `(left == right)`
  left: `0`,
 right: `1`', cli/lsp/testing/execution.rs:687:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[Info  - 3:05:25 PM] Connection to server got closed. Server will restart.

To Reproduce

  1. Write two tests like this:
    Deno.test("valid", () => undefined);
    Deno.test("", () => undefined);
  2. Run either test using the green triangle VSCode button.

Expected behavior

  1. The test should exit, not run forever.
  2. It should say what's wrong. When I run deno test, it correctly returns this:

    
    Check file:///[...]/src/scratch/api.ts
    Uncaught error from ./src/scratch/api.ts FAILED
    valid ... cancelled (0ms)
    
    ERRORS 

./src/scratch/api.ts (uncaught error) error: TypeError: The test name can't be empty Deno.test("", () => undefined); ^ at Object.test (deno:cli/js/40_testing.js:633:15) at file:///[...]/src/scratch/api.ts:180:6 This error was not caught from a test and caused the test runner to fail on the referenced module. It most likely originated from a dangling promise, event/timeout handler or top-level code.

FAILURES

./src/scratch/api.ts (uncaught error)

FAILED | 0 passed | 2 failed (21ms)

error: Test failed


(That's why I report it here first)

**Screenshots**

![Test running forever](https://user-images.githubusercontent.com/103094889/208306033-64cb79a5-6da9-49d3-8b3a-a317aa4465f0.png)

**Versions**

vscode: 1.74.1 (Universal) deno: 1.29.1 extension: v3.15.0
crowlKats commented 1 year ago

To add to this, even just

Deno.test("valid", () => undefined);
throw "foo";

Will cause a panic.

bartlomieju commented 1 year ago

@crowlKats I can't repeat this problem on latest canary. Perhaps it was fixed in https://github.com/denoland/deno/commit/1e0017d8fc3a7ed0dd5775196a861d46caea5c33?

bartlomieju commented 1 year ago

Actually I just noticed that that "running tests" spins forever on the left in the bottom bar. So it seems that's still an issue.