| 159 | } |
| 160 | |
| 161 | async fn assert_equal_dirs(src: &Path, dst: &Path) { |
| 162 | let mut src_dir = fs::read_dir(src).await.map(ReadDirStream::new).unwrap(); |
| 163 | let mut buf_a = vec![]; |
| 164 | let mut buf_b = vec![]; |
| 165 | while let Some(entry) = src_dir.next().await.map(Result::unwrap) { |
| 166 | if entry.file_type().await.unwrap().is_file() { |
| 167 | let src_path = entry.path(); |
| 168 | let dst_path = dst.join(src_path.file_name().unwrap()); |
| 169 | |
| 170 | let mut src_file = fs::File::open(&src_path).await.unwrap(); |
| 171 | let mut dst_file = fs::File::open(&dst_path).await.unwrap(); |
| 172 | |
| 173 | src_file.read_to_end(&mut buf_a).await.unwrap(); |
| 174 | dst_file.read_to_end(&mut buf_b).await.unwrap(); |
| 175 | |
| 176 | assert_eq!(buf_a, buf_b, "{} and {} differ", src_path.display(), dst_path.display()); |
| 177 | } |
| 178 | buf_a.clear(); |
| 179 | buf_b.clear(); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | fn default_options() -> Options { |
| 184 | Options { |