diff --git a/test/dub-as-a-library-cwd.sh b/test/dub-as-a-library-cwd.sh new file mode 100755 index 0000000..e0faea2 --- /dev/null +++ b/test/dub-as-a-library-cwd.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +. $(dirname "${BASH_SOURCE[0]}")/common.sh +$DUB --root="$CURR_DIR/dub-as-a-library-cwd" diff --git a/test/dub-as-a-library-cwd/.gitignore b/test/dub-as-a-library-cwd/.gitignore new file mode 100644 index 0000000..9a2c0e8 --- /dev/null +++ b/test/dub-as-a-library-cwd/.gitignore @@ -0,0 +1 @@ +/dub-as-a-library-cwd diff --git a/test/dub-as-a-library-cwd/.no_test b/test/dub-as-a-library-cwd/.no_test new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/dub-as-a-library-cwd/.no_test diff --git a/test/dub-as-a-library-cwd/dub.json b/test/dub-as-a-library-cwd/dub.json new file mode 100644 index 0000000..15adddf --- /dev/null +++ b/test/dub-as-a-library-cwd/dub.json @@ -0,0 +1,8 @@ +{ + "name": "dub-as-a-library-cwd", + "dependencies": { + "dub": { + "path": "../.." + } + } +} diff --git a/test/dub-as-a-library-cwd/source/app.d b/test/dub-as-a-library-cwd/source/app.d new file mode 100644 index 0000000..446c361 --- /dev/null +++ b/test/dub-as-a-library-cwd/source/app.d @@ -0,0 +1,45 @@ +import dub.compilers.buildsettings; +import dub.compilers.compiler; +import dub.dub; +import dub.generators.generator; +import dub.internal.vibecompat.inet.path; +import std.algorithm; +import std.file; +import std.path; +import std.stdio; + +void main(string[] args) +{ + auto project = buildNormalizedPath(getcwd, "subproject"); + chdir(buildNormalizedPath(getcwd, "..")); + + bool found; + + auto dub = new Dub(project, null, SkipPackageSuppliers.none); + dub.packageManager.getOrLoadPackage(NativePath(project)); + dub.loadPackage(); + dub.project.validate(); + + GeneratorSettings gs; + gs.buildType = "debug"; + gs.config = "application"; + gs.compiler = getCompiler(dub.defaultCompiler); + gs.run = false; + gs.force = true; + gs.tempBuild = true; + gs.platform = gs.compiler.determinePlatform(gs.buildSettings, + dub.defaultCompiler, dub.defaultArchitecture); + + gs.compileCallback = (status, output) { + found = output.canFind("FIND_THIS_STRING"); + if (!found) + stderr.writeln("Did not find required string!\nExit status:", + status, "\n\nOutput:\n", output); + }; + + stderr.writeln("Checking if building works from a library in a different cwd:"); + dub.generateProject("build", gs); + stderr.writeln("Success: ", found); + + assert(found); +} diff --git a/test/dub-as-a-library-cwd/subproject/dub.sdl b/test/dub-as-a-library-cwd/subproject/dub.sdl new file mode 100644 index 0000000..cb896c9 --- /dev/null +++ b/test/dub-as-a-library-cwd/subproject/dub.sdl @@ -0,0 +1 @@ +name "subproject" diff --git a/test/dub-as-a-library-cwd/subproject/source/app.d b/test/dub-as-a-library-cwd/subproject/source/app.d new file mode 100644 index 0000000..a891a6f --- /dev/null +++ b/test/dub-as-a-library-cwd/subproject/source/app.d @@ -0,0 +1,11 @@ +module app; + +deprecated("FIND_THIS_STRING") +void foo() +{ +} + +void main(string[] args) +{ + foo(); +}