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