Add debugging to the test scratch test

This commit is contained in:
Graham Christensen 2018-08-08 08:52:15 -04:00
parent b882a7a01c
commit a923e71a79
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C

View file

@ -8,27 +8,34 @@ pub struct TestScratch {
impl TestScratch {
pub fn new_dir(ident: &str) -> TestScratch {
let path = TestScratch {
let scratch = TestScratch {
root: Path::new(env!("CARGO_MANIFEST_DIR"))
.join("test-scratch")
.join("dirs")
.join(&format!("dir-{}", ident)),
};
fs::create_dir_all(path.root.parent().unwrap()).unwrap();
return path;
TestScratch::create_dir(&scratch);
return scratch;
}
pub fn new_file(ident: &str) -> TestScratch {
let path = TestScratch {
let scratch = TestScratch {
root: Path::new(env!("CARGO_MANIFEST_DIR"))
.join("test-scratch")
.join("files")
.join(&format!("file-{}", ident)),
};
fs::create_dir_all(path.root.parent().unwrap()).unwrap();
return path;
TestScratch::create_dir(&scratch);
return scratch;
}
fn create_dir(path: &TestScratch) {
let target = path.root.parent().unwrap();
debug!("Creating directory {:?}", target);
fs::create_dir_all(target).unwrap();
}
pub fn path(&self) -> PathBuf {
@ -42,6 +49,7 @@ impl TestScratch {
impl Drop for TestScratch {
fn drop(&mut self) {
debug!("Deleting root {:?}", self.root);
Command::new("rm")
.arg("-rf")
.arg(self.root.clone())