Rework tracing arguments to --keep-traces & --trace-level
This allows for a more fine-grained control over how the traces are showed. Now users can instrument the compiler to preserve only their user-defined traces, or the only the compiler, or all, or none. We also want to add another trace level on top of that: 'compact' to only show line numbers; which will work for both user-defined and/or compiler-generated traces.
This commit is contained in:
@@ -22,7 +22,10 @@ use crate::blueprint::{
|
||||
Blueprint,
|
||||
};
|
||||
use aiken_lang::{
|
||||
ast::{Definition, Function, ModuleKind, Tracing, TypedDataType, TypedFunction, Validator},
|
||||
ast::{
|
||||
Definition, Function, ModuleKind, TraceLevel, Tracing, TypedDataType, TypedFunction,
|
||||
Validator,
|
||||
},
|
||||
builtins,
|
||||
gen_uplc::builder::{DataTypeKey, FunctionAccessKey},
|
||||
tipo::TypeInfo,
|
||||
@@ -151,16 +154,10 @@ where
|
||||
self.defined_modules = checkpoint.defined_modules;
|
||||
}
|
||||
|
||||
pub fn build(
|
||||
&mut self,
|
||||
uplc: bool,
|
||||
tracing: Tracing,
|
||||
code_gen_tracing: Tracing,
|
||||
) -> Result<(), Vec<Error>> {
|
||||
pub fn build(&mut self, uplc: bool, tracing: Tracing) -> Result<(), Vec<Error>> {
|
||||
let options = Options {
|
||||
code_gen_mode: CodeGenMode::Build(uplc),
|
||||
tracing,
|
||||
code_gen_tracing,
|
||||
};
|
||||
|
||||
self.compile(options)
|
||||
@@ -182,7 +179,7 @@ where
|
||||
|
||||
let parsed_modules = self.parse_sources(self.config.name.clone())?;
|
||||
|
||||
self.type_check(parsed_modules, Tracing::NoTraces, false)?;
|
||||
self.type_check(parsed_modules, Tracing::silent(), false)?;
|
||||
|
||||
self.event_listener.handle_event(Event::GeneratingDocFiles {
|
||||
output_path: destination.clone(),
|
||||
@@ -216,11 +213,9 @@ where
|
||||
verbose: bool,
|
||||
exact_match: bool,
|
||||
tracing: Tracing,
|
||||
code_gen_tracing: Tracing,
|
||||
) -> Result<(), Vec<Error>> {
|
||||
let options = Options {
|
||||
tracing,
|
||||
code_gen_tracing,
|
||||
code_gen_mode: if skip_tests {
|
||||
CodeGenMode::NoOp
|
||||
} else {
|
||||
@@ -290,7 +285,10 @@ where
|
||||
&self.functions,
|
||||
&self.data_types,
|
||||
&self.module_types,
|
||||
options.code_gen_tracing.into(),
|
||||
match options.tracing.trace_level(true) {
|
||||
TraceLevel::Silent => false,
|
||||
TraceLevel::Verbose => true,
|
||||
},
|
||||
);
|
||||
|
||||
let blueprint = Blueprint::new(&self.config, &self.checked_modules, &mut generator)
|
||||
@@ -323,7 +321,10 @@ where
|
||||
verbose,
|
||||
match_tests,
|
||||
exact_match,
|
||||
options.code_gen_tracing.into(),
|
||||
match options.tracing.trace_level(true) {
|
||||
TraceLevel::Silent => false,
|
||||
TraceLevel::Verbose => true,
|
||||
},
|
||||
)?;
|
||||
|
||||
if !tests.is_empty() {
|
||||
@@ -530,7 +531,7 @@ where
|
||||
|
||||
let parsed_modules = self.parse_sources(package.name)?;
|
||||
|
||||
self.type_check(parsed_modules, Tracing::NoTraces, true)?;
|
||||
self.type_check(parsed_modules, Tracing::silent(), true)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -3,7 +3,6 @@ use aiken_lang::ast::Tracing;
|
||||
pub struct Options {
|
||||
pub code_gen_mode: CodeGenMode,
|
||||
pub tracing: Tracing,
|
||||
pub code_gen_tracing: Tracing,
|
||||
}
|
||||
|
||||
pub enum CodeGenMode {
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use aiken_lang::{
|
||||
ast::{ModuleKind, Tracing, TypedDataType, TypedFunction},
|
||||
ast::{ModuleKind, TraceLevel, Tracing, TypedDataType, TypedFunction},
|
||||
gen_uplc::builder::{DataTypeKey, FunctionAccessKey},
|
||||
parser,
|
||||
tipo::TypeInfo,
|
||||
@@ -81,7 +81,7 @@ impl TestProject {
|
||||
module.kind,
|
||||
&self.package.to_string(),
|
||||
&self.module_types,
|
||||
Tracing::KeepTraces,
|
||||
Tracing::All(TraceLevel::Verbose),
|
||||
&mut warnings,
|
||||
)
|
||||
.expect("Failed to type-check module");
|
||||
|
||||
Reference in New Issue
Block a user