Newer
Older
dub_jkp / test / 0-init-interactive.sh
  1. #!/usr/bin/env bash
  2.  
  3. . $(dirname "${BASH_SOURCE[0]}")/common.sh
  4. packname="0-init-interactive"
  5.  
  6. function cleanup {
  7. rm -rf $packname
  8. }
  9.  
  10. function runTest {
  11. local inp=$1
  12. local comp=$2
  13. local dub_ext=${comp##*.}
  14. local outp=$(echo -e $inp | $DUB init $packname)
  15. if [ ! -e $packname/dub.$dub_ext ]; then # it failed
  16. cleanup
  17. die $LINENO "No dub.$dub_ext file has been generated for test $comp with input '$inp'. Output: $outp"
  18. fi
  19. if ! diff $packname/dub.$dub_ext "$CURR_DIR"/$comp; then
  20. cleanup
  21. die $LINENO "Contents of generated dub.$dub_ext not as expected."
  22. fi
  23. cleanup
  24. }
  25.  
  26. # sdl package format
  27. runTest '1\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl
  28. # select package format out of bounds
  29. runTest '3\n1\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl
  30. # select package format not numeric, but in list
  31. runTest 'sdl\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl
  32. # selected value not numeric and not in list
  33. runTest 'sdlf\n1\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.sdl
  34. # default name
  35. runTest '1\n\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.default_name.dub.sdl
  36. # json package format
  37. runTest '2\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.json
  38. # default package format
  39. runTest '\ntest\ndesc\nauthor\ngpl\ncopy\n\n' 0-init-interactive.dub.json
  40. # select license
  41. runTest '1\ntest\ndesc\nauthor\n6\n3\ncopy\n\n' 0-init-interactive.license_gpl3.dub.sdl
  42. # select license (with description)
  43. runTest '1\ntest\ndesc\nauthor\n9\n3\ncopy\n\n' 0-init-interactive.license_mpl2.dub.sdl
  44. # select license out of bounds
  45. runTest '1\ntest\ndesc\nauthor\n21\n6\n3\ncopy\n\n' 0-init-interactive.license_gpl3.dub.sdl
  46. # default license
  47. runTest '1\ntest\ndesc\nauthor\n\ncopy\n\n' 0-init-interactive.license_proprietary.dub.sdl