Newer
Older
dub_jkp / test / 0-init-fail-json.script.d
@drug007 drug007 on 1 Mar 2021 949 bytes Convert one bash script test to D script
  1. /+ dub.sdl:
  2. name "0-init-fail-json"
  3. dependency "common" path="./common"
  4. +/
  5.  
  6. module _0_init_fail_json;
  7.  
  8. import std.file : exists, remove;
  9. import std.path : buildPath;
  10. import std.process : environment, spawnProcess, wait;
  11.  
  12. import common;
  13.  
  14. int main()
  15. {
  16. enum packname = "0-init-fail-pack";
  17. enum deps = "logger PACKAGE_DONT_EXIST"; // would be very unlucky if it does exist...
  18.  
  19. auto dub = environment.get("DUB");
  20. if (!dub.length)
  21. die(`Environment variable "DUB" must be defined to run the tests.`);
  22.  
  23. //** if $$DUB init -n $packname $deps -f json 2>/dev/null; then
  24. if (!spawnProcess([dub, "init", "-n", packname, deps, "-f", "json"]).wait)
  25. die("Init with unknown non-existing dependency expected to fail");
  26.  
  27. //** if [ -e $packname/dub.json ]; then # package is there, it should have failed
  28. const filepath = buildPath(packname, "dub.json");
  29. if (filepath.exists)
  30. {
  31. remove(packname);
  32. die(filepath ~ " was not created");
  33. }
  34.  
  35. return 0;
  36. }