Newer
Older
dub_jkp / test / issue895-local-configuration.sh
  1. #!/usr/bin/env bash
  2. . $(dirname "${BASH_SOURCE[0]}")/common.sh
  3.  
  4. if [ -e /var/lib/dub/settings.json ]; then
  5. die $LINENO 'Found existing system wide DUB configuration. Aborting.'
  6. fi
  7.  
  8. if [ -e ~/.dub/settings.json ]; then
  9. die $LINENO 'Found existing user wide DUB configuration. Aborting.'
  10. fi
  11.  
  12. cd ${CURR_DIR}
  13. mkdir -p ../etc/dub
  14. echo "{\"defaultCompiler\": \"foo\"}" > ../etc/dub/settings.json
  15. echo "Empty file named foo." > ../bin/foo
  16.  
  17. function cleanup {
  18. rm -r ../etc
  19. }
  20.  
  21. trap cleanup EXIT
  22.  
  23. if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Unknown compiler: $(dirname $CURR_DIR)/bin/foo"; then
  24. rm ../bin/foo
  25. die $LINENO 'DUB did not find the local configuration with an adjacent compiler.'
  26. fi
  27.  
  28. echo "{\"defaultCompiler\": \"$CURR_DIR/foo\"}" > ../etc/dub/settings.json
  29. mv ../bin/foo $CURR_DIR
  30.  
  31. if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Unknown compiler: $CURR_DIR/foo"; then
  32. rm $CURR_DIR/foo
  33. die $LINENO 'DUB did not find a locally-configured compiler with an absolute path.'
  34. fi
  35.  
  36. echo "{\"defaultCompiler\": \"~/.dub/foo\"}" > ../etc/dub/settings.json
  37. mv $CURR_DIR/foo ~/.dub/
  38.  
  39. if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Unknown compiler: "; then
  40. rm ~/.dub/foo
  41. die $LINENO 'DUB did not find a locally-configured compiler with a tilde-prefixed path.'
  42. fi
  43.  
  44. echo "{\"defaultCompiler\": \"\$DUB_BINARY_PATH/../foo\"}" > ../etc/dub/settings.json
  45. mv ~/.dub/foo ..
  46.  
  47. if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Unknown compiler: $(dirname $CURR_DIR)/bin/../foo"; then
  48. rm ../foo
  49. die $LINENO 'DUB did not find a locally-configured compiler with a DUB-relative path.'
  50. fi
  51.  
  52. echo "{\"defaultCompiler\": \"../foo\"}" > ../etc/dub/settings.json
  53.  
  54. if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "defaultCompiler specified in a DUB config file cannot use an unqualified relative path"; then
  55. rm ../foo
  56. die $LINENO 'DUB did not error properly for a locally-configured compiler with a relative path.'
  57. fi
  58.  
  59. rm ../etc/dub/settings.json
  60. echo "Empty file named ldc2." > ../bin/ldc2
  61.  
  62. if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Failed to invoke the compiler $(dirname $CURR_DIR)/bin/ldc2 to determine the build platform"; then
  63. rm ../bin/ldc2
  64. die $LINENO 'DUB did not find ldc2 adjacent to it.'
  65. fi
  66.  
  67. echo "{\"defaultCompiler\": \"foo\"}" > ../etc/dub/settings.json
  68. rm ../bin/ldc2
  69. export PATH=$(dirname $CURR_DIR)${PATH:+:$PATH}
  70.  
  71. if ! { ${DUB} describe --single issue103-single-file-package.d 2>&1 || true; } | grep -cF "Unknown compiler: foo"; then
  72. rm ../foo
  73. die $LINENO 'DUB did not find a locally-configured compiler in its PATH.'
  74. fi
  75.  
  76. rm ../foo