Added target awareness and fixed property based test json output
This commit is contained in:
parent
d1a1d0ec01
commit
1a75568027
|
@ -591,10 +591,22 @@ fn fmt_overall_summary_json(tests: &[TestResult<UntypedExpr, UntypedExpr>]) -> s
|
||||||
|
|
||||||
let (max_mem, max_cpu, max_iter) = find_max_execution_units(tests);
|
let (max_mem, max_cpu, max_iter) = find_max_execution_units(tests);
|
||||||
|
|
||||||
|
// Separate counts for unit tests and property-based tests
|
||||||
|
let unit_tests = tests
|
||||||
|
.iter()
|
||||||
|
.filter(|t| matches!(t, TestResult::UnitTestResult { .. }))
|
||||||
|
.count();
|
||||||
|
let property_tests = tests
|
||||||
|
.iter()
|
||||||
|
.filter(|t| matches!(t, TestResult::PropertyTestResult { .. }))
|
||||||
|
.count();
|
||||||
|
|
||||||
json!({
|
json!({
|
||||||
"total_tests": total,
|
"total_tests": total,
|
||||||
"passed_tests": passed,
|
"passed_tests": passed,
|
||||||
"failed_tests": failed,
|
"failed_tests": failed,
|
||||||
|
"unit_tests": unit_tests,
|
||||||
|
"property_tests": property_tests,
|
||||||
"module_count": module_count,
|
"module_count": module_count,
|
||||||
"max_execution_units": {
|
"max_execution_units": {
|
||||||
"memory": max_mem,
|
"memory": max_mem,
|
||||||
|
@ -605,7 +617,7 @@ fn fmt_overall_summary_json(tests: &[TestResult<UntypedExpr, UntypedExpr>]) -> s
|
||||||
json!({
|
json!({
|
||||||
"name": module,
|
"name": module,
|
||||||
"tests": results.iter().map(|r| fmt_test_json(r)).collect::<Vec<_>>(),
|
"tests": results.iter().map(|r| fmt_test_json(r)).collect::<Vec<_>>(),
|
||||||
"summary": fmt_test_summary_json(&results),
|
"summary": fmt_test_summary_json(&results)
|
||||||
})
|
})
|
||||||
}).collect::<Vec<_>>(),
|
}).collect::<Vec<_>>(),
|
||||||
})
|
})
|
||||||
|
|
|
@ -5,7 +5,11 @@ use aiken_lang::{
|
||||||
};
|
};
|
||||||
use aiken_project::watch::{self, watch_project, with_project};
|
use aiken_project::watch::{self, watch_project, with_project};
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use std::{path::PathBuf, process};
|
use std::{
|
||||||
|
io::{self, IsTerminal},
|
||||||
|
path::PathBuf,
|
||||||
|
process,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(clap::Args)]
|
#[derive(clap::Args)]
|
||||||
/// Type-check an Aiken project
|
/// Type-check an Aiken project
|
||||||
|
@ -84,10 +88,6 @@ pub struct Args {
|
||||||
/// [optional]
|
/// [optional]
|
||||||
#[clap(short, long, value_parser=trace_level_parser(), default_value_t=TraceLevel::Verbose, verbatim_doc_comment)]
|
#[clap(short, long, value_parser=trace_level_parser(), default_value_t=TraceLevel::Verbose, verbatim_doc_comment)]
|
||||||
trace_level: TraceLevel,
|
trace_level: TraceLevel,
|
||||||
|
|
||||||
/// Output JSON (useful for scripting & automation)
|
|
||||||
#[clap(long)]
|
|
||||||
json: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(
|
pub fn exec(
|
||||||
|
@ -104,13 +104,14 @@ pub fn exec(
|
||||||
seed,
|
seed,
|
||||||
max_success,
|
max_success,
|
||||||
env,
|
env,
|
||||||
json,
|
|
||||||
}: Args,
|
}: Args,
|
||||||
) -> miette::Result<()> {
|
) -> miette::Result<()> {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
|
|
||||||
let seed = seed.unwrap_or_else(|| rng.gen());
|
let seed = seed.unwrap_or_else(|| rng.gen());
|
||||||
|
|
||||||
|
let json_output = !io::stdout().is_terminal();
|
||||||
|
|
||||||
let result = if watch {
|
let result = if watch {
|
||||||
watch_project(directory.as_deref(), watch::default_filter, 500, |p| {
|
watch_project(directory.as_deref(), watch::default_filter, 500, |p| {
|
||||||
p.check(
|
p.check(
|
||||||
|
@ -125,26 +126,31 @@ pub fn exec(
|
||||||
None => Tracing::All(trace_level),
|
None => Tracing::All(trace_level),
|
||||||
},
|
},
|
||||||
env.clone(),
|
env.clone(),
|
||||||
json,
|
json_output,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
with_project(directory.as_deref(), deny, json, |p| {
|
with_project(
|
||||||
p.check(
|
directory.as_deref(),
|
||||||
skip_tests,
|
deny,
|
||||||
match_tests.clone(),
|
!io::stdout().is_terminal(),
|
||||||
debug,
|
|p| {
|
||||||
exact_match,
|
p.check(
|
||||||
seed,
|
skip_tests,
|
||||||
max_success,
|
match_tests.clone(),
|
||||||
match trace_filter {
|
debug,
|
||||||
Some(trace_filter) => trace_filter(trace_level),
|
exact_match,
|
||||||
None => Tracing::All(trace_level),
|
seed,
|
||||||
},
|
max_success,
|
||||||
env.clone(),
|
match trace_filter {
|
||||||
json,
|
Some(trace_filter) => trace_filter(trace_level),
|
||||||
)
|
None => Tracing::All(trace_level),
|
||||||
})
|
},
|
||||||
|
env.clone(),
|
||||||
|
json_output,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
result.map_err(|_| process::exit(1))
|
result.map_err(|_| process::exit(1))
|
||||||
|
|
Loading…
Reference in New Issue