diff options
author | Haibo Huang <hhb@google.com> | 2020-11-18 15:37:31 -0800 |
---|---|---|
committer | Haibo Huang <hhb@google.com> | 2020-11-18 15:37:31 -0800 |
commit | 6c94c6bafeee5322a4502f48fd53bf0269f144cc (patch) | |
tree | 62e1173064643de076d5710596b3cd6d390f4d00 /scripts/check-minimal-versions.sh | |
parent | cd6b1713c13e53065c66512d3ba0a578bbf22830 (diff) | |
download | pin-project-6c94c6bafeee5322a4502f48fd53bf0269f144cc.tar.gz |
Upgrade rust/crates/pin-project to 1.0.2
Test: make
Change-Id: Ia85e48e7fd669c568d9abc6a68934b8cfdb13f09
Diffstat (limited to 'scripts/check-minimal-versions.sh')
-rwxr-xr-x | scripts/check-minimal-versions.sh | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/scripts/check-minimal-versions.sh b/scripts/check-minimal-versions.sh index 6c7fa7b..56fadee 100755 --- a/scripts/check-minimal-versions.sh +++ b/scripts/check-minimal-versions.sh @@ -3,7 +3,7 @@ # Check all public crates with minimal version dependencies. # # Usage: -# bash scripts/check-minimal-versions.sh +# bash scripts/check-minimal-versions.sh [+toolchain] [check|test] # # Note: # - This script modifies Cargo.toml and Cargo.lock while running @@ -13,19 +13,34 @@ # Refs: https://github.com/rust-lang/cargo/issues/5657 set -euo pipefail +IFS=$'\n\t' cd "$(cd "$(dirname "${0}")" && pwd)"/.. -if [[ "${1:-none}" == "+"* ]]; then - toolchain="${1}" -elif [[ "${CI:-false}" != "true" ]]; then - cargo +nightly -V >/dev/null || exit 1 - toolchain="+nightly" +# Decide Rust toolchain. +# Nightly is used by default if the `CI` environment variable is unset. +if [[ "${1:-}" == "+"* ]]; then + toolchain="${1}" + shift +elif [[ -z "${CI:-}" ]]; then + toolchain="+nightly" fi - +# Make sure toolchain is installed. +cargo ${toolchain:-} -V >/dev/null +# This script requires nightly Rust and cargo-hack if [[ "${toolchain:-+nightly}" != "+nightly"* ]] || ! cargo hack -V &>/dev/null; then - echo "error: check-minimal-versions.sh requires nightly Rust and cargo-hack" - exit 1 + echo "error: check-minimal-versions.sh requires nightly Rust and cargo-hack" + exit 1 +fi + +# Parse subcommand. +subcmd="${1:-check}" +if [[ ! "${subcmd}" =~ ^(check|test)$ ]]; then + echo "error: invalid argument: ${1}" + exit 1 +elif [[ -n "${2:-}" ]]; then + echo "error: invalid argument: ${2}" + exit 1 fi # This script modifies Cargo.toml and Cargo.lock, so make sure there are no @@ -34,11 +49,13 @@ git diff --exit-code # Restore original Cargo.toml and Cargo.lock on exit. trap 'git checkout .' EXIT -# Remove dev-dependencies from Cargo.toml to prevent the next `cargo update` -# from determining minimal versions based on dev-dependencies. -cargo hack --remove-dev-deps --workspace +if [[ "${subcmd}" == "check" ]]; then + # Remove dev-dependencies from Cargo.toml to prevent the next `cargo update` + # from determining minimal versions based on dev-dependencies. + cargo hack --remove-dev-deps --workspace +fi # Update Cargo.lock to minimal version dependencies. -cargo ${toolchain:-} update -Zminimal-versions +cargo ${toolchain:-} update -Z minimal-versions # Run check for all public members of the workspace. -cargo ${toolchain:-} hack check --workspace --all-features --ignore-private -Zfeatures=all +cargo ${toolchain:-} hack "${subcmd}" --workspace --all-features --ignore-private -Z features=all |