loom 864 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/env bash
  2. #
  3. # Runs `loom` tests, using `cargo nextest` if it's available, or `cargo test`
  4. # otherwise.
  5. #
  6. # Usage:
  7. # All environment variables honored by `loom` can be used to configure `loom`
  8. # test behavior. Default values are set for `LOOM_LOG` and
  9. # `LOOM_MAX_PREEMPTIONS`, if those variables are unset when the script is
  10. # invoked.
  11. #
  12. # Any command-line arguments are passed through to the test invocation.
  13. set -euo pipefail
  14. set -x
  15. cd "$(dirname "$0")"/..
  16. TESTCMD=(test)
  17. # if cargo nextest is installed, use it instead!
  18. if cargo list | grep -q "nextest"; then
  19. TESTCMD=(nextest run --cargo-profile loom)
  20. fi
  21. TESTCMD+=(--profile loom --lib)
  22. # pass through args
  23. TESTCMD+=(${@})
  24. RUSTFLAGS="--cfg loom ${RUSTFLAGS:-}" \
  25. LOOM_LOG="${LOOM_LOG:-info}" \
  26. LOOM_MAX_PREEMPTIONS="${LOOM_MAX_PREEMPTIONS:-2}" \
  27. cargo ${TESTCMD[@]}