Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Phobos v3 unit tests to the regular unittest build. #8972

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ else
unittest : unittest-debug unittest-release
unittest-%:
$(MAKE) unittest OS=$(OS) MODEL=$(MODEL) DMD=$(DMD) BUILD=$*
DMD=$(DMD) $(DMD) -run build_v3.d unittest-$*
endif

################################################################################
Expand Down
38 changes: 23 additions & 15 deletions build_v3.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
Phobos V3 Build Script

Usage:
./build_v3.d [debug,release,unittest]
./build_v3.d [debug|release|unittest|unittest-debug|unittest-release]

Environment Variables:
DMD=[/path/to/compiler]
*/

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

immutable compiler = environment.get("DMD", "dmd").buildNormalizedPath();

bool buildUnittest = false;
bool buildRelease = false;
if (args.length > 1)

if(args.length > 1)
{
buildUnittest = args[1] == "unittest";
buildRelease = args[1] == "release";
switch(args[1])
{
case "release": buildRelease = true; break;
// This should be changed to run the tests in both debug and release
// modes, but that's a larger change.
case "unittest": buildUnittest = true; break;
case "unittest-debug": buildUnittest = true; break;
case "unittest-release": buildUnittest = true; goto case "release";
default: break;
}
}

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

result = runCommand("dmd --version", getcwd());
result = runCommand(format("%s --version", compiler), getcwd());
if (result != 0)
{
writeln("Compiler Failure.");
Expand All @@ -69,7 +83,6 @@ int main(string[] args)
{
argFile.writeln("-main");
argFile.writeln("-unittest");
argFile.writeln("-debug");

version(Windows)
{
Expand All @@ -80,24 +93,19 @@ int main(string[] args)
argFile.writeln("-of=unittest");
}
}
else if (buildRelease)
{
argFile.writeln("-release -O");
argFile.writeln("-lib");
argFile.writeln("-of=libphobos3");
}
else
{
argFile.writeln("-debug");
argFile.writeln("-lib");
argFile.writeln("-of=libphobos3-debug");
argFile.writefln("-of=libphobos3%s", buildRelease ? "" : "-debug");
}

argFile.writeln(buildRelease ? "-release -O" : "-debug");

argFile.flush();
argFile.close();

//Run the build.
result = runCommand("dmd @\"" ~ argFilePath ~ "\"", getcwd());
result = runCommand(format(`%s @"%s"`, compiler, argFilePath), getcwd());
if (result != 0)
{
writeln("Build failed.");
Expand Down
5 changes: 2 additions & 3 deletions phobos/sys/meta.d
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,13 @@ private template AppendIfUnique(alias Cmp, Args...)
///
@safe unittest
{
alias Types = AliasSeq!(int, uint, long, string, short, int*, ushort);
alias Types = AliasSeq!(int, uint, long, short, int*, ushort);

template sameSize(T)
{
enum sameSize(U) = T.sizeof == U.sizeof;
}
static assert(is(Unique!(sameSize, Types) ==
AliasSeq!(int, long, string, short)));
static assert(is(Unique!(sameSize, Types) == AliasSeq!(int, long, short)));

// The predicate must be partially instantiable.
enum sameSize_fails(T, U) = T.sizeof == U.sizeof;
Expand Down
Loading