diff options
author | redzic <48274562+redzic@users.noreply.github.com> | 2020-06-23 08:58:41 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-23 15:58:41 +0200 |
commit | e94f9b942d8928b7993351a4109cfcef03055d2f (patch) | |
tree | 3945c5724954a5adbec187d15c0aed79d96c38eb | |
parent | adf3e1ba9a8277d9b3e3a327055b6097938b4e29 (diff) |
fix(tests): turn off parallelism when in test mode (#43)
* Added conditional compilation to turn off/on parallelism
* style(name): clarify constant name
Co-authored-by: Aram Drevekenin <aram@poor.dev>
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index b0b709c..3adbe32 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ mod state; mod ui; use ::failure; -use ::jwalk::Parallelism::RayonDefaultPool; +use ::jwalk::Parallelism::{RayonDefaultPool, Serial}; use ::jwalk::WalkDir; use ::std::env; use ::std::io; @@ -38,6 +38,10 @@ const SHOULD_SHOW_LOADING_ANIMATION: bool = false; const SHOULD_HANDLE_WIN_CHANGE: bool = true; #[cfg(test)] const SHOULD_HANDLE_WIN_CHANGE: bool = false; +#[cfg(not(test))] +const SHOULD_SCAN_HD_FILES_IN_MULTIPLE_THREADS: bool = true; +#[cfg(test)] +const SHOULD_SCAN_HD_FILES_IN_MULTIPLE_THREADS: bool = false; #[derive(StructOpt, Debug)] #[structopt(name = "diskonaut")] @@ -144,7 +148,11 @@ pub fn start<B>( let loaded = loaded.clone(); move || { 'scanning: for entry in WalkDir::new(&path) - .parallelism(RayonDefaultPool) + .parallelism(if SHOULD_SCAN_HD_FILES_IN_MULTIPLE_THREADS { + RayonDefaultPool + } else { + Serial + }) .skip_hidden(false) .follow_links(false) .into_iter() |