test-release.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 'mmgen'; [ -L 'node_tools' ] || ln -s "../$nt_repo/mmgen/node_tools" )
  39. ( cd $mm_repo && [ -L 'mmgen_node_tools' ] || ln -s "$orig_pwd/mmgen_node_tools" )
  40. (
  41. cd 'test/unit_tests_d'
  42. for fn in ../../$nt_repo/test/unit_tests_d/nt_*.py; do
  43. [ -L "$(basename $fn)" ] || ln -s "$fn"
  44. done
  45. )
  46. }
  47. run_unit_tests() {
  48. pecho 'Running unit tests:'
  49. $unit_tests_py --node-tools
  50. pecho 'Completed unit tests'
  51. }
  52. # start execution
  53. set -e
  54. becho 'Starting node tools test suite (WIP)'
  55. check_mmgen_repo || die "No MMGen repository found at $mm_repo!"
  56. cd $mm_repo
  57. create_links
  58. run_unit_tests
  59. becho 'Node tools test suite completed successfully'