修复搜索工具错误
This commit is contained in:
parent
a73f9edda2
commit
1c59880f64
@ -189,7 +189,6 @@ impl FileSearchTool {
|
|||||||
.arg(pattern)
|
.arg(pattern)
|
||||||
.arg("--color")
|
.arg("--color")
|
||||||
.arg("never")
|
.arg("never")
|
||||||
.arg("--strip-cwd-prefix")
|
|
||||||
.arg("--max-results")
|
.arg("--max-results")
|
||||||
.arg(max_results.to_string())
|
.arg(max_results.to_string())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
@ -360,6 +359,45 @@ mod tests {
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use tempfile::TempDir;
|
use tempfile::TempDir;
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[tokio::test]
|
||||||
|
async fn fd_search_path_does_not_use_incompatible_strip_cwd_prefix() {
|
||||||
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
|
||||||
|
let dir = TempDir::new().unwrap();
|
||||||
|
let fake_fd = dir.path().join("fd");
|
||||||
|
fs::write(
|
||||||
|
&fake_fd,
|
||||||
|
r#"#!/bin/sh
|
||||||
|
for arg in "$@"; do
|
||||||
|
if [ "$arg" = "--strip-cwd-prefix" ]; then
|
||||||
|
echo "--strip-cwd-prefix conflicts with --search-path" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
printf '%s\n' 'example.rs'
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
let mut permissions = fs::metadata(&fake_fd).unwrap().permissions();
|
||||||
|
permissions.set_mode(0o755);
|
||||||
|
fs::set_permissions(&fake_fd, permissions).unwrap();
|
||||||
|
|
||||||
|
let tool = FileSearchTool::new();
|
||||||
|
let results = tool
|
||||||
|
.search_with_fd(
|
||||||
|
"*.rs",
|
||||||
|
dir.path().to_str().unwrap(),
|
||||||
|
true,
|
||||||
|
10,
|
||||||
|
fake_fd.to_str().unwrap(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(results, vec!["example.rs"]);
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_file_search_rust_fallback() {
|
async fn test_file_search_rust_fallback() {
|
||||||
let dir = TempDir::new().unwrap();
|
let dir = TempDir::new().unwrap();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user