Newer
Older
dub_jkp / test / run-unittest.sh
@Martin Nowak Martin Nowak on 18 Oct 2015 1 KB allow to specify ddox tool
  1. #!/bin/bash
  2.  
  3. function log() {
  4. echo -e "\033[0;33m[INFO] "$@"\033[0m"
  5. }
  6.  
  7. function logError() {
  8. echo -e 1>&2 "\033[0;31m"$@"\033[0m"
  9. any_errors=1
  10. }
  11.  
  12. function die() {
  13. logError "$@"
  14. exit 1
  15. }
  16.  
  17. export -f log
  18. export -f die
  19.  
  20. if [ -z ${DUB} ]; then
  21. die 'Error: Variable $DUB must be defined to run the tests.'
  22. fi
  23.  
  24. if [ -z ${DC} ]; then
  25. log '$DC not defined, assuming dmd...'
  26. DC=dmd
  27. fi
  28.  
  29. CURR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
  30.  
  31. for script in $(ls $CURR_DIR/*.sh); do
  32. if [ "$script" = "$(readlink -f ${BASH_SOURCE[0]})" ]; then continue; fi
  33. if [ -e $script.min_frontend ] && [ ! -z "$FRONTEND" -a "$FRONTEND" \< $(cat $script.min_frontend) ]; then continue; fi
  34. log "Running $script..."
  35. DUB=$DUB DC=$DC CURR_DIR="$CURR_DIR" $script || logError "Script failure."
  36. done
  37.  
  38. for pack in $(ls -d $CURR_DIR/*/); do
  39. if [ -e $pack/.min_frontend ] && [ ! -z "$FRONTEND" -a "$FRONTEND" \< $(cat $pack/.min_frontend) ]; then continue; fi
  40. # First we build the packages
  41. if [ ! -e $pack/.no_build ]; then # For sourceLibrary
  42. if [ -e $pack/.fail_build ]; then
  43. log "Building $pack, expected failure..."
  44. $DUB build --force --root=$pack --compiler=$DC 2>/dev/null && logError "Error: Failure expected, but build passed."
  45. else
  46. log "Building $pack..."
  47. $DUB build --force --root=$pack --compiler=$DC || logError "Build failure."
  48. fi
  49. fi
  50.  
  51. # We run the ones that are supposed to be runned
  52. if [ ! -e $pack/.no_build ] && [ ! -e $pack/.no_run ]; then
  53. log "Running $pack..."
  54. $DUB run --force --root=$pack --compiler=$DC || logError "Run failure."
  55. fi
  56.  
  57. # Finally, the unittest part
  58. if [ ! -e $pack/.no_build ] && [ ! -e $pack/.no_test ]; then
  59. log "Testing $pack..."
  60. $DUB test --force --root=$pack --compiler=$DC || logError "Test failure."
  61. fi
  62. done
  63.  
  64. exit $any_errors