Formatting

This commit is contained in:
Riley-Kilgore 2024-11-26 10:52:46 -08:00 committed by Riley
parent 9a3513b245
commit 8764d37d76
6 changed files with 58 additions and 41 deletions

View File

@ -193,11 +193,7 @@ impl Error {
test.input_path.to_path_buf(),
test.program.to_pretty(),
),
TestResult::Benchmark(_) => (
"benchmark".to_string(),
PathBuf::new(),
String::new(),
),
TestResult::Benchmark(_) => ("benchmark".to_string(), PathBuf::new(), String::new()),
};
Error::TestFailure {

View File

@ -61,7 +61,7 @@ use std::{
use telemetry::EventListener;
use uplc::{
ast::{Constant, Name, Program},
PlutusData
PlutusData,
};
#[derive(Debug)]
@ -418,7 +418,7 @@ where
path: options.blueprint_path,
}
})?;
Ok(())
}
CodeGenMode::Test {
@ -428,8 +428,7 @@ where
seed,
property_max_success,
} => {
let tests =
self.collect_tests(false, match_tests, exact_match, options.tracing)?;
let tests = self.collect_tests(false, match_tests, exact_match, options.tracing)?;
if !tests.is_empty() {
self.event_listener.handle_event(Event::RunningTests);
@ -475,8 +474,7 @@ where
property_max_success,
output,
} => {
let tests =
self.collect_tests(false, match_tests, exact_match, options.tracing)?;
let tests = self.collect_tests(false, match_tests, exact_match, options.tracing)?;
if !tests.is_empty() {
self.event_listener.handle_event(Event::RunningTests);
@ -506,8 +504,10 @@ where
})
.collect();
self.event_listener
.handle_event(Event::FinishedBenchmarks { seed, tests: tests.clone() });
self.event_listener.handle_event(Event::FinishedBenchmarks {
seed,
tests: tests.clone(),
});
if !errors.is_empty() {
Err(errors)
@ -516,12 +516,20 @@ where
use std::fs::File;
use std::io::Write;
let mut writer = File::create(&output)
.map_err(|error| vec![Error::FileIo { error, path: output.clone() }])?;
let mut writer = File::create(&output).map_err(|error| {
vec![Error::FileIo {
error,
path: output.clone(),
}]
})?;
// Write CSV header
writeln!(writer, "test_name,module,memory,cpu")
.map_err(|error| vec![Error::FileIo { error, path: output.clone() }])?;
writeln!(writer, "test_name,module,memory,cpu").map_err(|error| {
vec![Error::FileIo {
error,
path: output.clone(),
}]
})?;
// Write benchmark results
for test in tests {
@ -533,7 +541,13 @@ where
result.test.module,
result.cost.mem,
result.cost.cpu
).map_err(|error| vec![Error::FileIo { error, path: output.clone() }])?;
)
.map_err(|error| {
vec![Error::FileIo {
error,
path: output.clone(),
}]
})?;
}
}
@ -1133,13 +1147,11 @@ where
.into_par_iter()
.flat_map(|test| match test {
Test::UnitTest(_) => Vec::new(),
Test::PropertyTest(property_test) => {
property_test
.benchmark(seed, property_max_success, plutus_version)
.into_iter()
.map(|result| TestResult::Benchmark(result))
.collect::<Vec<_>>()
}
Test::PropertyTest(property_test) => property_test
.benchmark(seed, property_max_success, plutus_version)
.into_iter()
.map(|result| TestResult::Benchmark(result))
.collect::<Vec<_>>(),
})
.collect::<Vec<TestResult<(Constant, Rc<Type>), PlutusData>>>()
.into_iter()

View File

@ -145,4 +145,4 @@ pub(crate) fn find_max_execution_units<T>(xs: &[TestResult<T, T>]) -> (usize, us
max_cpu.to_string().len(),
max_iter.to_string().len(),
)
}
}

View File

@ -272,4 +272,4 @@ pub fn json_schema() -> serde_json::Value {
"definitions": definitions
}
})
}
}

View File

@ -469,4 +469,4 @@ fn fmt_test_summary<T>(tests: &[&TestResult<T, T>], styled: bool) -> String {
.if_supports_color(Stderr, |s| s.bold())
.to_string()),
)
}
}

View File

@ -1,7 +1,11 @@
use aiken_lang::test_framework::PropertyTest;
use aiken_project::watch::with_project;
use rand::prelude::*;
use std::{io::{self, IsTerminal},path::PathBuf, process};
use std::{
io::{self, IsTerminal},
path::PathBuf,
process,
};
#[derive(clap::Args)]
/// Type-check an Aiken project
@ -52,16 +56,21 @@ pub fn exec(
let seed = seed.unwrap_or_else(|| rng.gen());
let result = with_project(directory.as_deref(), false, !io::stdout().is_terminal(), |p| {
// We don't want to check here, we want to benchmark
p.benchmark(
match_tests.clone(),
exact_match,
seed,
max_success,
env.clone(),
output.clone(),
)
});
let result = with_project(
directory.as_deref(),
false,
!io::stdout().is_terminal(),
|p| {
// We don't want to check here, we want to benchmark
p.benchmark(
match_tests.clone(),
exact_match,
seed,
max_success,
env.clone(),
output.clone(),
)
},
);
result.map_err(|_| process::exit(1))
}
}