Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

runtest.sh 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. # Options
  10. ################
  11. # -f, --failfast
  12. #
  13. # Stop the test run on the first error or failure.
  14. # -v --verbose
  15. #
  16. # higher verbosity
  17. #
  18. # -d 0 : results are not displayed but stored in logfiles in /tmp/logXXXXXXX repository, with XXXXXXX a timestamp (default)
  19. # -d 1 : results are displayed when tests finish and kept in logfiles in /tmp/logXXXXXXX repository, with XXXXXXX a timestamp
  20. # -d 2 : results are displayed when tests finish, they are not stored
  21. #
  22. # More details :
  23. ################
  24. #
  25. # https://docs.python.org/3.4/library/unittest.html
  26. #
  27. if test ! -f lodel/buildconf.py
  28. then
  29. echo "You have to build the project before running the tests"
  30. echo "See README"
  31. exit 1
  32. fi
  33. logdisplay=2;
  34. while getopts ":d:" opt; do
  35. case $opt in
  36. d)
  37. logdisplay=$OPTARG
  38. ;;
  39. :)
  40. echo "Option -$OPTARG requires an argument, as it does not have we assume 0"
  41. ;;
  42. esac
  43. done
  44. if [[ $logdisplay -eq 2 ]]
  45. then
  46. echo $logdisplay
  47. logdir=$(mktemp -td "lodel2_log_unittest_XXXXXXX")
  48. else
  49. if [ ! -d ./tmp ]
  50. then
  51. mkdir ./tmp
  52. fi
  53. timestamp=$(date +%s)
  54. logdir="$(dirname $(realpath $0))/tmp/log$timestamp"
  55. mkdir $logdir
  56. fi
  57. PYTHON='env python3'
  58. $PYTHON ./nocontext_tests.py $logdir $@
  59. ./runtest_context.sh $logdir $@
  60. if [[ $logdisplay -eq 1 || $logdisplay -eq 2 ]]
  61. then
  62. logfiles=$(ls $logdir)
  63. for logfile in $logfiles
  64. do
  65. more $logdir/$logfile
  66. done
  67. if [[ $logdisplay -eq 2 ]]
  68. then
  69. rm -rf $logdir
  70. fi
  71. fi