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>
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -8,7 +8,7 @@ mod state;
|
|||||||
mod ui;
|
mod ui;
|
||||||
|
|
||||||
use ::failure;
|
use ::failure;
|
||||||
use ::jwalk::Parallelism::RayonDefaultPool;
|
use ::jwalk::Parallelism::{RayonDefaultPool, Serial};
|
||||||
use ::jwalk::WalkDir;
|
use ::jwalk::WalkDir;
|
||||||
use ::std::env;
|
use ::std::env;
|
||||||
use ::std::io;
|
use ::std::io;
|
||||||
@@ -38,6 +38,10 @@ const SHOULD_SHOW_LOADING_ANIMATION: bool = false;
|
|||||||
const SHOULD_HANDLE_WIN_CHANGE: bool = true;
|
const SHOULD_HANDLE_WIN_CHANGE: bool = true;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
const SHOULD_HANDLE_WIN_CHANGE: bool = false;
|
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)]
|
#[derive(StructOpt, Debug)]
|
||||||
#[structopt(name = "diskonaut")]
|
#[structopt(name = "diskonaut")]
|
||||||
@@ -144,7 +148,11 @@ pub fn start<B>(
|
|||||||
let loaded = loaded.clone();
|
let loaded = loaded.clone();
|
||||||
move || {
|
move || {
|
||||||
'scanning: for entry in WalkDir::new(&path)
|
'scanning: for entry in WalkDir::new(&path)
|
||||||
.parallelism(RayonDefaultPool)
|
.parallelism(if SHOULD_SCAN_HD_FILES_IN_MULTIPLE_THREADS {
|
||||||
|
RayonDefaultPool
|
||||||
|
} else {
|
||||||
|
Serial
|
||||||
|
})
|
||||||
.skip_hidden(false)
|
.skip_hidden(false)
|
||||||
.follow_links(false)
|
.follow_links(false)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|||||||
Reference in New Issue
Block a user