Formatting
This commit is contained in:
parent
9a3513b245
commit
8764d37d76
|
@ -193,11 +193,7 @@ impl Error {
|
||||||
test.input_path.to_path_buf(),
|
test.input_path.to_path_buf(),
|
||||||
test.program.to_pretty(),
|
test.program.to_pretty(),
|
||||||
),
|
),
|
||||||
TestResult::Benchmark(_) => (
|
TestResult::Benchmark(_) => ("benchmark".to_string(), PathBuf::new(), String::new()),
|
||||||
"benchmark".to_string(),
|
|
||||||
PathBuf::new(),
|
|
||||||
String::new(),
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Error::TestFailure {
|
Error::TestFailure {
|
||||||
|
|
|
@ -61,7 +61,7 @@ use std::{
|
||||||
use telemetry::EventListener;
|
use telemetry::EventListener;
|
||||||
use uplc::{
|
use uplc::{
|
||||||
ast::{Constant, Name, Program},
|
ast::{Constant, Name, Program},
|
||||||
PlutusData
|
PlutusData,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -428,8 +428,7 @@ where
|
||||||
seed,
|
seed,
|
||||||
property_max_success,
|
property_max_success,
|
||||||
} => {
|
} => {
|
||||||
let tests =
|
let tests = self.collect_tests(false, match_tests, exact_match, options.tracing)?;
|
||||||
self.collect_tests(false, 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);
|
||||||
|
@ -475,8 +474,7 @@ where
|
||||||
property_max_success,
|
property_max_success,
|
||||||
output,
|
output,
|
||||||
} => {
|
} => {
|
||||||
let tests =
|
let tests = self.collect_tests(false, match_tests, exact_match, options.tracing)?;
|
||||||
self.collect_tests(false, 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);
|
||||||
|
@ -506,8 +504,10 @@ where
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
self.event_listener
|
self.event_listener.handle_event(Event::FinishedBenchmarks {
|
||||||
.handle_event(Event::FinishedBenchmarks { seed, tests: tests.clone() });
|
seed,
|
||||||
|
tests: tests.clone(),
|
||||||
|
});
|
||||||
|
|
||||||
if !errors.is_empty() {
|
if !errors.is_empty() {
|
||||||
Err(errors)
|
Err(errors)
|
||||||
|
@ -516,12 +516,20 @@ where
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
let mut writer = File::create(&output)
|
let mut writer = File::create(&output).map_err(|error| {
|
||||||
.map_err(|error| vec![Error::FileIo { error, path: output.clone() }])?;
|
vec![Error::FileIo {
|
||||||
|
error,
|
||||||
|
path: output.clone(),
|
||||||
|
}]
|
||||||
|
})?;
|
||||||
|
|
||||||
// Write CSV header
|
// Write CSV header
|
||||||
writeln!(writer, "test_name,module,memory,cpu")
|
writeln!(writer, "test_name,module,memory,cpu").map_err(|error| {
|
||||||
.map_err(|error| vec![Error::FileIo { error, path: output.clone() }])?;
|
vec![Error::FileIo {
|
||||||
|
error,
|
||||||
|
path: output.clone(),
|
||||||
|
}]
|
||||||
|
})?;
|
||||||
|
|
||||||
// Write benchmark results
|
// Write benchmark results
|
||||||
for test in tests {
|
for test in tests {
|
||||||
|
@ -533,7 +541,13 @@ where
|
||||||
result.test.module,
|
result.test.module,
|
||||||
result.cost.mem,
|
result.cost.mem,
|
||||||
result.cost.cpu
|
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()
|
.into_par_iter()
|
||||||
.flat_map(|test| match test {
|
.flat_map(|test| match test {
|
||||||
Test::UnitTest(_) => Vec::new(),
|
Test::UnitTest(_) => Vec::new(),
|
||||||
Test::PropertyTest(property_test) => {
|
Test::PropertyTest(property_test) => property_test
|
||||||
property_test
|
.benchmark(seed, property_max_success, plutus_version)
|
||||||
.benchmark(seed, property_max_success, plutus_version)
|
.into_iter()
|
||||||
.into_iter()
|
.map(|result| TestResult::Benchmark(result))
|
||||||
.map(|result| TestResult::Benchmark(result))
|
.collect::<Vec<_>>(),
|
||||||
.collect::<Vec<_>>()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<TestResult<(Constant, Rc<Type>), PlutusData>>>()
|
.collect::<Vec<TestResult<(Constant, Rc<Type>), PlutusData>>>()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
use aiken_lang::test_framework::PropertyTest;
|
use aiken_lang::test_framework::PropertyTest;
|
||||||
use aiken_project::watch::with_project;
|
use aiken_project::watch::with_project;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use std::{io::{self, IsTerminal},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
|
||||||
|
@ -52,16 +56,21 @@ pub fn exec(
|
||||||
|
|
||||||
let seed = seed.unwrap_or_else(|| rng.gen());
|
let seed = seed.unwrap_or_else(|| rng.gen());
|
||||||
|
|
||||||
let result = with_project(directory.as_deref(), false, !io::stdout().is_terminal(), |p| {
|
let result = with_project(
|
||||||
// We don't want to check here, we want to benchmark
|
directory.as_deref(),
|
||||||
p.benchmark(
|
false,
|
||||||
match_tests.clone(),
|
!io::stdout().is_terminal(),
|
||||||
exact_match,
|
|p| {
|
||||||
seed,
|
// We don't want to check here, we want to benchmark
|
||||||
max_success,
|
p.benchmark(
|
||||||
env.clone(),
|
match_tests.clone(),
|
||||||
output.clone(),
|
exact_match,
|
||||||
)
|
seed,
|
||||||
});
|
max_success,
|
||||||
|
env.clone(),
|
||||||
|
output.clone(),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
);
|
||||||
result.map_err(|_| process::exit(1))
|
result.map_err(|_| process::exit(1))
|
||||||
}
|
}
|
Loading…
Reference in New Issue