Skip to content

Commit

Permalink
add panic hook to test server
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed May 6, 2024
1 parent 45427ce commit 899ef28
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/util/server/src/test_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

fn main() {
setup_panic_hook();
test_server::servers::run_all_servers();
}

fn setup_panic_hook() {
// Tokio does not exit the process when a task panics, so we define a custom
// panic hook to implement this behaviour.
let orig_hook = std::panic::take_hook();
std::panic::set_hook(Box::new(move |panic_info| {
eprintln!("\n============================================================");
eprintln!("Test server panicked!\n");
orig_hook(panic_info);
std::process::exit(1);
}));
}

0 comments on commit 899ef28

Please sign in to comment.