This commit is contained in:
Riley-Kilgore 2025-01-14 05:48:14 -08:00 committed by Riley
parent 3ee74a5ba8
commit 07679b8acc
4 changed files with 10 additions and 17 deletions

View File

@ -8,8 +8,6 @@ pub fn parser() -> impl Parser<Token, ast::UntypedDefinition, Error = ParseError
crate::parser::definition::test_like::parser(Token::Test) crate::parser::definition::test_like::parser(Token::Test)
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::assert_definition; use crate::assert_definition;

View File

@ -36,8 +36,8 @@ pub fn parser(keyword: Token) -> impl Parser<Token, ast::UntypedDefinition, Erro
.or_not() .or_not()
.delimited_by(just(Token::LeftBrace), just(Token::RightBrace)), .delimited_by(just(Token::LeftBrace), just(Token::RightBrace)),
) )
.map_with_span(move |((((name, arguments), fail), span_end), body), span| { .map_with_span(
match keyword { move |((((name, arguments), fail), span_end), body), span| match keyword {
Token::Test => ast::UntypedDefinition::Test(ast::Function { Token::Test => ast::UntypedDefinition::Test(ast::Function {
arguments, arguments,
body: body.unwrap_or_else(|| UntypedExpr::todo(None, span)), body: body.unwrap_or_else(|| UntypedExpr::todo(None, span)),
@ -63,8 +63,8 @@ pub fn parser(keyword: Token) -> impl Parser<Token, ast::UntypedDefinition, Erro
on_test_failure: fail.unwrap_or(OnTestFailure::FailImmediately), on_test_failure: fail.unwrap_or(OnTestFailure::FailImmediately),
}), }),
_ => unreachable!("Only Test and Benchmark tokens are supported"), _ => unreachable!("Only Test and Benchmark tokens are supported"),
} },
}) )
} }
pub fn via() -> impl Parser<Token, ast::UntypedArgVia, Error = ParseError> { pub fn via() -> impl Parser<Token, ast::UntypedArgVia, Error = ParseError> {

View File

@ -425,7 +425,8 @@ where
seed, seed,
property_max_success, property_max_success,
} => { } => {
let tests = self.collect_tests(verbose, match_tests, exact_match, options.tracing)?; let tests =
self.collect_tests(verbose, match_tests, exact_match, options.tracing)?;
if !tests.is_empty() { if !tests.is_empty() {
self.event_listener.handle_event(Event::RunningTests); self.event_listener.handle_event(Event::RunningTests);
@ -490,10 +491,8 @@ where
}) })
.collect(); .collect();
self.event_listener.handle_event(Event::FinishedBenchmarks { self.event_listener
seed, .handle_event(Event::FinishedBenchmarks { seed, tests });
tests,
});
if !errors.is_empty() { if !errors.is_empty() {
Err(errors) Err(errors)

View File

@ -227,11 +227,7 @@ impl EventListener for Terminal {
Event::FinishedBenchmarks { tests, .. } => { Event::FinishedBenchmarks { tests, .. } => {
for test in tests { for test in tests {
if let TestResult::Benchmark(result) = test { if let TestResult::Benchmark(result) = test {
println!( println!("{} {} ", result.test.name.bold(), "BENCH".blue(),);
"{} {} ",
result.test.name.bold(),
"BENCH".blue(),
);
println!(" Memory: {} bytes", result.cost.mem); println!(" Memory: {} bytes", result.cost.mem);
println!(" CPU: {} units", result.cost.cpu); println!(" CPU: {} units", result.cost.cpu);
println!(); println!();