Remove debug line for pretty-printing test, and add '--debug' flag to 'check instead.
This commit is contained in:
parent
e5972640d2
commit
5024bd884c
|
@ -11,6 +11,10 @@ pub struct Args {
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
skip_tests: bool,
|
skip_tests: bool,
|
||||||
|
|
||||||
|
/// When enabled, also pretty-print test UPLC on failure
|
||||||
|
#[clap(long)]
|
||||||
|
debug: bool,
|
||||||
|
|
||||||
/// Only run tests if their path + name match the given string
|
/// Only run tests if their path + name match the given string
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
match_tests: Option<String>,
|
match_tests: Option<String>,
|
||||||
|
@ -20,8 +24,11 @@ pub fn exec(
|
||||||
Args {
|
Args {
|
||||||
directory,
|
directory,
|
||||||
skip_tests,
|
skip_tests,
|
||||||
|
debug,
|
||||||
match_tests,
|
match_tests,
|
||||||
}: Args,
|
}: Args,
|
||||||
) -> miette::Result<()> {
|
) -> miette::Result<()> {
|
||||||
crate::with_project(directory, |p| p.check(skip_tests, match_tests.clone()))
|
crate::with_project(directory, |p| {
|
||||||
|
p.check(skip_tests, match_tests.clone(), debug)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ use std::sync::{
|
||||||
|
|
||||||
pub mod air;
|
pub mod air;
|
||||||
pub mod ast;
|
pub mod ast;
|
||||||
|
pub mod builder;
|
||||||
pub mod builtins;
|
pub mod builtins;
|
||||||
pub mod expr;
|
pub mod expr;
|
||||||
pub mod format;
|
pub mod format;
|
||||||
|
@ -12,7 +13,6 @@ pub mod parser;
|
||||||
pub mod pretty;
|
pub mod pretty;
|
||||||
pub mod tipo;
|
pub mod tipo;
|
||||||
pub mod uplc;
|
pub mod uplc;
|
||||||
pub mod builder;
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct IdGenerator {
|
pub struct IdGenerator {
|
||||||
|
|
|
@ -79,10 +79,12 @@ pub enum Error {
|
||||||
named: NamedSource,
|
named: NamedSource,
|
||||||
},
|
},
|
||||||
|
|
||||||
#[error("{} failed", name)]
|
#[error("{name} failed{}", if *verbose { format!("\n{src}") } else { String::new() } )]
|
||||||
TestFailure {
|
TestFailure {
|
||||||
name: String,
|
name: String,
|
||||||
path: PathBuf,
|
path: PathBuf,
|
||||||
|
verbose: bool,
|
||||||
|
src: String,
|
||||||
evaluation_hint: Option<EvalHint>,
|
evaluation_hint: Option<EvalHint>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,12 +105,20 @@ where
|
||||||
self.compile(options)
|
self.compile(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check(&mut self, skip_tests: bool, match_tests: Option<String>) -> Result<(), Error> {
|
pub fn check(
|
||||||
|
&mut self,
|
||||||
|
skip_tests: bool,
|
||||||
|
match_tests: Option<String>,
|
||||||
|
verbose: bool,
|
||||||
|
) -> Result<(), Error> {
|
||||||
let options = Options {
|
let options = Options {
|
||||||
code_gen_mode: if skip_tests {
|
code_gen_mode: if skip_tests {
|
||||||
CodeGenMode::NoOp
|
CodeGenMode::NoOp
|
||||||
} else {
|
} else {
|
||||||
CodeGenMode::Test(match_tests)
|
CodeGenMode::Test {
|
||||||
|
match_tests,
|
||||||
|
verbose,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -148,7 +156,10 @@ where
|
||||||
self.write_build_outputs(programs, uplc_dump)?;
|
self.write_build_outputs(programs, uplc_dump)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
CodeGenMode::Test(match_tests) => {
|
CodeGenMode::Test {
|
||||||
|
match_tests,
|
||||||
|
verbose,
|
||||||
|
} => {
|
||||||
let tests = self
|
let tests = self
|
||||||
.collect_scripts(&checked_modules, |def| matches!(def, Definition::Test(..)))?;
|
.collect_scripts(&checked_modules, |def| matches!(def, Definition::Test(..)))?;
|
||||||
if !tests.is_empty() {
|
if !tests.is_empty() {
|
||||||
|
@ -165,6 +176,8 @@ where
|
||||||
name: e.script.name.clone(),
|
name: e.script.name.clone(),
|
||||||
path: e.script.input_path.clone(),
|
path: e.script.input_path.clone(),
|
||||||
evaluation_hint: e.script.evaluation_hint.clone(),
|
evaluation_hint: e.script.evaluation_hint.clone(),
|
||||||
|
src: e.script.program.to_pretty(),
|
||||||
|
verbose,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -627,8 +640,6 @@ where
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{}", script.program.to_pretty());
|
|
||||||
|
|
||||||
match script.program.eval(initial_budget) {
|
match script.program.eval(initial_budget) {
|
||||||
(Ok(result), remaining_budget, _) => {
|
(Ok(result), remaining_budget, _) => {
|
||||||
let eval_info = EvalInfo {
|
let eval_info = EvalInfo {
|
||||||
|
|
|
@ -3,7 +3,10 @@ pub struct Options {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum CodeGenMode {
|
pub enum CodeGenMode {
|
||||||
Test(Option<String>),
|
Test {
|
||||||
|
match_tests: Option<String>,
|
||||||
|
verbose: bool,
|
||||||
|
},
|
||||||
Build(bool),
|
Build(bool),
|
||||||
NoOp,
|
NoOp,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue