Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deno.bench, Deno.test in the same file break each other #23041

Closed
rotu opened this issue Mar 23, 2024 · 1 comment · Fixed by #23055
Closed

Deno.bench, Deno.test in the same file break each other #23041

rotu opened this issue Mar 23, 2024 · 1 comment · Fixed by #23055
Labels
bug Something isn't working correctly testing related to deno test and coverage

Comments

@rotu
Copy link
Contributor

rotu commented Mar 23, 2024

Version: Deno 1.40.5, 1.41.3

If you have both tests and benchmarks in the same file, both deno test and deno bench fail. This appears to work in 1.39.4.

// example.js
Deno.test('atest', async () => {})
Deno.bench('abench', async () => {})
$ deno test example.js 
Check file:///Users/dan/Source/MiniProjects/example.js
Uncaught error from ./example.js FAILED

 ERRORS 

./example.js (uncaught error)
error: (in promise) TypeError: ops.op_register_bench is not a function
Deno.bench('abench', async () => {})
     ^
    at Object.bench (ext:cli/40_bench.js:53:32)
    at file:///Users/dan/Source/MiniProjects/example.js:2: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 

./example.js (uncaught error)

FAILED | 0 passed | 1 failed (0ms)

error: Test failed

Stack backtrace:
   0: std::backtrace::Backtrace::capture
   1: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
   2: deno_core::error::generic_error
   3: deno::tools::test::report_tests::{{closure}}
   4: <deno_unsync::task::MaskFutureAsSend<F> as core::future::future::Future>::poll
   5: tokio::runtime::task::raw::poll
   6: deno::main
   7: std::sys_common::backtrace::__rust_begin_short_backtrace
   8: _main

$ deno bench example.js 
error: (in promise) TypeError: op_register_test is not a function
Deno.test('atest', async () => {})
     ^
    at testInner (ext:cli/40_test.js:472:18)
    at Object.test (ext:cli/40_test.js:499:10)
    at file:///Users/dan/Source/MiniProjects/example.js:1:6
This error was not caught from a benchmark and caused the bench runner to fail on the referenced module.
It most likely originated from a dangling promise, event/timeout handler or top-level code.

error: Bench failed

Stack backtrace:
   0: std::backtrace::Backtrace::capture
   1: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
   2: deno_core::error::generic_error
   3: <deno_unsync::task::MaskFutureAsSend<F> as core::future::future::Future>::poll
   4: tokio::runtime::task::raw::poll
   5: deno::main
   6: std::sys_common::backtrace::__rust_begin_short_backtrace
   7: _main
@rotu
Copy link
Contributor Author

rotu commented Mar 23, 2024

I'm thinking this was caused by #22112, namely removing the supposedly unused checks in mmastrac@c8dd0c7

@bartlomieju bartlomieju added bug Something isn't working correctly testing related to deno test and coverage labels Mar 24, 2024
bartlomieju added a commit that referenced this issue Mar 24, 2024
Fixes regression introduced in
#22112 that
removed checks if `Deno.test` or `Deno.bench` are not used in respective
subcommands.

Closes #23041
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly testing related to deno test and coverage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants