Newer
Older
dub_jkp / test / issue1574-addcommand.sh
@Sebastian Wilzbach Sebastian Wilzbach on 31 Jan 2019 1 KB Add dub fetch <package>:<version> shortcut
  1. #!/usr/bin/env bash
  2. DIR=$(dirname "${BASH_SOURCE[0]}")
  3.  
  4. . "$DIR"/common.sh
  5.  
  6. PORT=$(($$ + 1024)) # PID + 1024
  7. tempDir="issue1574-addcommand"
  8.  
  9. "$DUB" build --single "$DIR"/test_registry.d
  10. "$DIR"/test_registry --folder="$DIR/issue1336-registry" --port=$PORT &
  11. PID=$!
  12. sleep 1
  13.  
  14. function cleanup {
  15. cd ..
  16. rm -rf $tempDir
  17. kill $PID 2>/dev/null || true
  18. }
  19. trap cleanup EXIT
  20.  
  21.  
  22. $DUB init --non-interactive --format=json $tempDir
  23. cd $tempDir
  24.  
  25. echo "import gitcompatibledubpackage.subdir.file; void main(){}" > source/app.d
  26. $DUB add gitcompatibledubpackage --skip-registry=all --registry=http://localhost:$PORT
  27. grep -q '"gitcompatibledubpackage"\s*:\s*"~>1\.0\.4"' dub.json
  28. $DUB add gitcompatibledubpackage=1.0.2 non-existing-issue1574-pkg='~>9.8.7' --skip-registry=all
  29. grep -q '"gitcompatibledubpackage"\s*:\s*"1\.0\.2"' dub.json
  30. grep -q '"non-existing-issue1574-pkg"\s*:\s*"~>9\.8\.7"' dub.json
  31. if $DUB add foo@1.2.3 gitcompatibledubpackage='~>a.b.c' --skip-registry=all; then
  32. die $LINENO 'Adding non-semver spec should error'
  33. fi
  34. if grep -q '"foo"' dub.json; then
  35. die $LINENO 'Failing add command should not write recipe file'
  36. fi