Refactor: Move tester module to utils
This commit is contained in:
@@ -5,4 +5,3 @@ pub mod parser;
|
||||
pub mod compiler;
|
||||
pub mod environment;
|
||||
pub mod vm;
|
||||
pub mod tester;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
use myc::ast::environment::Environment;
|
||||
use myc::ast::tester;
|
||||
use myc::utils::tester;
|
||||
use clap::Parser;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
pub mod ast;
|
||||
pub mod utils;
|
||||
|
||||
#[cfg(test)]
|
||||
mod integration_test;
|
||||
|
||||
+2
-2
@@ -231,7 +231,7 @@ impl CompilerApp {
|
||||
}
|
||||
|
||||
fn run_all_tests(&mut self) {
|
||||
use myc::ast::tester;
|
||||
use myc::utils::tester;
|
||||
let results = tester::run_functional_tests();
|
||||
let mut log = String::from("FUNCTIONAL TEST RESULTS:\n\n");
|
||||
let mut passed = 0;
|
||||
@@ -244,7 +244,7 @@ impl CompilerApp {
|
||||
}
|
||||
|
||||
fn run_benchmarks(&mut self, update: bool) {
|
||||
use myc::ast::tester;
|
||||
use myc::utils::tester;
|
||||
if cfg!(debug_assertions) && !update {
|
||||
self.output_log = String::from("⚠️ WARNING: Benchmarks in Debug mode are inaccurate!\nUse Release build for real measurements.\n\n");
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
pub mod tester;
|
||||
@@ -87,7 +87,8 @@ pub fn run_benchmarks(update: bool) -> Vec<BenchmarkResult> {
|
||||
let updated_content = if let Some(m) = baseline_match {
|
||||
content.replace(m.get(0).unwrap().as_str(), &format!(";; Benchmark: {}", new_val))
|
||||
} else {
|
||||
format!(";; Benchmark: {}\n{}", new_val, content)
|
||||
format!(";; Benchmark: {}
|
||||
{}", new_val, content)
|
||||
};
|
||||
fs::write(&path, updated_content).unwrap();
|
||||
results.push(BenchmarkResult { name, median, baseline: None, diff_pct: None, status: format!("UPDATED: {}", new_val) });
|
||||
@@ -134,11 +135,10 @@ fn parse_duration(s: &str) -> Option<Duration> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
#[cfg(not(debug_assertions))]
|
||||
fn benchmark_regression_test() {
|
||||
use super::*;
|
||||
let mut success = false;
|
||||
let mut last_failures = String::new();
|
||||
|
||||
@@ -157,14 +157,16 @@ mod tests {
|
||||
.map(|r| format!("{}: Median {:?}, Baseline {:?}, Diff {:.2}%",
|
||||
r.name, r.median, r.baseline.unwrap_or_default(), r.diff_pct.unwrap_or(0.0)))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
.join("
|
||||
");
|
||||
|
||||
// Give the system a tiny bit of breath between retries
|
||||
std::thread::sleep(std::time::Duration::from_millis(50));
|
||||
}
|
||||
|
||||
if !success {
|
||||
panic!("Performance regression detected after 5 attempts:\n{}", last_failures);
|
||||
panic!("Performance regression detected after 5 attempts:
|
||||
{}", last_failures);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user