From a923e71a793e15584c6fca14f2cf66379eb8be4c Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Wed, 8 Aug 2018 08:52:15 -0400 Subject: [PATCH] Add debugging to the test scratch test --- ofborg/src/test_scratch.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/ofborg/src/test_scratch.rs b/ofborg/src/test_scratch.rs index cec800b..1904ee0 100644 --- a/ofborg/src/test_scratch.rs +++ b/ofborg/src/test_scratch.rs @@ -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())