1 module tests.it.runtime.issues;
2 
3 
4 import tests.it.runtime;
5 
6 
7 // reggae/dub build should rebuild if dub.json/sdl change
8 @("23")
9 @Tags(["dub", "make"])
10 unittest {
11 
12     import std.process: execute;
13     import reggae.path: buildPath;
14 
15     with(immutable ReggaeSandbox("dub")) {
16         runReggae("-b", "make", "--dflags=-g -debug");
17         make(["VERBOSE=1"]).shouldExecuteOk.shouldContain("-g -debug");
18         {
19             const ret = execute(["touch", buildPath(testPath, "dub.json")]);
20             ret.status.shouldEqual(0);
21         }
22         {
23             const ret = execute(["make", "-C", testPath]);
24             // don't assert on the status of ret - it requires rerunning reggae
25             // and that can fail if the reggae binary isn't built yet.
26             // Either way make should run
27             ret.output.shouldNotContain("Nothing to be done");
28         }
29     }
30 }
31 
32 
33 @("62")
34 @Tags(["dub", "make"])
35 unittest {
36     with(immutable ReggaeSandbox()) {
37         writeFile("dub.sdl", `
38             name "issue62"
39             dependency "arsd-official:nanovega" version="*"
40         `);
41         writeFile("source/app.d", q{
42                 import arsd.simpledisplay;
43                 import arsd.nanovega;
44                 void main () { }
45             }
46         );
47         runReggae("-b", "make");
48         make.shouldExecuteOk;
49         shouldSucceed("issue62");
50     }
51 }
52 
53 
54 @("73")
55 @Tags("issues", "ninja")
56 unittest {
57     with(immutable ReggaeSandbox()) {
58         writeFile("include/lib.h", `int twice(int i);`);
59         writeFile("src/lib.c", `
60             #include "lib.h"
61             int twice(int i) { return i * 2; }
62         `);
63         writeFile("reggaefile.d",
64                   q{
65                       import reggae;
66                       alias mylib = staticLibrary!(
67                           "mylib",
68                           Sources!("src"),
69                           Flags(),
70                           ImportPaths(["include"]),
71                       );
72                       mixin build!mylib;
73                   }
74         );
75         runReggae("-b", "ninja");
76         ninja.shouldExecuteOk;
77     }
78 }
79 
80 
81 
82 @("dubLink")
83 @Tags(["dub", "make"])
84 unittest {
85     with(immutable ReggaeSandbox()) {
86         writeFile("dub.sdl", `
87             name "dublink"
88         `);
89         writeFile("source/app.d", q{
90                 void main () { }
91             }
92         );
93         writeFile("reggaefile.d",
94                   q{
95                       import reggae;
96                       alias sourceObjs = dlangObjects!(Sources!"source");
97                       alias exe = dubLink!(TargetName("exe"), Configuration("default"), sourceObjs);
98                       mixin build!exe;
99                   });
100         runReggae("-b", "make");
101         make.shouldExecuteOk;
102         shouldSucceed("exe");
103     }
104 }
105 
106 
107 @("127.0")
108 @Tags("dub", "issues", "ninja")
109 unittest {
110 
111     with(immutable ReggaeSandbox()) {
112         writeFile("dub.sdl",
113             [
114                 `name "issue157"`,
115                 `targetType "executable"`,
116                 `targetPath "daspath"`
117             ]
118         );
119 
120         writeFile("source/app.d",
121             [
122                 `void main() {}`,
123             ]
124         );
125 
126         version(Windows) {
127             enum ut = `daspath\ut.exe`;
128             enum bin = `daspath\issue157.exe`;
129         } else {
130             enum ut = "daspath/ut";
131             enum bin = "daspath/issue157";
132         }
133 
134         runReggae("-b", "ninja");
135         ninja(["default", ut]).shouldExecuteOk;
136 
137         shouldExist(bin);
138         shouldExist(ut);
139     }
140 }
141 
142 
143 @("127.1")
144 @Tags("dub", "issues", "ninja")
145 unittest {
146 
147     import std.file: mkdir;
148 
149     with(immutable ReggaeSandbox()) {
150         writeFile("dub.sdl",
151             [
152                 `name "issue157"`,
153                 `targetType "executable"`,
154                 `targetPath "daspath"`
155             ]
156         );
157 
158         writeFile("source/app.d",
159             [
160                 `void main() {}`,
161             ]
162         );
163 
164         const bin = inSandboxPath("bin");
165         mkdir(bin);
166         runReggae("-C", bin, "-b", "ninja", testPath);
167         ninja(["-C", bin, "default", "ut"]).shouldExecuteOk;
168 
169         version(Windows) {
170             shouldExist(`bin\issue157.exe`);
171             shouldExist(`bin\ut.exe`);
172         } else {
173             shouldExist("bin/issue157");
174             shouldExist("bin/ut");
175         }
176     }
177 }
178 
179 
180 @("140")
181 @Tags("dub", "issues", "ninja")
182 unittest {
183 
184     import std.path: buildPath;
185 
186     with(immutable ReggaeSandbox()) {
187         writeFile("dub.sdl",
188             [
189                 `name "issue140"`,
190                 `targetType "executable"`,
191                 `targetPath "daspath"`,
192                 `dependency "bar" path="bar"`
193             ]
194         );
195 
196         writeFile("source/app.d",
197             [
198                 `void main() {}`,
199             ]
200         );
201 
202         writeFile(
203             "bar/dub.sdl",
204             [
205                 `name "bar"`,
206                 `copyFiles "$PACKAGE_DIR/txts/text.txt"`
207             ]
208         );
209         writeFile("bar/source/bar.d",
210             [
211                 `module bar;`,
212                 `int twice(int i) { return i * 2; }`,
213             ]
214         );
215 
216         writeFile("bar/txts/text.txt", "das text");
217 
218         runReggae("-b", "ninja");
219         ninja(["default"]).shouldExecuteOk;
220         shouldExist(buildPath("daspath", "text.txt"));
221     }
222 }
223 
224 
225 @("144")
226 @Tags("dub", "issues", "ninja")
227 unittest {
228 
229     import std.path: buildPath;
230 
231     with(immutable ReggaeSandbox()) {
232         writeFile("dub.sdl",
233             [
234                 `name "issue144"`,
235                 `targetType "executable"`,
236                 `configuration "default" {`,
237                 `}`,
238                 `configuration "daslib" {`,
239                 `    targetType "library"`,
240                 `    excludedSourceFiles "source/main.d"`,
241                 `}`,
242                 `configuration "weird" {`,
243                 `    targetName "weird"`,
244                 `    versions "weird"`,
245                 `}`,
246             ]
247         );
248 
249         writeFile("source/main.d",
250             [
251                 `void main() {}`,
252             ]
253         );
254 
255         writeFile("source/lib.d",
256             [
257                 `int twice(int i) { return i * 2; }`,
258             ]
259         );
260 
261         version(Windows) {
262             enum exe = "issue144.exe";
263             enum lib = "issue144.lib";
264             enum ut  = "ut.exe";
265         } else {
266             enum exe = "issue144";
267             enum lib = "issue144.a";
268             enum ut  = "ut";
269         }
270 
271         runReggae("-b", "ninja", "--dub-config=daslib");
272 
273         ninja([lib]).shouldExecuteOk;
274         ninja([exe]).shouldFailToExecute.should ==
275             ["ninja: error: unknown target '" ~ exe ~ "', did you mean '" ~ lib ~ "'?"];
276         // No unittest target when --dub-config is used
277         ninja([ut]).shouldFailToExecute.should ==
278             ["ninja: error: unknown target '" ~ ut ~ "'"];
279     }
280 }