1 module tests.it.dub;
2 
3 import unit_threaded;
4 
5 @("describe")
6 @Tags(["dub"])
7 unittest {
8 
9     import std.string: join;
10     import std.algorithm: find;
11     import std.format: format;
12     import std.process;
13 
14     const string[string] env = null;
15     Config config = Config.none;
16     size_t maxOutput = size_t.max;
17 
18     with(immutable Sandbox()) {
19         writeFile("dub.sdl",
20                   [
21                       `name "foo"`,
22                       `targetType "executable"`,
23                       `dependency "bar" path="bar"`,
24                       `versions "lefoo"`
25                   ].join("\n"));
26 
27         writeFile("source/app.d",
28                   [
29                       `void main() {`,
30                       `    import bar;`,
31                       `    lebar;`,
32                       `}`,
33                   ]);
34 
35         writeFile("bar/dub.sdl",
36                   [
37                       `name "bar"`,
38                       `targetType "library"`,
39                       ].join("\n"));
40 
41 
42         writeFile("bar/source/bar.d",
43                   [
44                       `module bar;`,
45                       `void lebar() {}`,
46                   ]);
47 
48         const ret = execute(["dub", "describe"], env, config, maxOutput, testPath);
49         if(ret.status != 0)
50             throw new Exception("Could not call dub describe:\n" ~ ret.output);
51 
52         ret.output.find("{").shouldBeSameJsonAs(
53             import("foobar.json").format(testPath, testPath, testPath, testPath, testPath,
54                                          testPath, testPath, testPath, testPath, testPath, testPath));
55     }
56 }