about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTobias Mayer <tobim@fastmail.fm>2023-08-11 16:01:43 +0200
committerTobias Mayer <tobim@fastmail.fm>2023-08-13 17:57:19 +0200
commit70cea510a8027b94bf9aa396fad767f8d47c07a8 (patch)
tree81e7c49735d8b732ccc0dbbc0146e238729a0dae
parentd53bdba34547fe019f081d3a452260905b4ab002 (diff)
glog: disable broken test under clang
-rw-r--r--pkgs/development/libraries/glog/default.nix32
1 files changed, 28 insertions, 4 deletions
diff --git a/pkgs/development/libraries/glog/default.nix b/pkgs/development/libraries/glog/default.nix
index a64bb0967aa7b..85e9770f989e3 100644
--- a/pkgs/development/libraries/glog/default.nix
+++ b/pkgs/development/libraries/glog/default.nix
@@ -19,24 +19,48 @@ stdenv.mkDerivation rec {
 
   cmakeFlags = [
     "-DBUILD_SHARED_LIBS=ON"
+    # glog's custom FindUnwind.cmake module detects LLVM's unwind in case
+    # stdenv.cc is clang. But the module doesn't get installed, causing
+    # consumers of the CMake config file to fail at the configuration step.
+    # Explicitly disabling unwind support sidesteps the issue.
+    "-DWITH_UNWIND=OFF"
   ];
 
-  # TODO: Re-enable Darwin tests once we're on a release that has https://github.com/google/glog/issues/709#issuecomment-960381653 fixed
-  doCheck = !stdenv.isDarwin;
+  doCheck = true;
+
   # There are some non-thread safe tests that can fail
   enableParallelChecking = false;
   nativeCheckInputs = [ perl ];
 
-  GTEST_FILTER =
+  env.GTEST_FILTER =
     let
       filteredTests = lib.optionals stdenv.hostPlatform.isMusl [
         "Symbolize.SymbolizeStackConsumption"
         "Symbolize.SymbolizeWithDemanglingStackConsumption"
       ] ++ lib.optionals stdenv.hostPlatform.isStatic [
         "LogBacktraceAt.DoesBacktraceAtRightLineWhenEnabled"
+      ] ++ lib.optionals stdenv.cc.isClang [
+        # Clang optimizes an expected allocation away.
+        # See https://github.com/google/glog/issues/937
+        "DeathNoAllocNewHook.logging"
+      ] ++ lib.optionals stdenv.isDarwin [
+        "LogBacktraceAt.DoesBacktraceAtRightLineWhenEnabled"
+      ];
+    in
+    "-${builtins.concatStringsSep ":" filteredTests}";
+
+  checkPhase =
+    let
+      excludedTests = lib.optionals stdenv.isDarwin [
+        "mock-log"
       ];
+      excludedTestsRegex = lib.optionalString (excludedTests != [ ]) "(${lib.concatStringsSep "|" excludedTests})";
     in
-    lib.optionalString doCheck "-${builtins.concatStringsSep ":" filteredTests}";
+    ''
+      runHook preCheck
+      ctest -E "${excludedTestsRegex}" --output-on-failure
+      runHook postCheck
+    '';
 
   meta = with lib; {
     homepage = "https://github.com/google/glog";