spamassassin: enable tests

This commit is contained in:
Luke Granger-Brown 2023-06-25 13:37:18 +00:00
parent 16663f620a
commit 6c161ee4b9
3 changed files with 66 additions and 2 deletions

View file

@ -1,4 +1,4 @@
{ lib, fetchurl, perlPackages, makeWrapper, gnupg, re2c, gcc, gnumake, libxcrypt }:
{ lib, fetchurl, perlPackages, makeWrapper, gnupg, re2c, gcc, gnumake, libxcrypt, coreutils, poppler_utils, tesseract, iana-etc }:
perlPackages.buildPerlPackage rec {
pname = "SpamAssassin";
@ -9,6 +9,11 @@ perlPackages.buildPerlPackage rec {
hash = "sha256-5aoXBQowvHK6qGr9xgSMrepNHsLsxh14dxegWbgxnog=";
};
patches = [
./satest-no-clean-path.patch
./sa_compile-use-perl5lib.patch
];
nativeBuildInputs = [ makeWrapper ];
buildInputs = (with perlPackages; [
HTMLParser NetCIDRLite NetDNS NetAddrIP DBFile HTTPDate MailDKIM LWP
@ -24,7 +29,25 @@ perlPackages.buildPerlPackage rec {
makeMakerFlags = [ "SYSCONFDIR=/etc LOCALSTATEDIR=/var/lib/spamassassin" ];
doCheck = false;
checkInputs = (with perlPackages; [
TextDiff # t/strip2.t
]) ++ [
coreutils # date, t/basic_meta.t
poppler_utils # pdftotext, t/extracttext.t
tesseract # tesseract, t/extracttext.t
iana-etc # t/dnsbl_subtests.t (/etc/protocols used by Net::DNS::Nameserver)
re2c gcc gnumake
];
preCheck = ''
substituteInPlace t/spamc_x_e.t \
--replace "/bin/echo" "${coreutils}/bin/echo"
export C_INCLUDE_PATH='${lib.makeSearchPathOutput "include" "include" [ libxcrypt ]}'
export HARNESS_OPTIONS="j''${NIX_BUILD_CORES}"
export HOME=$NIX_BUILD_TOP/home
mkdir -p $HOME
mkdir t/log # pre-create to avoid race conditions
'';
postInstall = ''
mkdir -p $out/share/spamassassin

View file

@ -0,0 +1,23 @@
diff -ru orig/t/sa_compile.t new/t/sa_compile.t
--- orig/t/sa_compile.t 2022-12-14 06:03:26.000000000 +0000
+++ new/t/sa_compile.t 2023-06-25 12:30:39.735577152 +0000
@@ -40,7 +40,7 @@
# we now have an "installed" version we can run sa-compile with. Ensure
# sarun() will use it appropriately
-$scr = "$instdir/$temp_binpath/spamassassin";
+$scr = "$perl_cmd -T $instdir/$temp_binpath/spamassassin";
$scr_localrules_args = $scr_cf_args = ""; # use the default rules dir, from our "install"
&set_rules('
@@ -86,8 +86,8 @@
# -------------------------------------------------------------------
rmtree( glob "~/.spamassassin/sa-compile.cache". { safe => 1 }); # reset test
-system_or_die "TMP=$instdir TMPDIR=$instdir $instdir/$temp_binpath/sa-compile --quiet -p $cwd/$workdir/user.cf --keep-tmps -D 2>$instdir/sa-compile.debug"; # --debug
-$scr = "$instdir/$temp_binpath/spamassassin";
+system_or_die "TMP=$instdir TMPDIR=$instdir $perl_cmd -T $instdir/$temp_binpath/sa-compile --quiet -p $cwd/$workdir/user.cf --keep-tmps -D 2>$instdir/sa-compile.debug"; # --debug
+$scr = "$perl_cmd -T $instdir/$temp_binpath/spamassassin";
$scr_localrules_args = $scr_cf_args = ""; # use the default rules dir, from our "install"
%patterns = (

View file

@ -0,0 +1,18 @@
diff -ru orig/t/SATest.pm new/t/SATest.pm
--- orig/t/SATest.pm 2023-06-25 11:26:27.663204415 +0000
+++ new/t/SATest.pm 2023-06-25 11:34:08.902174669 +0000
@@ -65,9 +65,12 @@
# Clean PATH so taint doesn't complain
if (!$RUNNING_ON_WINDOWS) {
- $ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
+ # untaint PATH
+ $ENV{'PATH'} =~ /^(.+)$/;
+ $ENV{'PATH'} = $1;
+ # $ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
# Remove tainted envs, at least ENV used in FreeBSD
- delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
+ # delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
} else {
# Windows might need non-system directories in PATH to run a Perl installation
# The best we can do is clean out obviously bad stuff such as relative paths or \..\