diff options
author | David Peter <sharkdp@users.noreply.github.com> | 2022-11-02 13:45:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-02 13:45:45 +0100 |
commit | 0a7b51ad4217fe40d5e6496a99ad54a9bd7b40cf (patch) | |
tree | b7208c63d416bcde19b0fe677ab42f05dab1cd42 | |
parent | cbd11d8a45dc80392c5f1be9679051085e6a3376 (diff) | |
parent | f15be89bff23cdd2fa94eeb484200f5d7d4ffb5f (diff) |
Merge pull request #1162 from sharkdp/fix-threads-option
Fix --threads/-j option value parsing
-rw-r--r-- | src/cli.rs | 2 | ||||
-rw-r--r-- | tests/tests.rs | 8 |
2 files changed, 9 insertions, 1 deletions
@@ -462,7 +462,7 @@ pub struct Opts { /// Set number of threads to use for searching & executing (default: number /// of available CPU cores) - #[arg(long, short = 'j', value_name = "num", hide_short_help = true, value_parser = 1..)] + #[arg(long, short = 'j', value_name = "num", hide_short_help = true, value_parser = clap::value_parser!(u32).range(1..))] pub threads: Option<u32>, /// Milliseconds to buffer before streaming search results to console diff --git a/tests/tests.rs b/tests/tests.rs index 4d5b151..1cc561f 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -2066,6 +2066,14 @@ fn test_list_details() { te.assert_success_and_get_output(".", &["--list-details"]); } +#[test] +fn test_single_and_multithreaded_execution() { + let te = TestEnv::new(DEFAULT_DIRS, DEFAULT_FILES); + + te.assert_output(&["--threads=1", "a.foo"], "a.foo"); + te.assert_output(&["--threads=16", "a.foo"], "a.foo"); +} + /// Make sure that fd fails if numeric arguments can not be parsed #[test] fn test_number_parsing_errors() { |