diff --git a/test/0-init-fail-json.script.d b/test/0-init-fail-json.script.d new file mode 100644 index 0000000..d629385 --- /dev/null +++ b/test/0-init-fail-json.script.d @@ -0,0 +1,36 @@ +/+ dub.sdl: + name "0-init-fail-json" + dependency "common" path="./common" + +/ + +module _0_init_fail_json; + +import std.file : exists, remove; +import std.path : buildPath; +import std.process : environment, spawnProcess, wait; + +import common; + +int main() +{ + enum packname = "0-init-fail-pack"; + enum deps = "logger PACKAGE_DONT_EXIST"; // would be very unlucky if it does exist... + + auto dub = environment.get("DUB"); + if (!dub.length) + die(`Environment variable "DUB" must be defined to run the tests.`); + + //** if $$DUB init -n $packname $deps -f json 2>/dev/null; then + if (!spawnProcess([dub, "init", "-n", packname, deps, "-f", "json"]).wait) + die("Init with unknown non-existing dependency expected to fail"); + + //** if [ -e $packname/dub.json ]; then # package is there, it should have failed + const filepath = buildPath(packname, "dub.json"); + if (filepath.exists) + { + remove(packname); + die(filepath ~ " was not created"); + } + + return 0; +} diff --git a/test/0-init-fail-json.sh b/test/0-init-fail-json.sh deleted file mode 100755 index 069014e..0000000 --- a/test/0-init-fail-json.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -. $(dirname "${BASH_SOURCE[0]}")/common.sh -packname="0-init-fail-pack" -deps="logger PACKAGE_DONT_EXIST" # would be very unlucky if it does exist... - -if $$DUB init -n $packname $deps -f json 2>/dev/null; then - die $LINENO 'Init with unknown non-existing dependency expected to fail' -fi - - -function cleanup { - rm -rf $packname -} - -if [ -e $packname/dub.json ]; then # package is there, it should have failed - cleanup - die $LINENO "$packname/dub.json was not created" -fi