summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSebastian Thiel <sthiel@thoughtworks.com>2019-06-08 15:43:38 +0530
committerSebastian Thiel <sthiel@thoughtworks.com>2019-06-08 15:43:38 +0530
commiteb4f9780d69824b9ca389f42b2ec65077640cd54 (patch)
treed8b053d3963d2230d399bd571930c0debd0e83dd /src
parentef8cf5636f782024372f044af80f06ed030168b0 (diff)
Somewhere over China: Let's not be quite so ignorant about errors during deletion
Diffstat (limited to 'src')
-rw-r--r--src/interactive/app_test.rs31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/interactive/app_test.rs b/src/interactive/app_test.rs
index 9737cb0..7a6d1c5 100644
--- a/src/interactive/app_test.rs
+++ b/src/interactive/app_test.rs
@@ -7,10 +7,17 @@ use failure::Error;
use jwalk::{DirEntry, WalkDir};
use petgraph::prelude::NodeIndex;
use pretty_assertions::assert_eq;
-use std::env::temp_dir;
-use std::fs::{copy, create_dir_all, remove_dir, remove_file};
-use std::io::ErrorKind;
-use std::{ffi::OsStr, ffi::OsString, fmt, path::Path, path::PathBuf};
+use std::{
+ env::temp_dir,
+ ffi::OsStr,
+ ffi::OsString,
+ fmt,
+ fs::{copy, create_dir_all, remove_dir, remove_file},
+ io,
+ io::ErrorKind,
+ path::Path,
+ path::PathBuf,
+};
use termion::input::TermRead;
use tui::backend::TestBackend;
use tui_react::Terminal;
@@ -340,11 +347,11 @@ struct WritableFixture {
impl Drop for WritableFixture {
fn drop(&mut self) {
- delete_recursive(&self.root);
+ delete_recursive(&self.root).unwrap();
}
}
-fn delete_recursive(path: impl AsRef<Path>) {
+fn delete_recursive(path: impl AsRef<Path>) -> Result<(), io::Error> {
let mut files: Vec<_> = Vec::new();
let mut dirs: Vec<_> = Vec::new();
@@ -356,12 +363,12 @@ fn delete_recursive(path: impl AsRef<Path>) {
false => files.push(p),
}
}
- for fp in files {
- remove_file(fp).ok();
- }
- for dp in dirs {
- remove_dir(dp).ok();
- }
+
+ files
+ .iter()
+ .map(|f| remove_file(f))
+ .chain(dirs.iter().map(|d| remove_dir(d)))
+ .collect::<Result<_, _>>()
}
fn copy_recursive(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> Result<(), Error> {