refactor: replace run_keep with run_sh for sh -c command execution

This commit is contained in:
Andrew Phillips (aider)
2025-05-12 12:06:44 -03:00
parent 543468bf0e
commit b5de04c877

View File

@@ -6,11 +6,11 @@ mod tests {
use tempfile::tempdir; use tempfile::tempdir;
// Helper function to run the keep command with given arguments // Helper function to run a command in sh -c
fn run_keep(args: &[&str]) -> std::process::Output { fn run_sh(cmd: &str) -> std::process::Output {
let output = Command::new("cargo") let output = Command::new("sh")
.args(["run", "--",]) .arg("-c")
.args(args) .arg(cmd)
.output() .output()
.expect("Failed to execute command"); .expect("Failed to execute command");
output output
@@ -56,14 +56,8 @@ mod tests {
// Save an item with some content // Save an item with some content
let input = "test content"; let input = "test content";
// Create a command that pipes input to keep with the specified environment // Create a command that pipes input to keep with the specified environment
let mut cmd = Command::new("sh"); let cmd = format!("echo {} | {}", input, env);
cmd.arg("-c") run_sh(cmd.as_str()).expect("Failed to execute command");
.arg(format!("echo {} | {}", input, env));
cmd.spawn()
.expect("Failed to spawn process")
.wait()
.expect("Failed to wait for child process");
// Verify the item was saved // Verify the item was saved
let output = Command::new("sh") let output = Command::new("sh")
@@ -232,15 +226,8 @@ mod tests {
// Save an item with some content and tags // Save an item with some content and tags
let input = "test content"; let input = "test content";
// Create a command that pipes input to keep with the specified environment and tags // Create a command that pipes input to keep with the specified environment and tags
let mut cmd = Command::new("sh"); let cmd = format!("echo {} | {}", input, env);
cmd.arg("-c") run_sh(cmd.as_str()).expect("Failed to execute command");
.arg(format!("echo {} | {}", input, env))
.arg("cargo run -- --save tag1 tag2");
cmd.spawn()
.expect("Failed to spawn process")
.wait()
.expect("Failed to wait for child process");
// List items with a specific tag // List items with a specific tag
let output = Command::new("sh") let output = Command::new("sh")
@@ -263,15 +250,8 @@ mod tests {
// Save an item with some content and compression // Save an item with some content and compression
let input = "test content"; let input = "test content";
// Create a command that pipes input to keep with the specified environment and compression // Create a command that pipes input to keep with the specified environment and compression
let mut cmd = Command::new("sh"); let cmd = format!("echo {} | {}", input, env);
cmd.arg("-c") run_sh(cmd.as_str()).expect("Failed to execute command");
.arg(format!("echo {} | {}", input, env))
.arg("cargo run -- --save --compression gzip");
cmd.spawn()
.expect("Failed to spawn process")
.wait()
.expect("Failed to wait for child process");
// Get the item ID // Get the item ID
let list_output = Command::new("sh") let list_output = Command::new("sh")