Skip to content

Commit

Permalink
fix: switch to TokioCommand for async execution in cli tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbrink committed Feb 9, 2025
1 parent f9fb0c4 commit 5e8bd80
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf
# Add OpenSSL dev packages for cross-compilation
sudo apt-get install -y libssl-dev:arm64 libssl-dev:armhf pkg-config
# Configure pkg-config for cross-compilation
echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
echo "PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig" >> $GITHUB_ENV
- name: Cache dependencies
uses: actions/cache@v4
Expand Down
10 changes: 6 additions & 4 deletions tests/cli_test.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use anyhow::Result;
use std::process::Command;
use std::time::Duration;
use tokio::process::Command as TokioCommand;
use tokio::time::sleep;

// Helper function to run the command to avoid rebuilding for each test
async fn run_strainer_command(args: &[&str]) -> Result<std::process::Output> {
Ok(Command::new("cargo")
Ok(TokioCommand::new("cargo")
.args(["run", "--"])
.args(args)
.output()?)
.output()
.await?)
}

#[tokio::test]
Expand Down Expand Up @@ -61,7 +63,7 @@ async fn test_run_command_rate_limits() -> Result<()> {
async fn test_run_command_process_control() -> Result<()> {
let mut child = Command::new("cargo")
.args(["run", "--"])
.args(&[
.args([
"run",
"--api-key",
"test_key",
Expand Down Expand Up @@ -115,4 +117,4 @@ async fn test_watch_command() -> Result<()> {
// Should fail because watch command is not implemented yet
assert!(!output.status.success());
Ok(())
}
}

0 comments on commit 5e8bd80

Please sign in to comment.