From d93e88f6cfe672737ad457d72070f037a4202c26 Mon Sep 17 00:00:00 2001 From: WATANABE Yuki Date: Sun, 10 Nov 2024 12:23:41 +0900 Subject: [PATCH 1/2] check-msrv: Autodetect expected MSRV This commit updates the `check-msrv` script to autodetect the expected minimum supported Rust version (MSRV) for each crate. This is done by querying the `rust_version` field of the package metadata using `jq`. This ensures that the script always tests the correct MSRV for each crate, even if the MSRV is updated in the future. --- check-msrv.sh | 84 ++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/check-msrv.sh b/check-msrv.sh index 42ced804..bd4fe336 100755 --- a/check-msrv.sh +++ b/check-msrv.sh @@ -16,47 +16,43 @@ resolver = "2" EOF } -update_workspace_member yash-arith -cargo +nightly update -Z direct-minimal-versions -cargo +1.65.0 test --package yash-arith -- $quiet - -update_workspace_member yash-builtin -cargo +nightly update -Z direct-minimal-versions -cargo +1.82.0 test --package yash-builtin -- $quiet - -update_workspace_member yash-cli -cargo +nightly update -Z direct-minimal-versions -cargo +1.82.0 test --package yash-cli -- $quiet - -update_workspace_member yash-env -cargo +nightly update -Z direct-minimal-versions -cargo +1.82.0 test --package yash-env -- $quiet - -update_workspace_member yash-env-test-helper -cargo +nightly update -Z direct-minimal-versions -cargo +1.82.0 test --package yash-env-test-helper -- $quiet - -update_workspace_member yash-executor -cargo +nightly update -Z direct-minimal-versions -cargo +1.65.0 test --package yash-executor -- $quiet - -update_workspace_member yash-fnmatch -cargo +nightly update -Z direct-minimal-versions -cargo +1.65.0 test --package yash-fnmatch -- $quiet - -update_workspace_member yash-prompt -cargo +nightly update -Z direct-minimal-versions -cargo +1.82.0 test --package yash-prompt -- $quiet - -update_workspace_member yash-quote -cargo +nightly update -Z direct-minimal-versions -cargo +1.65.0 test --package yash-quote -- $quiet - -update_workspace_member yash-semantics -cargo +nightly update -Z direct-minimal-versions -cargo +1.82.0 test --package yash-semantics -- $quiet - -update_workspace_member yash-syntax -cargo +nightly update -Z direct-minimal-versions -cargo +1.82.0 test --package yash-syntax -- $quiet -cargo +1.82.0 test --package yash-syntax --features annotate-snippets -- $quiet +prepare() { + update_workspace_member "$1" + cargo +nightly update -Z direct-minimal-versions + msrv=$(cargo metadata --format-version=1 | + jq -r ".packages[] | select(.name == \"$1\") | .rust_version") +} + +prepare yash-arith +cargo +$msrv test --package yash-arith -- $quiet + +prepare yash-builtin +cargo +$msrv test --package yash-builtin -- $quiet + +prepare yash-cli +cargo +$msrv test --package yash-cli -- $quiet + +prepare yash-env +cargo +$msrv test --package yash-env -- $quiet + +prepare yash-env-test-helper +cargo +$msrv test --package yash-env-test-helper -- $quiet + +prepare yash-executor +cargo +$msrv test --package yash-executor -- $quiet + +prepare yash-fnmatch +cargo +$msrv test --package yash-fnmatch -- $quiet + +prepare yash-prompt +cargo +$msrv test --package yash-prompt -- $quiet + +prepare yash-quote +cargo +$msrv test --package yash-quote -- $quiet + +prepare yash-semantics +cargo +$msrv test --package yash-semantics -- $quiet + +prepare yash-syntax +cargo +$msrv test --package yash-syntax -- $quiet +cargo +$msrv test --package yash-syntax --features annotate-snippets -- $quiet From 05c402fa8a8bdd51abc0f2a0b98fe59b27ffe2d8 Mon Sep 17 00:00:00 2001 From: WATANABE Yuki Date: Sun, 10 Nov 2024 13:04:03 +0900 Subject: [PATCH 2/2] check-msrv: Refactor by extracting a function to run tests --- check-msrv.sh | 62 +++++++++++++++++++++------------------------------ 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/check-msrv.sh b/check-msrv.sh index bd4fe336..6c901c18 100755 --- a/check-msrv.sh +++ b/check-msrv.sh @@ -16,43 +16,33 @@ resolver = "2" EOF } -prepare() { - update_workspace_member "$1" +# $1 = package name +# $2, $3, ... = additional options to `cargo test` +check() { + package="$1" + shift + if [ "$#" -eq 0 ]; then + set '' + fi + + update_workspace_member "$package" cargo +nightly update -Z direct-minimal-versions msrv=$(cargo metadata --format-version=1 | - jq -r ".packages[] | select(.name == \"$1\") | .rust_version") -} - -prepare yash-arith -cargo +$msrv test --package yash-arith -- $quiet - -prepare yash-builtin -cargo +$msrv test --package yash-builtin -- $quiet - -prepare yash-cli -cargo +$msrv test --package yash-cli -- $quiet - -prepare yash-env -cargo +$msrv test --package yash-env -- $quiet - -prepare yash-env-test-helper -cargo +$msrv test --package yash-env-test-helper -- $quiet + jq -r ".packages[] | select(.name == \"$package\") | .rust_version") -prepare yash-executor -cargo +$msrv test --package yash-executor -- $quiet - -prepare yash-fnmatch -cargo +$msrv test --package yash-fnmatch -- $quiet - -prepare yash-prompt -cargo +$msrv test --package yash-prompt -- $quiet - -prepare yash-quote -cargo +$msrv test --package yash-quote -- $quiet - -prepare yash-semantics -cargo +$msrv test --package yash-semantics -- $quiet + for options do + cargo +$msrv test --package "$package" $options -- $quiet + done +} -prepare yash-syntax -cargo +$msrv test --package yash-syntax -- $quiet -cargo +$msrv test --package yash-syntax --features annotate-snippets -- $quiet +check yash-arith +check yash-builtin +check yash-cli +check yash-env +check yash-env-test-helper +check yash-executor +check yash-fnmatch +check yash-prompt +check yash-quote +check yash-semantics +check yash-syntax '' '--features annotate-snippets'