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.
This commit is contained in:
KtorZ 2022-12-17 13:33:32 +01:00 committed by Lucas
parent eb386f4606
commit 44d72c046e
3 changed files with 23 additions and 2 deletions

View File

@ -101,6 +101,14 @@ impl telemetry::EventListener for Terminal {
output_path.to_str().unwrap_or("").bright_blue() 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 } => { telemetry::Event::EvaluatingFunction { results } => {
println!("{}\n", "...Evaluating function".bold().purple()); println!("{}\n", "...Evaluating function".bold().purple());

View File

@ -173,8 +173,9 @@ where
match_tests, match_tests,
verbose, verbose,
} => { } => {
let tests = self let tests = self.collect_scripts(&checked_modules, verbose, |def| {
.collect_scripts(&checked_modules, |def| matches!(def, Definition::Test(..)))?; matches!(def, Definition::Test(..))
})?;
if !tests.is_empty() { if !tests.is_empty() {
self.event_listener.handle_event(Event::RunningTests); self.event_listener.handle_event(Event::RunningTests);
} }
@ -516,6 +517,7 @@ where
fn collect_scripts( fn collect_scripts(
&mut self, &mut self,
checked_modules: &CheckedModules, checked_modules: &CheckedModules,
verbose: bool,
should_collect: fn(&TypedDefinition) -> bool, should_collect: fn(&TypedDefinition) -> bool,
) -> Result<Vec<Script>, Error> { ) -> Result<Vec<Script>, Error> {
let mut programs = Vec::new(); let mut programs = Vec::new();
@ -594,6 +596,13 @@ where
.. ..
} = func_def; } = func_def;
if verbose {
self.event_listener.handle_event(Event::GeneratingUPLCFor {
name: name.clone(),
path: input_path.clone(),
})
}
let mut generator = CodeGenerator::new( let mut generator = CodeGenerator::new(
&functions, &functions,
// &type_aliases, // &type_aliases,

View File

@ -24,6 +24,10 @@ pub enum Event {
GeneratingUPLC { GeneratingUPLC {
output_path: PathBuf, output_path: PathBuf,
}, },
GeneratingUPLCFor {
name: String,
path: PathBuf,
},
EvaluatingFunction { EvaluatingFunction {
results: Vec<EvalInfo>, results: Vec<EvalInfo>,
}, },