Bug 7005 - sa_compile.t test failures with MacPorts' perl
Summary: sa_compile.t test failures with MacPorts' perl
Status: REOPENED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Building & Packaging (show other bugs)
Version: 3.4.0
Hardware: Macintosh Mac OS X
: P2 minor
Target Milestone: 4.0.0
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-11 22:16 UTC by Daniel J. Luke
Modified: 2019-06-15 20:35 UTC (History)
4 users (show)



Attachment Type Modified Status Actions Submitter/CLA Status
use Config to get path when non-standard sitebin is set patch None Daniel J. Luke [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel J. Luke 2014-02-11 22:16:28 UTC
MacPorts perl sets sitebin to ${prefix}/libexec/${perlversion}/sitebin [current default is /opt/local/libexec/perl5.12/sitebin], which causes sa_compile.t to not be able to find spamassasin and sa-compile. I manually modified sa_compile.t for my local installation and verified that the tests pass.

While I personally don't like MacPorts' approach here, the test should probably handle this situation.

I can probably provide a patch that uses Config to pull the appropriate path info, if desired (it should be fairly trivial to add $Config{sitebinexp}).
Comment 1 Kevin A. McGrail 2014-02-11 22:29:18 UTC
Good to know the tests pass, thanks.  If you can help with a patch, that would be great.
Comment 2 Daniel J. Luke 2014-02-11 22:56:09 UTC
Created attachment 5184 [details]
use Config to get path when non-standard sitebin is set

This works for me (but obviously should get some review from at least people with more 'normal' perl installs).
Comment 3 Mark Martinec 2014-02-13 00:07:18 UTC
> Created attachment 5184 [details]
> use Config to get path when non-standard sitebin is set
> This works for me (but obviously should get some review from at least people
> with more 'normal' perl installs).

Sounds like a plan.

The s/// at line 10 should better take the $Config{prefix} literally
(i.e. quoted):

  s{^\Q$Config{prefix}\E/?}{}
Comment 4 Kevin A. McGrail 2014-02-20 19:46:01 UTC
Patch is pretty trivial and looks good to me.

svn commit -m 'Patch from Daniel J. Luke to use Config to get path when non-standard sitebin is set' 
Sending        t/sa_compile.t
Transmitting file data .
Committed revision 1570329..
Comment 5 Mark Martinec 2014-02-20 19:54:32 UTC
Bug 7005: sa_compile.t test failures with MacPorts' perl - safe quoting
  Sending t/sa_compile.t
Committed revision 1570334.
Comment 6 Kevin A. McGrail 2015-05-01 17:11:38 UTC
See bug 7181.  This patch breaks prove -v t/sa_compile.t on source install of SA 3.4.1 on a Debian 7.4 box.

Daniel, any thoughts on this?
Comment 7 Bill Cole 2015-05-02 03:59:10 UTC
I think the problem is/was with more than one directory. Running 'port -d test p5.16-mail-spamassassin' with 3.4.0 fails in t/sa_compile.t with this:

[...]
a Mail-SpamAssassin-3.4.0/build/parse-rules-for-masses
a Mail-SpamAssassin-3.4.0/build/preprocessor
a Mail-SpamAssassin-3.4.0/build/sha1sum.pl
cannot write /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_perl_p5-mail-spamassassin/p5.16-mail-spamassassin/work/Mail-SpamAssassin-3.4.0/t/log/d.sa_compile/inst.basic/foo/etc/mail/spamassassin/v330.pre at t/sa_compile.t line 85.
t/sa_compile.t .................... Dubious, test returned 2 (wstat 512, 0x200)
Failed 5/5 subtests 

While the same command after cleaning & updating the Portfile to fetch and build 3.4.1 yields this:

[...]
a Mail-SpamAssassin-3.4.1/build/parse-rules-for-masses
a Mail-SpamAssassin-3.4.1/build/preprocessor
a Mail-SpamAssassin-3.4.1/build/sha1sum.pl
sa-compile: cannot write to /var/opt/spamassassin/compiled/5.016/3.004001, aborting
'/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_perl_p5-mail-spamassassin/p5.16-mail-spamassassin/work/Mail-SpamAssassin-3.4.1/t/log/d.sa_compile/inst.basic/foo//libexec/perl5.16/sitebin/sa-compile --keep-tmps' failed: exit 2 at t/SATest.pm line 991.
t/sa_compile.t .................... 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 3/5 subtests 


Note that 3.4.1 apparently gets further (2 tests passed) and is for some reason trying to write in /var/opt/spamassassin, *WHICH SHOULDN'T EXIST*

If you actually use MacPorts to install either version -- both of which do work -- the fact that MacPorts sets LOCALSTATEDIR=/opt/local/var/spamassassin to build the Makefile means that you get:

# ls -l /opt/local/var/spamassassin/
total 0
drwxr-xr-x  3 root  admin  136 Jul 13  2014 3.003002
drwxr-xr-x  3 root  admin  136 Apr 23 12:49 3.004000
drwxr-xr-x  3 root  admin  136 May  1 18:55 3.004001
drwxr-xr-x  3 root  admin  102 May  1 23:35 compiled

But this hint isn't making it to the test rig. The "MakeMaker ARGV" line in the Makefile created in sa_compile.t is a smoking gun. 

In short: replace line 129 of t/sa_compile.t with something that doesn't assume PREFIX is the only directory anyone will customize.
Comment 8 Daniel J. Luke 2015-05-04 15:57:00 UTC
(In reply to Kevin A. McGrail from comment #6)
> See bug 7181.  This patch breaks prove -v t/sa_compile.t on source install
> of SA 3.4.1 on a Debian 7.4 box.
> 
> Daniel, any thoughts on this?

Note that I don't use MacPorts perl anymore (or have a debian box around to test with), but looking at what sitebin is set to on a box where the test(s) are failing would probably be interesting.
Comment 9 Daniel J. Luke 2015-05-04 16:48:33 UTC
(In reply to Bill Cole from comment #7)
> In short: replace line 129 of t/sa_compile.t with something that doesn't
> assume PREFIX is the only directory anyone will customize.

I think you may have hit on something real (but probably shouldn't be in this bug report). Also, some/most of this can (and maybe should) be addressed in the MacPorts port (ie, even if the directory in the final error you posted was 'correct', MacPorts would still not be able to write in that directory as the test phase doesn't run as root by default).
Comment 10 Bill Cole 2015-05-05 13:28:58 UTC
OK, so I guess I should rephrase that more directly and less verbosely:

The test file t/sa_compile.t configures a complete build & installation of SA from scratch with a directory configuration that entirely ignores any installation directives of the build supposedly being tested other than a custom PREFIX. 

This is not a MacPorts issue. This is a logical problem with the test design, which explicitly avoids testing with 'make test' the SA build that 'make install' will in fact install. Bluntly: it's a test that tests itself and can't even pass that.
Comment 11 Daniel J. Luke 2015-05-05 13:36:01 UTC
(In reply to Bill Cole from comment #10)
> This is not a MacPorts issue. This is a logical problem with the test
> design, which explicitly avoids testing with 'make test' the SA build that
> 'make install' will in fact install. Bluntly: it's a test that tests itself
> and can't even pass that.

so you chose to mention this in an old bug about using sitebin in the test? This isn't my bug tracker, but I would think it would be better for you to open a new bug (and maybe include a patch if possible).
Comment 12 Bill Cole 2015-05-05 20:07:28 UTC
(In reply to Daniel J. Luke from comment #11)

> so you chose to mention this in an old bug about using sitebin in the test?

I admit to being excessively influenced by Kevin re-opening this ticket and by the fact that with the patch, both 3.4.0 and 3.4.1 fail in t/sa_compile.t if $prefix starts with /opt (as for MacPorts) unless /etc/opt and /var/opt are creatable by or exist and are writable by the user running the test. 

> This isn't my bug tracker, but I would think it would be better for you to
> open a new bug (and maybe include a patch if possible).

Done: Bug 7188
Comment 13 Kevin A. McGrail 2015-05-05 20:28:30 UTC
(In reply to Bill Cole from comment #12)
> I admit to being excessively influenced by Kevin re-opening this ticket and
> by the fact that with the patch, both 3.4.0 and 3.4.1 fail in t/sa_compile.t
> if $prefix starts with /opt (as for MacPorts) unless /etc/opt and /var/opt
> are creatable by or exist and are writable by the user running the test. 

submitting a patch is a good way to get me to forgive most transgressions ;-)

Bill, can you look at submitting a CLA? http://www.apache.org/licenses/
Comment 14 Kevin A. McGrail 2018-09-03 04:46:22 UTC
Minor issue targeting for 3.4.3