Feature: Impl opt-out options (#510)

Fixed #136

* Impl opt-out optioins in binstalk
* Replace field `Options::{gh_crate, quickinstall}_fetcher` with `resolver`
  which can determine order of resolver used.
* Add new field `Args::{disable_}strategies`
* Add new variant `BinstallError::InvalidStrategies`
* Add variant `BinstallError::NoFallbackToCargoInstall`
* Add code for supporting strategies in mod entry
* Test `--disable-strategies` in `tests.sh`
* Test for `--strategies` in `tests.sh`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-11-11 16:24:46 +11:00 committed by GitHub
parent 89fa5b1769
commit 9e80cf0700
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 141 additions and 11 deletions

View file

@ -77,16 +77,13 @@ cargo binstall --help >/dev/null
"./$1" binstall --no-confirm cargo-binstall@0.12.0 | grep -q 'cargo-binstall v0.12.0 is already installed'
"./$1" binstall --no-confirm cargo-binstall@^0.12.0 | grep -q -v 'cargo-binstall v0.12.0 is already installed'
# to force failure if falling back to source
# FIXME: remove/replace once #136 lands
export PATH="$test_resources/fake-cargo:$PATH"
# Test default GitLab pkg-url templates
"./$1" binstall \
--force \
--manifest-path "$test_resources/gitlab-test-Cargo.toml" \
--log-level debug \
--no-confirm \
--disable-strategies compile \
cargo-binstall
# Test default BitBucket pkg-url templates
@ -95,6 +92,7 @@ export PATH="$test_resources/fake-cargo:$PATH"
--manifest-path "$test_resources/bitbucket-test-Cargo.toml" \
--log-level debug \
--no-confirm \
--disable-strategies compile \
cargo-binstall
# Test default Github pkg-url templates,
@ -104,4 +102,25 @@ export PATH="$test_resources/fake-cargo:$PATH"
--manifest-path "$test_resources/github-test-Cargo2.toml" \
--log-level debug \
--no-confirm \
--disable-strategies compile \
cargo-binstall
## Test --disable-strategies
set +e
"./$1" binstall --no-confirm --disable-strategies quick-install,compile cargo-update
exit_code="$?"
if [ "$exit_code" != 94 ]; then
echo "Expected exit code 94, but actual exit code $exit_code"
exit 1
fi
## Test --strategies
"./$1" binstall --no-confirm --strategies crate-meta-data cargo-update
exit_code="$?"
if [ "$exit_code" != 94 ]; then
echo "Expected exit code 94, but actual exit code $exit_code"
exit 1
fi