test-release.sh 1.7 KB

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