i3: fix and reenable testsuite

The `checkPhase` script was stale and needed to be rewritten for the new
version of i3 (paths are different now, and `complete-run.pl` now
invokes `xvfb-run` internally).  The code to check the log file for
errors might be unneeded for the new version (`complete-run.pl` seems to
return a non-zero exit code correctly on errors), but is left to catch
any possible regressions in the test runner behavior.

Also the `318-i3-dmenu-desktop.t` testcase was failing, because that
testcase was creating a temporary Perl script intended to shadow the
real `i3-msg` executable, but the `#!/usr/bin/env perl` shebang in that
script did not work in the build environment; this problem was not
really obvious, because `system('i3-msg', $cmd)` silently continued to
search for the `i3-msg` executable further in `$PATH` and launched the
real binary instead of the replacement script.  The problematic shebang
needed to be replaced manually, because `patchShebangs` handles only
real shebangs on the first line of each executable file.
This commit is contained in:
Sergey Vlasov 2024-03-10 22:20:04 +03:00 committed by Franz Pletz
parent f20ebb1201
commit b934fad58c
No known key found for this signature in database
GPG Key ID: 846FDED7792617B4

View File

@ -36,20 +36,32 @@ stdenv.mkDerivation rec {
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.
substituteInPlace testcases/t/318-i3-dmenu-desktop.t \
--replace-fail "#!/usr/bin/env perl" "#!${perl}/bin/perl"
'';
# 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";
doCheck = 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
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 = ''