test-release.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. export MMGEN_TEST_SUITE=1
  3. export PYTHONPATH=.
  4. RED="\e[31;1m" GREEN="\e[32;1m" YELLOW="\e[33;1m" BLUE="\e[34;1m" MAGENTA="\e[35;1m" CYAN="\e[36;1m"
  5. RESET="\e[0m"
  6. set -o errtrace
  7. set -o functrace
  8. trap 'echo -e "${GREEN}Exiting at user request$RESET"; exit' INT
  9. trap 'echo -e "${RED}Node tools test suite exited with error$RESET"' ERR
  10. umask 0022
  11. unit_tests_py='test/unit_tests.py --names --quiet'
  12. PROGNAME=$(basename $0)
  13. while getopts hv OPT
  14. do
  15. case "$OPT" in
  16. h) printf " %-16s The MMGen node tools test suite\n" "${PROGNAME}:"
  17. echo " USAGE: $PROGNAME [options] [tests or test group]"
  18. echo " OPTIONS: '-h' Print this help message"
  19. echo " '-v' Run commands with '--verbose' switch"
  20. exit ;;
  21. v) VERBOSE=1
  22. unit_tests_py="${unit_tests_py/--quiet/--verbose}" ;;
  23. *) exit ;;
  24. esac
  25. done
  26. shift $((OPTIND-1))
  27. nt_repo='../mmgen-node-tools'
  28. mm_repo='../mmgen'
  29. die() { echo -e $YELLOW$1$RESET; false; }
  30. gecho() { echo -e $GREEN$1$RESET; }
  31. pecho() { echo -e $MAGENTA$1$RESET; }
  32. becho() { echo -e $BLUE$1$RESET; }
  33. check_mmgen_repo() {
  34. ( cd $mm_repo; python3 ./setup.py --url | grep -iq 'mmgen' )
  35. }
  36. create_links() {
  37. ( cd 'mmgen'; [ -L 'node_tools' ] || ln -s "../$nt_repo/mmgen/node_tools" )
  38. (
  39. cd 'test/unit_tests_d'
  40. for fn in ../../$nt_repo/test/unit_tests_d/nt_*.py; do
  41. [ -L "$(basename $fn)" ] || ln -s "$fn"
  42. done
  43. )
  44. }
  45. run_unit_tests() {
  46. pecho 'Running unit tests:'
  47. $unit_tests_py --node-tools
  48. pecho 'Completed unit tests'
  49. }
  50. # start execution
  51. set -e
  52. becho 'Starting node tools test suite (WIP)'
  53. check_mmgen_repo || die "No MMGen repository found at $mm_repo!"
  54. cd $mm_repo
  55. create_links
  56. run_unit_tests
  57. becho 'Node tools test suite completed successfully'