Strip prefix from file path.

This commit is contained in:
Tom Alexander 2023-10-14 15:07:17 -04:00
parent f43920fc7c
commit 92afdc0ea6
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 16 additions and 9 deletions

View File

@ -1,12 +1,10 @@
#![feature(round_char_boundary)]
#![feature(exact_size_is_empty)]
use std::io::Read;
use std::path::Path;
use std::path::PathBuf;
use futures::future::BoxFuture;
use futures::future::FutureExt;
use organic::compare::run_compare_on_file;
use organic::compare::silent_compare_on_file;
use tokio::sync::Semaphore;
use tokio::task::JoinError;
@ -85,14 +83,23 @@ fn compare_all_org_document<P: AsRef<Path>>(root_dir: P) -> impl Iterator<Item =
})
.collect::<Result<Vec<_>, _>>()
.unwrap();
let test_configs = test_files.into_iter().map(|test_file| {
let name = test_file.path().as_os_str().to_string_lossy().into_owned();
TestConfig::SingleFile(SingleFile {
name,
file_path: test_file.into_path(),
let test_configs: Vec<_> = test_files
.into_iter()
.map(|test_file| {
let name = test_file
.path()
.strip_prefix(root_dir)
.expect("Result is from walkdir so it must be below the root directory.")
.as_os_str()
.to_string_lossy()
.into_owned();
TestConfig::SingleFile(SingleFile {
name,
file_path: test_file.into_path(),
})
})
});
test_configs
.collect();
test_configs.into_iter()
}
static TEST_PERMITS: Semaphore = Semaphore::const_new(8);