mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-25 06:40:03 +00:00
Support --registry
and more options from .cargo/config.toml
(#1195)
Fixed #885 Now we can take advantage of new argument `--registry` and env overrides: - `CARGO_REGISTRIES_DEFAULT` if `--registry` is not specified - `CARGO_REGISTRIES_{registry_name}_INDEX` for the registry index url We can also read from `.cargo/config.toml` for: - default registry and registries configurations - additional CA bundle `http.cainfo` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
d280e122ca
commit
7dea40a99a
7 changed files with 297 additions and 63 deletions
62
e2e-tests/registries.sh
Normal file
62
e2e-tests/registries.sh
Normal file
|
@ -0,0 +1,62 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
test_cargo_binstall_install() {
|
||||
# Test that the installed binaries can be run
|
||||
cargo binstall --help >/dev/null
|
||||
|
||||
cargo_binstall_version="$(cargo binstall -V)"
|
||||
echo "$cargo_binstall_version"
|
||||
|
||||
[ "$cargo_binstall_version" = "cargo-binstall 0.12.0" ]
|
||||
}
|
||||
|
||||
unset CARGO_INSTALL_ROOT
|
||||
|
||||
CARGO_HOME="$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-home')"
|
||||
export CARGO_HOME
|
||||
export PATH="$CARGO_HOME/bin:$PATH"
|
||||
|
||||
# Testing conflicts of `--index` and `--registry`
|
||||
set +e
|
||||
|
||||
"./$1" binstall --index 'sparse+https://index.crates.io/' --registry t1 cargo-binstall
|
||||
exit_code="$?"
|
||||
|
||||
set -e
|
||||
|
||||
if [ "$exit_code" != 2 ]; then
|
||||
echo "Expected exit code 2, but actual exit code $exit_code"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat >"$CARGO_HOME/config.toml" << EOF
|
||||
[registries]
|
||||
t1 = { index = "https://github.com/rust-lang/crates.io-index" }
|
||||
t2 = { index = "sparse+https://index.crates.io/" }
|
||||
|
||||
[registry]
|
||||
default = "t1"
|
||||
EOF
|
||||
|
||||
# Install binaries using default registry in config
|
||||
"./$1" binstall --force -y cargo-binstall@0.12.0
|
||||
|
||||
test_cargo_binstall_install
|
||||
|
||||
# Install binaries using registry t2 in config
|
||||
"./$1" binstall --force --registry t2 -y cargo-binstall@0.12.0
|
||||
|
||||
test_cargo_binstall_install
|
||||
|
||||
# Install binaries using registry t3 in env
|
||||
CARGO_REGISTRIES_t3_INDEX='sparse+https://index.crates.io/' "./$1" binstall --force --registry t3 -y cargo-binstall@0.12.0
|
||||
|
||||
test_cargo_binstall_install
|
||||
|
||||
|
||||
# Install binaries using index directly
|
||||
"./$1" binstall --force --index 'sparse+https://index.crates.io/' -y cargo-binstall@0.12.0
|
||||
|
||||
test_cargo_binstall_install
|
Loading…
Add table
Add a link
Reference in a new issue