Skip to content

Commit 756cad7

Browse files
committed
Add the Phobos v3 unit tests to the regular unittest build.
I'm sure that we'll need to rework the build stuff at some point here (both for Phobos v2 and v3), but this gets the v3 tests run by the v2 Makefile so that the CI will build and run them.
1 parent 354781f commit 756cad7

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ else
337337
unittest : unittest-debug unittest-release
338338
unittest-%:
339339
$(MAKE) unittest OS=$(OS) MODEL=$(MODEL) DMD=$(DMD) BUILD=$*
340+
DMD=$(DMD) $(DMD) -run build_v3.d unittest-$*
340341
endif
341342

342343
################################################################################

build_v3.d

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
Phobos V3 Build Script
44
55
Usage:
6-
./build_v3.d [debug,release,unittest]
6+
./build_v3.d [debug|release|unittest|unittest-debug|unittest-release]
7+
8+
Environment Variables:
9+
DMD=[/path/to/compiler]
710
*/
811

912
import std.conv;
@@ -18,12 +21,23 @@ int main(string[] args)
1821
{
1922
int result = 0;
2023

24+
immutable compiler = environment.get("DMD", "dmd").buildNormalizedPath();
25+
2126
bool buildUnittest = false;
2227
bool buildRelease = false;
23-
if (args.length > 1)
28+
29+
if(args.length > 1)
2430
{
25-
buildUnittest = args[1] == "unittest";
26-
buildRelease = args[1] == "release";
31+
switch(args[1])
32+
{
33+
case "release": buildRelease = true; break;
34+
// This should be changed to run the tests in both debug and release
35+
// modes, but that's a larger change.
36+
case "unittest": buildUnittest = true; break;
37+
case "unittest-debug": buildUnittest = true; break;
38+
case "unittest-release": buildUnittest = true; goto case "release";
39+
default: break;
40+
}
2741
}
2842

2943
string argFilePath = buildNormalizedPath(getcwd(), "phobosbuildargs.txt");
@@ -47,7 +61,7 @@ int main(string[] args)
4761
if (exists(unittestExecutable)) remove(unittestExecutable);
4862
}
4963

50-
result = runCommand("dmd --version", getcwd());
64+
result = runCommand(format("%s --version", compiler), getcwd());
5165
if (result != 0)
5266
{
5367
writeln("Compiler Failure.");
@@ -69,7 +83,6 @@ int main(string[] args)
6983
{
7084
argFile.writeln("-main");
7185
argFile.writeln("-unittest");
72-
argFile.writeln("-debug");
7386

7487
version(Windows)
7588
{
@@ -80,24 +93,19 @@ int main(string[] args)
8093
argFile.writeln("-of=unittest");
8194
}
8295
}
83-
else if (buildRelease)
84-
{
85-
argFile.writeln("-release -O");
86-
argFile.writeln("-lib");
87-
argFile.writeln("-of=libphobos3");
88-
}
8996
else
9097
{
91-
argFile.writeln("-debug");
9298
argFile.writeln("-lib");
93-
argFile.writeln("-of=libphobos3-debug");
99+
argFile.writefln("-of=libphobos3%s", buildRelease ? "" : "-debug");
94100
}
95101

102+
argFile.writeln(buildRelease ? "-release -O" : "-debug");
103+
96104
argFile.flush();
97105
argFile.close();
98106

99107
//Run the build.
100-
result = runCommand("dmd @\"" ~ argFilePath ~ "\"", getcwd());
108+
result = runCommand(format(`%s @"%s"`, compiler, argFilePath), getcwd());
101109
if (result != 0)
102110
{
103111
writeln("Build failed.");

0 commit comments

Comments
 (0)