説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

runtest.sh 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/bash
  2. #
  3. # Usage : ./runtest [OPTIONS] [test_module[.test_class][ test_module2[.test_class2]...]
  4. #########
  5. #
  6. # Running all discoverables tests :
  7. # ./runtest
  8. #
  9. ################
  10. # -f, --failfast
  11. #
  12. # Stop the test run on the first error or failure.
  13. # -v --verbose
  14. #
  15. # higher verbosity
  16. #
  17. # -d 0 : results are not displayed but stored in logfiles in /tmp/logXXXXXXX repository, with XXXXXXX a timestamp (default)
  18. # -d 1 : results are displayed when tests finish and kept in logfiles in /tmp/logXXXXXXX repository, with XXXXXXX a timestamp
  19. # -d 2 : results are displayed when tests finish, they are not stored
  20. #
  21. # Furthermore
  22. ################
  23. # Most of the tests need an install of lodel for dependencies reasons
  24. # For those which not need, prefix the python file by 'nc_' (example nc_test_query.py)
  25. # they will be executed outside a lodel install
  26. # More details :
  27. ################
  28. #
  29. # https://docs.python.org/3.4/library/unittest.html
  30. #
  31. if test ! -f lodel/buildconf.py
  32. then
  33. echo "You have to build the project before running the tests"
  34. echo "See README"
  35. exit 1
  36. fi
  37. logdisplay=2;
  38. while getopts ":d:" opt; do
  39. case $opt in
  40. d)
  41. logdisplay=$OPTARG
  42. ;;
  43. :)
  44. echo "Option -$OPTARG requires an argument, as it does not have we assume 0"
  45. ;;
  46. esac
  47. done
  48. if [[ $logdisplay -eq 2 ]]
  49. then
  50. echo $logdisplay
  51. logdir=$(mktemp -td "lodel2_log_unittest_XXXXXXX")
  52. else
  53. if [ ! -d ./tmp ]
  54. then
  55. mkdir ./tmp
  56. fi
  57. timestamp=$(date +%s)
  58. logdir="$(dirname $(realpath $0))/tmp/log$timestamp"
  59. mkdir $logdir
  60. fi
  61. PYTHON='env python3'
  62. ret_status=0
  63. $PYTHON ./nocontext_tests.py $logdir $@ || ret_status=1
  64. ./runtest_context.sh $logdir $@ || ret_status=1
  65. if [[ $logdisplay -eq 1 || $logdisplay -eq 2 ]]
  66. then
  67. logfiles=$(ls $logdir)
  68. for logfile in $logfiles
  69. do
  70. cat $logdir/$logfile
  71. done
  72. if [[ $logdisplay -eq 2 ]]
  73. then
  74. rm -rf $logdir
  75. fi
  76. fi
  77. exit $ret_status