Permalink
Browse files

Auto merge of #387 - pietroalbini:revert-cleanup, r=pietroalbini

Revert target directory cleanup

Actually broke a lot of stuff.
  • Loading branch information...
bors committed Jan 3, 2019
2 parents b83e3c7 + 9bdc4e8 commit d68b832ca8dedb300d3ff466b5f7ba7146088430
Showing with 0 additions and 131 deletions.
  1. +0 −91 src/runner/cleanup.rs
  2. +0 −1 src/runner/mod.rs
  3. +0 −2 src/runner/test.rs
  4. +0 −37 src/utils/fs.rs

This file was deleted.

Oops, something went wrong.
@@ -1,4 +1,3 @@
mod cleanup;
mod graph;
mod prepare;
mod tasks;
@@ -1,4 +1,3 @@
use super::cleanup;
use crate::docker::{DockerError, MountPerms};
use crate::prelude::*;
use crate::results::{FailureReason, TestResult, WriteResults};
@@ -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(())
}
@@ -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 d68b832

Please sign in to comment.