Skip to content

Commit

Permalink
Revert "Auto merge of #382 - pietroalbini:clean-target-dir, r=pietroa…
Browse files Browse the repository at this point in the history
…lbini"

This reverts commit fa42afa, reversing
changes made to 48233a2.
  • Loading branch information
pietroalbini committed Jan 3, 2019
1 parent b83e3c7 commit 9bdc4e8
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 131 deletions.
91 changes: 0 additions & 91 deletions src/runner/cleanup.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/runner/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mod cleanup;
mod graph;
mod prepare;
mod tasks;
Expand Down
2 changes: 0 additions & 2 deletions src/runner/test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use super::cleanup;
use crate::docker::{DockerError, MountPerms};
use crate::prelude::*;
use crate::results::{FailureReason, TestResult, WriteResults};
Expand Down Expand Up @@ -93,7 +92,6 @@ pub(super) fn run_test<DB: WriteResults>(
test_fn(ctx, &source_path)
},
)?;
cleanup::clean_target_dirs(&ctx.toolchain.target_dir(&ctx.experiment.name))?;
}
Ok(())
}
Expand Down
37 changes: 0 additions & 37 deletions src/utils/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,40 +61,3 @@ pub(crate) fn copy_dir(src_dir: &Path, dest_dir: &Path) -> Fallible<()> {

Ok(())
}

#[cfg(test)]
#[derive(Default)]
pub(crate) struct TempDirBuilder {
dirs: Vec<PathBuf>,
files: Vec<(PathBuf, String)>,
}

#[cfg(test)]
impl TempDirBuilder {
pub(crate) fn dir<P: Into<PathBuf>>(mut self, path: P) -> TempDirBuilder {
self.dirs.push(path.into());
self
}

pub(crate) fn file<P: Into<PathBuf>>(mut self, path: P, content: &str) -> TempDirBuilder {
self.files.push((path.into(), content.into()));
self
}

pub(crate) fn build(self) -> Fallible<tempfile::TempDir> {
let temp = tempfile::TempDir::new()?;
for path in &self.dirs {
std::fs::create_dir_all(temp.path().join(path))?;
}
for (path, content) in &self.files {
let path = temp.path().join(path);
if let Some(parent) = path.parent() {
if !parent.exists() {
std::fs::create_dir_all(parent)?;
}
}
std::fs::write(&path, content.as_bytes())?;
}
Ok(temp)
}
}

0 comments on commit 9bdc4e8

Please sign in to comment.