Remove 'eval' command.
Was introduced as a work-around to get some debugging info out of scripts, but tests do now provide the same capability with a better output and, do so automatically.
This commit is contained in:
parent
978a6c6981
commit
e5972640d2
|
@ -1,27 +0,0 @@
|
||||||
use aiken_project::options::{CodeGenMode, Options};
|
|
||||||
use std::path::PathBuf;
|
|
||||||
|
|
||||||
#[derive(clap::Args)]
|
|
||||||
/// Evaluate a chosen function with no argument.
|
|
||||||
pub struct Args {
|
|
||||||
/// Path to project
|
|
||||||
#[clap(short, long)]
|
|
||||||
directory: Option<PathBuf>,
|
|
||||||
|
|
||||||
/// Evaluate the given function
|
|
||||||
#[clap(short, long)]
|
|
||||||
function_name: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn exec(
|
|
||||||
Args {
|
|
||||||
directory,
|
|
||||||
function_name,
|
|
||||||
}: Args,
|
|
||||||
) -> miette::Result<()> {
|
|
||||||
crate::with_project(directory, |p| {
|
|
||||||
p.compile(Options {
|
|
||||||
code_gen_mode: CodeGenMode::Eval(function_name.clone()),
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -1,7 +1,6 @@
|
||||||
pub mod build;
|
pub mod build;
|
||||||
pub mod check;
|
pub mod check;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod eval;
|
|
||||||
pub mod fmt;
|
pub mod fmt;
|
||||||
pub mod lsp;
|
pub mod lsp;
|
||||||
pub mod new;
|
pub mod new;
|
||||||
|
|
|
@ -34,16 +34,15 @@ where
|
||||||
err.report();
|
err.report();
|
||||||
println!("{}", "Summary".purple().bold());
|
println!("{}", "Summary".purple().bold());
|
||||||
println!(
|
println!(
|
||||||
" {}, {}",
|
" {} error(s), {}",
|
||||||
format!("{} error(s)", err.len()),
|
err.len(),
|
||||||
format!("{warning_count} warning(s)").yellow(),
|
format!("{warning_count} warning(s)").yellow(),
|
||||||
);
|
);
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
} else {
|
} else {
|
||||||
println!("{}", "Summary".purple().bold());
|
println!("{}", "Summary".purple().bold());
|
||||||
println!(
|
println!(
|
||||||
" {}, {}",
|
" 0 error, {}",
|
||||||
"0 error",
|
|
||||||
format!("{warning_count} warning(s)").yellow(),
|
format!("{warning_count} warning(s)").yellow(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -162,8 +161,6 @@ fn fmt_test_summary(tests: &Vec<&EvalInfo>, styled: bool) -> String {
|
||||||
(n_passed, n_failed + 1)
|
(n_passed, n_failed + 1)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
format!(
|
|
||||||
"{}",
|
|
||||||
format!(
|
format!(
|
||||||
"{} | {} | {}",
|
"{} | {} | {}",
|
||||||
pretty::style_if(styled, format!("{} tests", tests.len()), |s| s
|
pretty::style_if(styled, format!("{} tests", tests.len()), |s| s
|
||||||
|
@ -178,7 +175,6 @@ fn fmt_test_summary(tests: &Vec<&EvalInfo>, styled: bool) -> String {
|
||||||
.bold()
|
.bold()
|
||||||
.to_string()),
|
.to_string()),
|
||||||
)
|
)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fmt_eval(eval_info: &EvalInfo, max_mem: usize, max_cpu: usize) -> String {
|
fn fmt_eval(eval_info: &EvalInfo, max_mem: usize, max_cpu: usize) -> String {
|
||||||
|
@ -207,9 +203,7 @@ fn fmt_eval(eval_info: &EvalInfo, max_mem: usize, max_cpu: usize) -> String {
|
||||||
fn group_by_module(infos: &Vec<EvalInfo>) -> BTreeMap<String, Vec<&EvalInfo>> {
|
fn group_by_module(infos: &Vec<EvalInfo>) -> BTreeMap<String, Vec<&EvalInfo>> {
|
||||||
let mut modules = BTreeMap::new();
|
let mut modules = BTreeMap::new();
|
||||||
for eval_info in infos {
|
for eval_info in infos {
|
||||||
let xs = modules
|
let xs: &mut Vec<&EvalInfo> = modules.entry(eval_info.script.module.clone()).or_default();
|
||||||
.entry(eval_info.script.module.clone())
|
|
||||||
.or_insert(vec![]);
|
|
||||||
xs.push(eval_info);
|
xs.push(eval_info);
|
||||||
}
|
}
|
||||||
modules
|
modules
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use aiken::cmd::{build, check, eval, fmt, lsp, new, tx, uplc};
|
use aiken::cmd::{build, check, fmt, lsp, new, tx, uplc};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
/// Aiken: a smart-contract language and toolchain for Cardano
|
/// Aiken: a smart-contract language and toolchain for Cardano
|
||||||
|
@ -11,7 +11,6 @@ pub enum Cmd {
|
||||||
Fmt(fmt::Args),
|
Fmt(fmt::Args),
|
||||||
Build(build::Args),
|
Build(build::Args),
|
||||||
Check(check::Args),
|
Check(check::Args),
|
||||||
Eval(eval::Args),
|
|
||||||
|
|
||||||
#[clap(hide = true)]
|
#[clap(hide = true)]
|
||||||
Lsp(lsp::Args),
|
Lsp(lsp::Args),
|
||||||
|
@ -36,7 +35,6 @@ fn main() -> miette::Result<()> {
|
||||||
Cmd::Fmt(args) => fmt::exec(args),
|
Cmd::Fmt(args) => fmt::exec(args),
|
||||||
Cmd::Build(args) => build::exec(args),
|
Cmd::Build(args) => build::exec(args),
|
||||||
Cmd::Check(args) => check::exec(args),
|
Cmd::Check(args) => check::exec(args),
|
||||||
Cmd::Eval(args) => eval::exec(args),
|
|
||||||
Cmd::Lsp(args) => lsp::exec(args),
|
Cmd::Lsp(args) => lsp::exec(args),
|
||||||
Cmd::Tx(sub_cmd) => tx::exec(sub_cmd),
|
Cmd::Tx(sub_cmd) => tx::exec(sub_cmd),
|
||||||
Cmd::Uplc(sub_cmd) => uplc::exec(sub_cmd),
|
Cmd::Uplc(sub_cmd) => uplc::exec(sub_cmd),
|
||||||
|
|
|
@ -94,7 +94,7 @@ impl TypedFunction {
|
||||||
left,
|
left,
|
||||||
right,
|
right,
|
||||||
..
|
..
|
||||||
} if tipo == &bool() => Some((name.clone(), left.clone(), right.clone())),
|
} if tipo == &bool() => Some((*name, left.clone(), right.clone())),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,14 +178,6 @@ where
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CodeGenMode::Eval(func_name) => {
|
|
||||||
let scripts = self
|
|
||||||
.collect_scripts(&checked_modules, |def| matches!(def, Definition::Fn(..)))?;
|
|
||||||
let results = self.eval_scripts(scripts, Some(func_name));
|
|
||||||
self.event_listener
|
|
||||||
.handle_event(Event::EvaluatingFunction { results });
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
CodeGenMode::NoOp => Ok(()),
|
CodeGenMode::NoOp => Ok(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ pub struct Options {
|
||||||
|
|
||||||
pub enum CodeGenMode {
|
pub enum CodeGenMode {
|
||||||
Test(Option<String>),
|
Test(Option<String>),
|
||||||
Eval(String),
|
|
||||||
Build(bool),
|
Build(bool),
|
||||||
NoOp,
|
NoOp,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue