From 5129276a4be3e97a1311afe47665a532d2ec98aa Mon Sep 17 00:00:00 2001 From: gluax <16431709+gluax@users.noreply.github.com> Date: Wed, 8 Jun 2022 10:50:23 -0700 Subject: [PATCH] some compiler lib cleanup --- tests/test-framework/Cargo.toml | 5 ++++- tests/test-framework/src/runner.rs | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/test-framework/Cargo.toml b/tests/test-framework/Cargo.toml index fa4a97beb6..ff592d09c4 100644 --- a/tests/test-framework/Cargo.toml +++ b/tests/test-framework/Cargo.toml @@ -17,6 +17,9 @@ include = [ "Cargo.toml", "src", "README.md", "LICENSE.md" ] license = "GPL-3.0" edition = "2018" +[dependencies] +backtrace = "0.3.65" + [dependencies.serde] version = "1.0" features = [ "derive" ] @@ -64,4 +67,4 @@ path = "../../leo/errors" version = "1.5.3" [dependencies.regex] -version = "1.5" \ No newline at end of file +version = "1.5" diff --git a/tests/test-framework/src/runner.rs b/tests/test-framework/src/runner.rs index a1be3677af..8beb27fbe8 100644 --- a/tests/test-framework/src/runner.rs +++ b/tests/test-framework/src/runner.rs @@ -57,7 +57,14 @@ fn set_hook() -> Arc>> { let panic_buf = panic_buf.clone(); Box::new(move |e| { if thread::current().id() == thread_id { - *panic_buf.lock().unwrap() = Some(e.to_string()); + if !std::env::var("RUST_BACKTRACE") + .unwrap_or_else(|_| "".to_string()) + .is_empty() + { + *panic_buf.lock().unwrap() = Some(format!("{:?}", backtrace::Backtrace::new())); + } else { + *panic_buf.lock().unwrap() = Some(e.to_string()); + } } else { println!("{}", e) }