test_full.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. set -e
  3. CRATE=num-traits
  4. MSRV=1.31
  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=(libm)
  25. echo "Testing supported features: ${FEATURES[*]}"
  26. cargo generate-lockfile
  27. # libm 0.2.6 started using {float}::EPSILON
  28. check_version 1.43 || cargo update -p libm --precise 0.2.5
  29. set -x
  30. # test the default
  31. cargo build
  32. cargo test
  33. # test `no_std`
  34. cargo build --no-default-features
  35. cargo test --no-default-features
  36. # test each isolated feature, with and without std
  37. for feature in ${FEATURES[*]}; do
  38. cargo build --no-default-features --features="std $feature"
  39. cargo test --no-default-features --features="std $feature"
  40. cargo build --no-default-features --features="$feature"
  41. cargo test --no-default-features --features="$feature"
  42. done
  43. # test all supported features, with and without std
  44. cargo build --features="std ${FEATURES[*]}"
  45. cargo test --features="std ${FEATURES[*]}"
  46. cargo build --features="${FEATURES[*]}"
  47. cargo test --features="${FEATURES[*]}"