1#!/bin/bash 2 3set -e 4 5CRATE=num-traits 6MSRV=1.8 7 8get_rust_version() { 9 local array=($(rustc --version)); 10 echo "${array[1]}"; 11 return 0; 12} 13RUST_VERSION=$(get_rust_version) 14 15check_version() { 16 IFS=. read -ra rust <<< "$RUST_VERSION" 17 IFS=. read -ra want <<< "$1" 18 [[ "${rust[0]}" -gt "${want[0]}" || 19 ( "${rust[0]}" -eq "${want[0]}" && 20 "${rust[1]}" -ge "${want[1]}" ) 21 ]] 22} 23 24echo "Testing $CRATE on rustc $RUST_VERSION" 25if ! check_version $MSRV ; then 26 echo "The minimum for $CRATE is rustc $MSRV" 27 exit 1 28fi 29 30FEATURES=() 31check_version 1.26 && FEATURES+=(i128) 32check_version 1.27 && FEATURES+=(libm) 33echo "Testing supported features: ${FEATURES[*]}" 34 35set -x 36 37# test the default 38cargo build 39cargo test 40 41# test `no_std` 42cargo build --no-default-features 43cargo test --no-default-features 44 45# test each isolated feature, with and without std 46for feature in ${FEATURES[*]}; do 47 cargo build --no-default-features --features="std $feature" 48 cargo test --no-default-features --features="std $feature" 49 50 cargo build --no-default-features --features="$feature" 51 cargo test --no-default-features --features="$feature" 52done 53 54# test all supported features, with and without std 55cargo build --features="std ${FEATURES[*]}" 56cargo test --features="std ${FEATURES[*]}" 57 58cargo build --features="${FEATURES[*]}" 59cargo test --features="${FEATURES[*]}" 60