From 44d72c046ee0ae092935f36cfa73d31d1ca39247 Mon Sep 17 00:00:00 2001 From: KtorZ Date: Sat, 17 Dec 2022 13:33:32 +0100 Subject: [PATCH] Print files / tests as they're processed when --debug This is because there's no proper way to catch panics in Rust, which makes it hard to know _which_ test did cause the panic when this happen. The stack trace gives little detail about this, but we can print this information before it happens -- making it easier to identify the culprit. --- crates/cli/src/lib.rs | 8 ++++++++ crates/project/src/lib.rs | 13 +++++++++++-- crates/project/src/telemetry.rs | 4 ++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index 28cb9f01..bf7b8ac5 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -101,6 +101,14 @@ impl telemetry::EventListener for Terminal { output_path.to_str().unwrap_or("").bright_blue() ); } + telemetry::Event::GeneratingUPLCFor { name, path } => { + println!( + "{} {}.{{{}}}", + "...Generating Untyped Plutus Core for".bold().purple(), + path.to_str().unwrap_or("").blue(), + name.bright_blue(), + ); + } telemetry::Event::EvaluatingFunction { results } => { println!("{}\n", "...Evaluating function".bold().purple()); diff --git a/crates/project/src/lib.rs b/crates/project/src/lib.rs index 5f7ad8e4..e89e4b67 100644 --- a/crates/project/src/lib.rs +++ b/crates/project/src/lib.rs @@ -173,8 +173,9 @@ where match_tests, verbose, } => { - let tests = self - .collect_scripts(&checked_modules, |def| matches!(def, Definition::Test(..)))?; + let tests = self.collect_scripts(&checked_modules, verbose, |def| { + matches!(def, Definition::Test(..)) + })?; if !tests.is_empty() { self.event_listener.handle_event(Event::RunningTests); } @@ -516,6 +517,7 @@ where fn collect_scripts( &mut self, checked_modules: &CheckedModules, + verbose: bool, should_collect: fn(&TypedDefinition) -> bool, ) -> Result, Error> { let mut programs = Vec::new(); @@ -594,6 +596,13 @@ where .. } = func_def; + if verbose { + self.event_listener.handle_event(Event::GeneratingUPLCFor { + name: name.clone(), + path: input_path.clone(), + }) + } + let mut generator = CodeGenerator::new( &functions, // &type_aliases, diff --git a/crates/project/src/telemetry.rs b/crates/project/src/telemetry.rs index a09bbf63..99c6265b 100644 --- a/crates/project/src/telemetry.rs +++ b/crates/project/src/telemetry.rs @@ -24,6 +24,10 @@ pub enum Event { GeneratingUPLC { output_path: PathBuf, }, + GeneratingUPLCFor { + name: String, + path: PathBuf, + }, EvaluatingFunction { results: Vec, },