From f60c92ca58db9dd941224d02779e3a97a00d3b4f Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 14 Jul 2022 09:53:31 +1000 Subject: [PATCH] Add informative error message to DO_BENCH If CI script is run with `DO_BENCH=true` and `TOOLCHAIN` set to a non-nightly toolchain the build will fail with a less than meaningful error. To assist runners of the script output an informative error message if an attempt is made at using the wrong toolchain. --- contrib/test.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/contrib/test.sh b/contrib/test.sh index 6238d299..f46a2de5 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -16,6 +16,12 @@ fi cargo --version rustc --version +# Work out if we are using a nightly toolchain. +NIGHTLY=false +if cargo --version | grep nightly; then + NIGHTLY=true +fi + echo "********* Testing std *************" # Test without any features other than std first cargo test --verbose --no-default-features --features="std" @@ -74,6 +80,16 @@ fi # Bench if told to if [ "$DO_BENCH" = true ] then + if [ "NIGHTLY" = false ] + then + if [ -n "TOOLCHAIN" ] + then + echo "TOOLCHAIN is set to a non-nightly toolchain but DO_BENCH requires a nightly toolchain" + else + echo "DO_BENCH requires a nightly toolchain" + fi + exit 1 + fi cargo bench --features unstable fi