about summary refs log tree commit diff
path: root/pkgs/applications/window-managers/i3/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/window-managers/i3/default.nix')
-rw-r--r--pkgs/applications/window-managers/i3/default.nix47
1 files changed, 33 insertions, 14 deletions
diff --git a/pkgs/applications/window-managers/i3/default.nix b/pkgs/applications/window-managers/i3/default.nix
index 16dd2e6485e77..9b66a3279f8d3 100644
--- a/pkgs/applications/window-managers/i3/default.nix
+++ b/pkgs/applications/window-managers/i3/default.nix
@@ -1,8 +1,9 @@
 { fetchurl, lib, stdenv, pkg-config, makeWrapper, meson, ninja, installShellFiles, libxcb, xcbutilkeysyms
 , xcbutil, xcbutilwm, xcbutilxrm, libstartup_notification, libX11, pcre2, libev
 , yajl, xcb-util-cursor, perl, pango, perlPackages, libxkbcommon
-, xorgserver, xvfb-run
+, xorgserver, xvfb-run, xdotool, xorg, which
 , asciidoc, xmlto, docbook_xml_dtd_45, docbook_xsl, findXMLCatalogs
+, nixosTests
 }:
 
 stdenv.mkDerivation rec {
@@ -29,27 +30,42 @@ stdenv.mkDerivation rec {
     libstartup_notification libX11 pcre2 libev yajl xcb-util-cursor perl pango
     perlPackages.AnyEventI3 perlPackages.X11XCB perlPackages.IPCRun
     perlPackages.ExtUtilsPkgConfig perlPackages.InlineC
-    xorgserver xvfb-run
+  ] ++ lib.optionals doCheck [
+    xorgserver xvfb-run xdotool xorg.setxkbmap xorg.xrandr which
   ];
 
   configureFlags = [ "--disable-builddir" ];
 
   postPatch = ''
     patchShebangs .
+
+    # This testcase generates a Perl executable file with a shebang, and
+    # patchShebangs can't replace a shebang in the middle of a file.
+    if [ -f testcases/t/318-i3-dmenu-desktop.t ]; then
+      substituteInPlace testcases/t/318-i3-dmenu-desktop.t \
+        --replace-fail "#!/usr/bin/env perl" "#!${perl}/bin/perl"
+    fi
   '';
 
-  # Tests have been failing (at least for some people in some cases)
-  # and have been disabled until someone wants to fix them. Some
-  # initial digging uncovers that the tests call out to `git`, which
-  # they shouldn't, and then even once that's fixed have some
-  # perl-related errors later on. For more, see
-  # https://github.com/NixOS/nixpkgs/issues/7957
-  doCheck = false; # stdenv.hostPlatform.system == "x86_64-linux";
-
-  checkPhase = lib.optionalString (stdenv.hostPlatform.system == "x86_64-linux")
-  ''
-    (cd testcases && xvfb-run ./complete-run.pl -p 1 --keep-xserver-output)
-    ! grep -q '^not ok' testcases/latest/complete-run.log
+  # xvfb-run is available only on Linux
+  doCheck = stdenv.isLinux;
+
+  checkPhase = ''
+    test_failed=
+    # "| cat" disables fancy progress reporting which makes the log unreadable.
+    ./complete-run.pl -p 1 --keep-xserver-output | cat || test_failed="complete-run.pl returned $?"
+    if [ -z "$test_failed" ]; then
+      # Apparently some old versions of `complete-run.pl` did not return a
+      # proper exit code, so check the log for signs of errors too.
+      grep -q '^not ok' latest/complete-run.log && test_failed="test log contains errors" ||:
+    fi
+    if [ -n "$test_failed" ]; then
+      echo "***** Error: $test_failed"
+      echo "===== Test log ====="
+      cat latest/complete-run.log
+      echo "===== End of test log ====="
+      false
+    fi
   '';
 
   postInstall = ''
@@ -63,6 +79,9 @@ stdenv.mkDerivation rec {
 
   separateDebugInfo = true;
 
+  passthru.tests = { inherit (nixosTests) i3wm; };
+
+
   meta = with lib; {
     description = "Tiling window manager";
     homepage    = "https://i3wm.org";