From c95469b5e170397469f2f0b1bba8dafa5f8bfdc2 Mon Sep 17 00:00:00 2001 From: Romain Ruetschi Date: Tue, 5 Dec 2023 09:38:22 +0100 Subject: [PATCH] More refactoring --- Code/itf/src/utils.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Code/itf/src/utils.rs b/Code/itf/src/utils.rs index 8364ad56f..78f6b1124 100644 --- a/Code/itf/src/utils.rs +++ b/Code/itf/src/utils.rs @@ -38,7 +38,7 @@ impl TraceGenerator { cmd.arg(self.spec_path.as_os_str()); - println!("Generating traces..."); + println!("Generating traces from '{}'...", self.spec_path.display()); cmd.current_dir(self.spec_path.parent().unwrap()) .output() @@ -47,15 +47,16 @@ impl TraceGenerator { /// Remove traces from imported modules fn remove_imported_traces(&self) { - for redundant_itf in glob(&format!( + let redundant_itfs = glob(&format!( "{}/*{}::*.*", self.gen_dir.display(), - self.spec_path.file_stem().unwrap().to_str().unwrap() + self.spec_path.file_stem().and_then(|s| s.to_str()).unwrap() )) .expect("Failed to read glob pattern") - .flatten() - { - std::fs::remove_file(&redundant_itf).unwrap(); + .flatten(); + + for redundant_itf in redundant_itfs { + std::fs::remove_file(&redundant_itf).expect("Failed to remove redundant ITF file"); } } @@ -159,7 +160,9 @@ impl TraceGeneratorBuilder { pub fn build(self) -> TraceGenerator { let spec_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")) .join("../../Specs/Quint") - .join(self.spec_rel_path); + .join(self.spec_rel_path) + .canonicalize() + .expect("Failed to canonicalize spec path"); TraceGenerator { spec_path,