Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/ofborg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b882a7a01c95
Choose a base ref
...
head repository: NixOS/ofborg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a923e71a793e
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Aug 8, 2018

  1. Copy the full SHA
    a923e71 View commit details
Showing with 14 additions and 6 deletions.
  1. +14 −6 ofborg/src/test_scratch.rs
20 changes: 14 additions & 6 deletions ofborg/src/test_scratch.rs
Original file line number Diff line number Diff line change
@@ -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())