bmake: enable ksh test on non musl platforms

bmake runs the ksh test if /bin/ksh exists. This is never a good
indication on platforms where we can sandbox and causes problems on
darwin where this path may exist, but never would be in PATH.

We solve this problem by always enabling the test and adding ksh to
checkInputs.

ksh doesn't seem to compile with musl, so we disable it on that
platform.
This commit is contained in:
sternenseemann 2021-07-04 19:16:06 +02:00 committed by sterni
parent 32c42d37ab
commit 2019f82e3e
2 changed files with 24 additions and 3 deletions

View file

@ -1,5 +1,5 @@
{ lib, stdenv, fetchurl, fetchpatch
, getopt, tzdata
, getopt, tzdata, ksh
, pkgsMusl # for passthru.tests
}:
@ -14,9 +14,12 @@ stdenv.mkDerivation rec {
# Make tests work with musl
# * Disable deptgt-delete_on_error test (alpine does this too)
# * Disable shell-ksh test (ksh doesn't compile with musl)
# * Fix test failing due to different strerror(3) output for musl and glibc
postPatch = lib.optionalString (stdenv.hostPlatform.libc == "musl") ''
sed -i unit-tests/Makefile -e '/deptgt-delete_on_error/d'
sed -i unit-tests/Makefile \
-e '/deptgt-delete_on_error/d' \
-e '/shell-ksh/d'
substituteInPlace unit-tests/opt-chdir.exp --replace "File name" "Filename"
'';
@ -29,6 +32,8 @@ stdenv.mkDerivation rec {
./fix-unexport-env-test.patch
# Fix localtime tests without global /etc/zoneinfo directory
./fix-localtime-test.patch
# Always enable ksh test since it checks in a impure location /bin/ksh
./unconditional-ksh-test.patch
# decouple tests from build phase
(fetchpatch {
name = "separate-tests.patch";
@ -69,7 +74,11 @@ stdenv.mkDerivation rec {
'';
doCheck = true;
checkInputs = [ tzdata ];
checkInputs = [
tzdata
] ++ lib.optionals (stdenv.hostPlatform.libc != "musl") [
ksh
];
checkPhase = ''
runHook preCheck

View file

@ -0,0 +1,12 @@
--- bmake/unit-tests/Makefile.orig 2021-07-04 19:13:09.068094922 +0200
+++ bmake/unit-tests/Makefile 2021-07-04 19:13:14.630080696 +0200
@@ -295,9 +295,7 @@
TESTS+= sh-single-line
TESTS+= shell-csh
TESTS+= shell-custom
-.if exists(/bin/ksh)
TESTS+= shell-ksh
-.endif
TESTS+= shell-sh
TESTS+= suff-add-later
TESTS+= suff-clear-regular