test_full.sh 1.4 KB

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