No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

runtest.sh 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. export PYTHONPATH="$PYTHONPATH:$(pwd)"
  62. PYTHON="env python3"
  63. ret_status=0
  64. $PYTHON ./nocontext_tests.py $logdir $@ || ret_status=1
  65. ./runtest_context.sh $logdir $@ || ret_status=1
  66. if [[ $logdisplay -eq 1 || $logdisplay -eq 2 ]]
  67. then
  68. logfiles=$(ls $logdir)
  69. for logfile in $logfiles
  70. do
  71. cat $logdir/$logfile
  72. done
  73. if [[ $logdisplay -eq 2 ]]
  74. then
  75. rm -rf $logdir
  76. fi
  77. fi
  78. exit $ret_status