simulator should delete files after a successful run

This commit is contained in:
pedrocarlo
2025-08-09 16:01:32 -03:00
parent 54613cceec
commit 0c9ecbc768
4 changed files with 15 additions and 5 deletions

1
.gitignore vendored
View File

@@ -39,3 +39,4 @@ limbostress.log
simulator.log
**/*.txt
profile.json.gz
simulator-output/

View File

@@ -136,6 +136,10 @@ fn testing_main(cli_opts: &SimulatorCLI) -> anyhow::Result<()> {
println!("seed: {seed}");
println!("path: {}", paths.base.display());
if result.is_ok() {
paths.delete_all_files();
}
result
}

View File

@@ -439,11 +439,6 @@ impl BugBase {
&self.path
}
/// Get the path to the database file for a given seed.
pub(crate) fn db_path(&self, seed: u64) -> PathBuf {
self.path.join(format!("{seed}/test.db"))
}
/// Get paths to all the files for a given seed.
pub(crate) fn paths(&self, seed: u64) -> Paths {
let base = self.path.join(format!("{seed}/"));

View File

@@ -124,6 +124,7 @@ impl SimulatorEnv {
) {
Ok(db) => db,
Err(e) => {
tracing::error!(%e);
panic!("error opening simulator test file {db_path:?}: {e:?}");
}
};
@@ -464,4 +465,13 @@ impl Paths {
pub(crate) fn plan(&self, type_: &SimulationType, phase: &SimulationPhase) -> PathBuf {
self.path_(type_, phase).with_extension("sql")
}
pub fn delete_all_files(&self) {
if self.base.exists() {
let res = std::fs::remove_dir_all(&self.base);
if res.is_err() {
tracing::error!(error = %res.unwrap_err(),"failed to remove directory");
}
}
}
}