fixup aesthetics
Signed-off-by: KtorZ <5680256+KtorZ@users.noreply.github.com>
This commit is contained in:
parent
2a1253cb52
commit
37f721ff06
|
@ -523,7 +523,7 @@ impl Benchmark {
|
|||
prng = new_prng;
|
||||
let mut eval_result = self.eval(&value, plutus_version);
|
||||
results.push(BenchmarkResult {
|
||||
test: self.clone(),
|
||||
bench: self.clone(),
|
||||
cost: eval_result.cost(),
|
||||
success: true,
|
||||
traces: eval_result.logs().to_vec(),
|
||||
|
@ -536,7 +536,7 @@ impl Benchmark {
|
|||
|
||||
Err(e) => {
|
||||
results.push(BenchmarkResult {
|
||||
test: self.clone(),
|
||||
bench: self.clone(),
|
||||
cost: ExBudget::default(),
|
||||
success: false,
|
||||
traces: vec![e.to_string()],
|
||||
|
@ -1068,7 +1068,7 @@ where
|
|||
pub enum TestResult<U, T> {
|
||||
UnitTestResult(UnitTestResult<U>),
|
||||
PropertyTestResult(PropertyTestResult<T>),
|
||||
Benchmark(BenchmarkResult),
|
||||
BenchmarkResult(BenchmarkResult),
|
||||
}
|
||||
|
||||
unsafe impl<U, T> Send for TestResult<U, T> {}
|
||||
|
@ -1083,7 +1083,7 @@ impl TestResult<(Constant, Rc<Type>), PlutusData> {
|
|||
TestResult::PropertyTestResult(test) => {
|
||||
TestResult::PropertyTestResult(test.reify(data_types))
|
||||
}
|
||||
TestResult::Benchmark(result) => TestResult::Benchmark(result),
|
||||
TestResult::BenchmarkResult(result) => TestResult::BenchmarkResult(result),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1106,7 +1106,7 @@ impl<U, T> TestResult<U, T> {
|
|||
}
|
||||
OnTestFailure::SucceedImmediately => counterexample.is_some(),
|
||||
},
|
||||
TestResult::Benchmark(BenchmarkResult { success, .. }) => *success,
|
||||
TestResult::BenchmarkResult(BenchmarkResult { success, .. }) => *success,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1116,7 +1116,7 @@ impl<U, T> TestResult<U, T> {
|
|||
TestResult::PropertyTestResult(PropertyTestResult { ref test, .. }) => {
|
||||
test.module.as_str()
|
||||
}
|
||||
TestResult::Benchmark(BenchmarkResult { ref test, .. }) => test.module.as_str(),
|
||||
TestResult::BenchmarkResult(BenchmarkResult { ref bench, .. }) => bench.module.as_str(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1126,7 +1126,7 @@ impl<U, T> TestResult<U, T> {
|
|||
TestResult::PropertyTestResult(PropertyTestResult { ref test, .. }) => {
|
||||
test.name.as_str()
|
||||
}
|
||||
TestResult::Benchmark(BenchmarkResult { ref test, .. }) => test.name.as_str(),
|
||||
TestResult::BenchmarkResult(BenchmarkResult { ref bench, .. }) => bench.name.as_str(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1134,7 +1134,7 @@ impl<U, T> TestResult<U, T> {
|
|||
match self {
|
||||
TestResult::UnitTestResult(UnitTestResult { traces, .. })
|
||||
| TestResult::PropertyTestResult(PropertyTestResult { traces, .. })
|
||||
| TestResult::Benchmark(BenchmarkResult { traces, .. }) => traces,
|
||||
| TestResult::BenchmarkResult(BenchmarkResult { traces, .. }) => traces,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1472,7 +1472,7 @@ impl Assertion<UntypedExpr> {
|
|||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct BenchmarkResult {
|
||||
pub test: Benchmark,
|
||||
pub bench: Benchmark,
|
||||
pub cost: ExBudget,
|
||||
pub success: bool,
|
||||
pub traces: Vec<String>,
|
||||
|
|
|
@ -193,7 +193,7 @@ impl Error {
|
|||
test.input_path.to_path_buf(),
|
||||
test.program.to_pretty(),
|
||||
),
|
||||
TestResult::Benchmark(_) => ("bench".to_string(), PathBuf::new(), String::new()), // todo
|
||||
TestResult::BenchmarkResult(_) => ("bench".to_string(), PathBuf::new(), String::new()), // todo
|
||||
};
|
||||
|
||||
Error::TestFailure {
|
||||
|
|
|
@ -1135,7 +1135,7 @@ where
|
|||
Test::Benchmark(benchmark) => benchmark
|
||||
.benchmark(seed, property_max_success, plutus_version)
|
||||
.into_iter()
|
||||
.map(TestResult::Benchmark)
|
||||
.map(TestResult::BenchmarkResult)
|
||||
.collect::<Vec<_>>(),
|
||||
})
|
||||
.collect::<Vec<TestResult<(Constant, Rc<Type>), PlutusData>>>()
|
||||
|
|
|
@ -134,7 +134,7 @@ pub(crate) fn find_max_execution_units<T>(xs: &[TestResult<T, T>]) -> (usize, us
|
|||
(max_mem, max_cpu, max_iter)
|
||||
}
|
||||
}
|
||||
TestResult::Benchmark(..) => {
|
||||
TestResult::BenchmarkResult(..) => {
|
||||
unreachable!("property returned benchmark result ?!")
|
||||
}
|
||||
});
|
||||
|
|
|
@ -43,10 +43,10 @@ impl EventListener for Json {
|
|||
let benchmark_results: Vec<_> = tests
|
||||
.into_iter()
|
||||
.filter_map(|test| {
|
||||
if let TestResult::Benchmark(result) = test {
|
||||
if let TestResult::BenchmarkResult(result) = test {
|
||||
Some(serde_json::json!({
|
||||
"name": result.test.name,
|
||||
"module": result.test.module,
|
||||
"name": result.bench.name,
|
||||
"module": result.bench.module,
|
||||
"memory": result.cost.mem,
|
||||
"cpu": result.cost.cpu
|
||||
}))
|
||||
|
@ -74,7 +74,7 @@ fn fmt_test_json(result: &TestResult<UntypedExpr, UntypedExpr>) -> serde_json::V
|
|||
TestResult::PropertyTestResult(PropertyTestResult { ref test, .. }) => {
|
||||
&test.on_test_failure
|
||||
}
|
||||
TestResult::Benchmark(_) => unreachable!("benchmark returned in JSON output"),
|
||||
TestResult::BenchmarkResult(_) => unreachable!("benchmark returned in JSON output"),
|
||||
};
|
||||
|
||||
let mut test = json!({
|
||||
|
@ -120,7 +120,7 @@ fn fmt_test_json(result: &TestResult<UntypedExpr, UntypedExpr>) -> serde_json::V
|
|||
Err(err) => json!({"error": err.to_string()}),
|
||||
};
|
||||
}
|
||||
TestResult::Benchmark(_) => unreachable!("benchmark returned in JSON output"),
|
||||
TestResult::BenchmarkResult(_) => unreachable!("benchmark returned in JSON output"),
|
||||
}
|
||||
|
||||
if !result.traces().is_empty() {
|
||||
|
|
|
@ -226,8 +226,8 @@ impl EventListener for Terminal {
|
|||
}
|
||||
Event::FinishedBenchmarks { tests, .. } => {
|
||||
for test in tests {
|
||||
if let TestResult::Benchmark(result) = test {
|
||||
println!("{} {} ", result.test.name.bold(), "BENCH".blue(),);
|
||||
if let TestResult::BenchmarkResult(result) = test {
|
||||
println!("{} {} ", result.bench.name.bold(), "BENCH".blue(),);
|
||||
println!(" Memory: {} bytes", result.cost.mem);
|
||||
println!(" CPU: {} units", result.cost.cpu);
|
||||
println!();
|
||||
|
@ -292,7 +292,7 @@ fn fmt_test(
|
|||
if *iterations > 1 { "s" } else { "" }
|
||||
);
|
||||
}
|
||||
TestResult::Benchmark(benchmark) => {
|
||||
TestResult::BenchmarkResult(benchmark) => {
|
||||
let mem_pad = pretty::pad_left(benchmark.cost.mem.to_string(), max_mem, " ");
|
||||
let cpu_pad = pretty::pad_left(benchmark.cost.cpu.to_string(), max_cpu, " ");
|
||||
|
||||
|
|
|
@ -278,7 +278,9 @@ mod test {
|
|||
PropertyTest::DEFAULT_MAX_SUCCESS,
|
||||
&PlutusVersion::default(),
|
||||
) {
|
||||
TestResult::UnitTestResult(..) => unreachable!("property returned unit-test result ?!"),
|
||||
TestResult::BenchmarkResult(..) | TestResult::UnitTestResult(..) => {
|
||||
unreachable!("property returned non-property result ?!")
|
||||
}
|
||||
TestResult::PropertyTestResult(result) => {
|
||||
assert!(
|
||||
result
|
||||
|
@ -289,7 +291,6 @@ mod test {
|
|||
result.labels
|
||||
)
|
||||
}
|
||||
TestResult::Benchmark(..) => unreachable!("property returned benchmark result ?!"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue