mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 00:45:37 +01:00
simulator should delete files after a successful run
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -39,3 +39,4 @@ limbostress.log
|
||||
simulator.log
|
||||
**/*.txt
|
||||
profile.json.gz
|
||||
simulator-output/
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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}/"));
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user