feat: print budget consumed by test
This commit is contained in:
parent
141a9aef30
commit
e9d8e1d317
|
@ -293,7 +293,7 @@ impl Diagnostic for Warning {
|
||||||
|
|
||||||
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
|
fn code<'a>(&'a self) -> Option<Box<dyn Display + 'a>> {
|
||||||
match self {
|
match self {
|
||||||
Warning::Type { .. } => Some(Box::new("aiken::typecheck")),
|
Warning::Type { .. } => Some(Box::new("aiken::check")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,10 @@ use pallas::{
|
||||||
use pallas_traverse::ComputeHash;
|
use pallas_traverse::ComputeHash;
|
||||||
use script::Script;
|
use script::Script;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use uplc::ast::{DeBruijn, Program};
|
use uplc::{
|
||||||
|
ast::{DeBruijn, Program},
|
||||||
|
machine::cost_model::ExBudget,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::Config,
|
config::Config,
|
||||||
|
@ -481,14 +484,31 @@ impl Project {
|
||||||
|
|
||||||
fn run_tests(&self, tests: Vec<Script>) {
|
fn run_tests(&self, tests: Vec<Script>) {
|
||||||
for test in tests {
|
for test in tests {
|
||||||
let result = test.program.eval();
|
// TODO: in the future we probably just want to be able to
|
||||||
|
// tell the machine to not explode on budget consumption.
|
||||||
|
let initial_budget = ExBudget {
|
||||||
|
mem: i64::MAX,
|
||||||
|
cpu: i64::MAX,
|
||||||
|
};
|
||||||
|
|
||||||
|
let result = test.program.eval(initial_budget);
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
(Ok(..), _, _) => {
|
(Ok(..), remaining_budget, _) => {
|
||||||
println!("{}::{} ✓", test.module, test.name);
|
let ExBudget { mem, cpu } = initial_budget - remaining_budget;
|
||||||
|
|
||||||
|
println!(
|
||||||
|
" [PASS] [mem: {}, cpu: {}] {}::{}",
|
||||||
|
mem, cpu, test.module, test.name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
(Err(e), _, _) => {
|
(Err(_), remaining_budget, _) => {
|
||||||
println!("{}::{} x", test.module, test.name);
|
let ExBudget { mem, cpu } = initial_budget - remaining_budget;
|
||||||
println!("{}", e);
|
|
||||||
|
println!(
|
||||||
|
" [FAIL] [mem: {}, cpu: {}] {}::{}",
|
||||||
|
mem, cpu, test.module, test.name
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use sample
|
use sample
|
||||||
|
|
||||||
pub fn spend(datum: sample.Datum, rdmr: sample.Redeemer, _ctx: Nil) -> Bool {
|
pub fn spend(datum: sample.Datum, rdmr: sample.Redeemer, _ctx: Nil) -> Bool {
|
||||||
let x = #(datum, #[244])
|
let _x = #(datum, rdmr, #[244])
|
||||||
|
|
||||||
let y = [#(#[222], #[222]), #(#[233], #[52])]
|
let y = [#(#[222], #[222]), #(#[233], #[52])]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue