From fe16f24ed89be57ac75814c3c294c805a0e4df12 Mon Sep 17 00:00:00 2001 From: sudotac Date: Wed, 31 Jan 2024 23:34:57 +0900 Subject: [PATCH] test(complete): Verify filename splitting --- clap_complete/tests/testsuite/bash.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/clap_complete/tests/testsuite/bash.rs b/clap_complete/tests/testsuite/bash.rs index 1392294bd2d..d64d155a521 100644 --- a/clap_complete/tests/testsuite/bash.rs +++ b/clap_complete/tests/testsuite/bash.rs @@ -222,6 +222,27 @@ fn complete() { ); } + // Issue 5313 (https://github.com/clap-rs/clap/issues/5313) + { + use std::fs::File; + use std::path::Path; + + let testdir = snapbox::path::PathFixture::mutable_temp().unwrap(); + let testdir_path = testdir.path().unwrap(); + + File::create(Path::new(testdir_path).join("foo bar.txt")).unwrap(); + File::create(Path::new(testdir_path).join("baz\tqux.txt")).unwrap(); + + let input = format!( + "exhaustive hint --file {}/\t\t", + testdir_path.to_string_lossy() + ); + let expected = r#"% +foo bar.txt baz qux.txt "#; + let actual = runtime.complete(input.as_str(), &term).unwrap(); + snapbox::assert_eq(expected, actual); + } + let input = "exhaustive hint --other \t"; let expected = "exhaustive hint --other % exhaustive hint --other "; let actual = runtime.complete(input, &term).unwrap();