mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-25 06:40:03 +00:00
feat: Impl new option --continue-on-failure
(#1559)
* feat: Impl new option `--continue-on-failure` Resolve #1548 Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Add new e2e-tests continue-on-failure Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Rm dup line ion `e2e-tests/live.sh` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix shellcheck Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Fix `BinstallError::crate_errors` if `errors.len()` is 1 In that case, it should return `Some(Self::CrateContext(_))` instead of `Some(Self::Errors(_))` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Add more tests to `e2e-tests/continue-on-failure.sh` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Propagate crate errors on `confirm()` err Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> * Test having two errors in `e2e-tests/continue-on-failure.sh` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --------- Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
f5da25cc56
commit
c08b8d232a
8 changed files with 365 additions and 60 deletions
58
e2e-tests/continue-on-failure.sh
Executable file
58
e2e-tests/continue-on-failure.sh
Executable file
|
@ -0,0 +1,58 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
unset CARGO_INSTALL_ROOT
|
||||
|
||||
CARGO_HOME=$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-home')
|
||||
export CARGO_HOME
|
||||
othertmpdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-test')
|
||||
export PATH="$CARGO_HOME/bin:$othertmpdir/bin:$PATH"
|
||||
|
||||
mkdir -p "$othertmpdir/bin"
|
||||
# Copy it to bin to test use of env var `CARGO`
|
||||
cp "./$1" "$othertmpdir/bin/"
|
||||
|
||||
|
||||
## Test --continue-on-failure
|
||||
set +e
|
||||
cargo binstall --no-confirm --continue-on-failure cargo-watch@8.4.0 non-existent-clippy
|
||||
exit_code="$?"
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$exit_code" != 76 ]; then
|
||||
echo "Expected exit code 76, but actual exit code $exit_code"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
cargo_watch_version="$(cargo watch -V)"
|
||||
echo "$cargo_watch_version"
|
||||
|
||||
[ "$cargo_watch_version" = "cargo-watch 8.4.0" ]
|
||||
|
||||
|
||||
## Test that it is no-op when only one crate is passed
|
||||
set +e
|
||||
cargo binstall --no-confirm --continue-on-failure non-existent-clippy
|
||||
exit_code="$?"
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$exit_code" != 76 ]; then
|
||||
echo "Expected exit code 76, but actual exit code $exit_code"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test if both crates are invalid
|
||||
set +e
|
||||
cargo binstall --no-confirm --continue-on-failure non-existent-clippy non-existent-clippy2
|
||||
exit_code="$?"
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$exit_code" != 76 ]; then
|
||||
echo "Expected exit code 76, but actual exit code $exit_code"
|
||||
exit 1
|
||||
fi
|
|
@ -36,7 +36,6 @@ echo "$cargo_release_version"
|
|||
|
||||
[ "$cargo_release_version" = "cargo-release 0.24.9" ]
|
||||
|
||||
cargo-binstall --help >/dev/null
|
||||
cargo binstall --help >/dev/null
|
||||
|
||||
cargo_binstall_version="$(cargo-binstall -V)"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue