From 756cad73ae6c5ddb850e9de318dee1857a366bda Mon Sep 17 00:00:00 2001 From: Jonathan M Davis Date: Sat, 6 Apr 2024 07:42:44 -0600 Subject: [PATCH 1/2] 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. --- Makefile | 1 + build_v3.d | 38 +++++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 7a0f73e2e65..65c252451ff 100644 --- a/Makefile +++ b/Makefile @@ -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 ################################################################################ diff --git a/build_v3.d b/build_v3.d index 83c9be57bcd..f533bdf8362 100755 --- a/build_v3.d +++ b/build_v3.d @@ -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; @@ -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"); @@ -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."); @@ -69,7 +83,6 @@ int main(string[] args) { argFile.writeln("-main"); argFile.writeln("-unittest"); - argFile.writeln("-debug"); version(Windows) { @@ -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."); From 56ef5fba68b8f8b3d7a003362bb4a41dfe775533 Mon Sep 17 00:00:00 2001 From: Jonathan M Davis Date: Sat, 26 Oct 2024 03:37:02 -0600 Subject: [PATCH 2/2] Fix phobos.sys.meta example which is broken on 32-bit systems. --- phobos/sys/meta.d | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/phobos/sys/meta.d b/phobos/sys/meta.d index 1c31b67a72f..2b127d90e73 100644 --- a/phobos/sys/meta.d +++ b/phobos/sys/meta.d @@ -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;