diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b092ae2..70683aa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -17,5 +17,6 @@ jobs: name: Run cargo test with: command: test + args: --all-targets --all-features - name: Run terminal tests - run: ./tests/tests-unix.sh \ No newline at end of file + run: ./tests/tests-unix.sh diff --git a/Cargo.toml b/Cargo.toml index 473069e..a5f15a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rpassword" -version = "5.0.0" +version = "5.0.1" authors = ["Conrad Kleinespel "] description = "Read passwords in console applications." license = "Apache-2.0" diff --git a/tests/piped.rs b/tests/piped.rs index 8aa24f1..6d10788 100644 --- a/tests/piped.rs +++ b/tests/piped.rs @@ -1,27 +1,21 @@ //! This test checks that piped input is handled correctly. -use std::env; use std::io::Write; use std::process::{Command, Stdio}; #[test] fn piped_password() { - // Find target directory - let target_dir = env::current_exe() - .unwrap() - .parent() - .unwrap() - .parent() - .unwrap() - .to_path_buf(); - // Run an example that reads a password and prints it - let mut out = Command::new(target_dir.join("examples/read-password")) + let mut out = Command::new("cargo") + .arg("run") + .arg("--quiet") + .arg("--example") + .arg("read-password") .stdout(Stdio::piped()) .stdin(Stdio::piped()) .spawn() .unwrap(); - + // Write "secret" as the password into stdin let stdin = out.stdin.as_mut().unwrap(); stdin.write_all("secret".as_bytes()).unwrap(); diff --git a/tests/tests-unix.sh b/tests/tests-unix.sh index 50270f0..e629701 100755 --- a/tests/tests-unix.sh +++ b/tests/tests-unix.sh @@ -13,14 +13,14 @@ DIR="$( dirname $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) )" # - diff tests/stderr <(printf "prompt_password_stderrprompt_reply_stderr") # STDIN comes from a pipe -printf "1\n2\n3\n" | $DIR/target/debug/examples/tests > $DIR/tests/results_pipe_actual_stdout 2> $DIR/tests/results_pipe_actual_stderr +printf "1\n2\n3\n" | cargo run --quiet --example tests > $DIR/tests/results_pipe_actual_stdout 2> $DIR/tests/results_pipe_actual_stderr diff $DIR/tests/results_pipe_expected_stdout $DIR/tests/results_pipe_actual_stdout echo 'pipe stdout OK' diff $DIR/tests/results_pipe_expected_stderr $DIR/tests/results_pipe_actual_stderr echo 'pipe stderr OK' # missing newline, only tested in pipe mode -printf "1\n2\n3" | $DIR/target/debug/examples/tests > $DIR/tests/results_pipe_missing_nl_actual_stdout 2> $DIR/tests/results_pipe_missing_nl_actual_stderr +printf "1\n2\n3" | cargo run --quiet --example tests > $DIR/tests/results_pipe_missing_nl_actual_stdout 2> $DIR/tests/results_pipe_missing_nl_actual_stderr diff $DIR/tests/results_pipe_missing_nl_expected_stdout $DIR/tests/results_pipe_missing_nl_actual_stdout echo 'pipe with missing nl stdout OK' diff $DIR/tests/results_pipe_missing_nl_expected_stderr $DIR/tests/results_pipe_missing_nl_actual_stderr