From 4aca2de09370c5bb2244592926d84d0dba9bd3a8 Mon Sep 17 00:00:00 2001 From: Jonas Meeuws Date: Fri, 13 Mar 2026 19:54:02 +0100 Subject: gnu: dmd: Reinstate phobos tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/packages/dlang.scm (dmd-bootstrap) [#:disallowed-references]: Add tzdata-for-tests. [#:test-target]: Remove. [#:phases]: Remove commented out zoneinfo path patch. Reinstate commented out libcurl path patch. : Disable an unittest from ‘std.process’. : Override ‘#:test-target’. : Override ‘#:test-target’. [inputs]: Add curl. [native-inputs]: Add tzdata-for-tests. {patches}: Add “dmd-phobos-support-TZDIR.patch”. (dmd)[#:disallowed-references]: Add tzdata-for-tests. * gnu/packages/patches/dmd-phobos-support-TZDIR.patch: New file. * gnu/local.mk (dist_patch_DATA): Add the patch. Signed-off-by: Liliana Marie Prikler --- gnu/local.mk | 1 + gnu/packages/dlang.scm | 41 ++++++++++++--------- .../patches/dmd-phobos-support-TZDIR.patch | 42 ++++++++++++++++++++++ 3 files changed, 67 insertions(+), 17 deletions(-) create mode 100644 gnu/packages/patches/dmd-phobos-support-TZDIR.patch (limited to 'gnu') diff --git a/gnu/local.mk b/gnu/local.mk index d99bf29551e..836a8d60200 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1209,6 +1209,7 @@ dist_patch_DATA = \ %D%/packages/patches/directfb-davinci-glibc-228-compat.patch \ %D%/packages/patches/django-compressor-build-with-beautifulsoup-4.14+.patch \ %D%/packages/patches/dkimproxy-add-ipv6-support.patch \ + %D%/packages/patches/dmd-phobos-support-TZDIR.patch \ %D%/packages/patches/doc++-gcc-14.patch \ %D%/packages/patches/docbook-utils-documentation-edits.patch \ %D%/packages/patches/docbook-utils-escape-characters.patch \ diff --git a/gnu/packages/dlang.scm b/gnu/packages/dlang.scm index 112c6cbf9c3..38f756b3833 100644 --- a/gnu/packages/dlang.scm +++ b/gnu/packages/dlang.scm @@ -357,13 +357,12 @@ integration tests...\n") (build-system gnu-build-system) (arguments (list - #:disallowed-references (list (gexp-input (canonical-package gcc) - "lib")) + #:disallowed-references (list (gexp-input (canonical-package gcc) "lib") + tzdata-for-tests) ;; Disable tests, as gdmd cannot cope with some arguments used such as ;; '-conf'. #:tests? #f #:out-of-source? #t - #:test-target "test" #:make-flags #~(list (string-append "CC=" #$(cc-for-target)) (string-append "HOST_CXX=" #$(cxx-for-target)) @@ -389,7 +388,8 @@ integration tests...\n") (append args '#$extra-args)))))) (target-file (lambda (pkg-name path) (file-append (this-package-input pkg-name) path))) - (target-bin-sh (target-file "bash-minimal" "/bin/sh"))) + (target-bin-sh (target-file "bash-minimal" "/bin/sh")) + (target-lib-curl (target-file "curl" "/lib/libcurl.so"))) #~(modify-phases %standard-phases (replace 'unpack (lambda* (#:key source #:allow-other-keys) @@ -418,12 +418,9 @@ integration tests...\n") (add-after 'unpack 'patch-paths-in-phobos (lambda _ (with-directory-excursion "phobos" - ;; (substitute* "std/datetime/timezone.d" - ;; (("\"/usr/share/zoneinfo/\"") - ;; (format #f "~s" target-zoneinfo))) - ;; (substitute* "std/net/curl.d" - ;; (("\"libcurl\\.so\"") - ;; (format #f "~s" target-lib-curl))) + (substitute* "std/net/curl.d" + (("\"libcurl\\.so\"") + (format #f "~s" #$target-lib-curl))) (substitute* "std/process.d" (("return \"/bin/sh\";") (format #f "return ~s;" #$target-bin-sh)) @@ -472,7 +469,13 @@ integration tests...\n") "long_backtrace_trunc rt_trap_exceptions ")) "")) (substitute* "dmd/druntime/test/gc/Makefile" - ((" invariant ") " ")))) + ((" invariant ") " ")) + + ;; Skip a std.process unittest that fails due to "kill" not + ;; working properly in the build environment. + (substitute* "phobos/std/process.d" + (("^.*sleep.*10000" all) + (string-append " return;\n" all))))) (delete 'bootstrap) (delete 'configure) (replace 'build @@ -489,9 +492,11 @@ integration tests...\n") (string-append "DMD=" dmd) make-flags)))))) (replace 'check - #$(wrap-in-directory-excursion "dmd" 'check)) + #$(wrap-in-directory-excursion "dmd" 'check + #:test-target "test")) (add-after 'check 'check-phobos - #$(wrap-in-directory-excursion "phobos" 'check)) + #$(wrap-in-directory-excursion "phobos" 'check + #:test-target "unittest")) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let* ((platform (cond (#$(target-linux?) "linux"))) @@ -536,10 +541,11 @@ integration tests...\n") ;; Phobos license is identical. #$(wrap-in-directory-excursion "dmd" 'install-license-files)))))) (inputs - (list bash-minimal)) + (list curl ; std.net.curl + bash-minimal)) ; std.process (native-inputs (list gdmd which - gdb/pinned ; for tests + gdb/pinned tzdata-for-tests ; for tests (origin (method git-fetch) (uri (git-reference @@ -548,7 +554,8 @@ integration tests...\n") (file-name (git-file-name "phobos" version)) (sha256 (base32 - "1ydls3ar6d3f7ffqvidr46x3zrz3wlzjln5qa0nbz843ndjr4g7n"))))) + "1ydls3ar6d3f7ffqvidr46x3zrz3wlzjln5qa0nbz843ndjr4g7n")) + (patches (search-patches "dmd-phobos-support-TZDIR.patch"))))) (outputs '("out" "lib" "debug")) (synopsis "Reference D Programming Language compiler") (description "@acronym{DMD, Digital Mars D compiler} is the reference @@ -573,7 +580,7 @@ compiler for the D programming language.") '(#:tests?) ;reinstate tests (package-arguments dmd-bootstrap)) ((#:disallowed-references _ ''()) - (list dmd-bootstrap)) + (list dmd-bootstrap tzdata-for-tests)) ((#:make-flags flags ''()) #~(fold delete #$flags '("HOST_DMD=gdmd" "SHARED=0"))) diff --git a/gnu/packages/patches/dmd-phobos-support-TZDIR.patch b/gnu/packages/patches/dmd-phobos-support-TZDIR.patch new file mode 100644 index 00000000000..62a2a7ea2d6 --- /dev/null +++ b/gnu/packages/patches/dmd-phobos-support-TZDIR.patch @@ -0,0 +1,42 @@ +commit 957d704139d6430fcce7e5b0d7058572f220ab09 +Author: Jonas Meeuws +Date: Thu Mar 12 01:27:34 2026 +0100 + + std.datetime.timezone: Support the TZDIR environment variable on POSIX. + +diff --git a/std/datetime/timezone.d b/std/datetime/timezone.d +index 6a1898b0e..4e7b1f95b 100644 +--- a/std/datetime/timezone.d ++++ b/std/datetime/timezone.d +@@ -2033,7 +2033,15 @@ public: + } + else version (Posix) + { +- enum defaultTZDatabaseDir = "/usr/share/zoneinfo/"; ++ static nothrow ++ string defaultTZDatabaseDir() ++ { ++ import std.exception : assumeWontThrow; ++ import std.process : environment; ++ return environment ++ .get("TZDIR", "/usr/share/zoneinfo/") ++ .assumeWontThrow; // nothrow on POSIX ++ } + } + else version (Windows) + { +@@ -2455,11 +2463,13 @@ public: + // RefCounted variable, but here, no references to the payload is + // escaped to the outside, so this should be @trusted + () @trusted { +- foreach (DirEntry de; dirEntries(tzDatabaseDir, SpanMode.depth)) ++ foreach (DirEntry de; dirEntries(tzDatabaseDir, SpanMode.depth, false)) + { + if (de.isFile) + { + auto tzName = de.name[tzDatabaseDir.length .. $]; ++ if (tzName.startsWith("/")) ++ tzName = tzName[1 .. $]; + + if (!tzName.extension().empty || + !tzName.startsWith(subName) || -- cgit v1.2.3