Perl-Toolchain-Gang / ExtUtils-Manifest

Utilities to write and check a MANIFEST file
https://metacpan.org/release/ExtUtils-Manifest/
Other
4 stars 7 forks source link

Manifest.t fails on AFS file system #39

Open djzhh opened 4 months ago

djzhh commented 4 months ago

Test #93 fails on AFS filesystems, as on AFS chmod does not have any effect. Compilation with files located locally works though. Tested using perl-5.36.3 and perl-5.38.2.

The test must fail as there is no such thing as file-based ACLs in AFS; see https://docs.openafs.org/UserGuide/HDRWQ46.html

make test
PERL_DL_NONLAZY=1 "../../perl" "-I../../lib" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, '../../lib', '../../lib')" t/*.t
t/Manifest.t .. 1/98
#   Failed test 'maniadd() dies if it can't open the MANIFEST'
#   at t/Manifest.t line 468.
#                   ''
#     doesn't match '(?^:^maniadd\(\)\ could\ not\ open\ MANIFEST\:)'
# Looks like you failed 1 test of 98.
t/Manifest.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/98 subtests

Test Summary Report
-------------------
t/Manifest.t (Wstat: 256 (exited 1) Tests: 98 Failed: 1)
  Failed test:  93
  Non-zero exit status: 1
Files=1, Tests=98,  0 wallclock secs ( 0.02 usr  0.01 sys +  0.08 cusr  0.05 csys =  0.16 CPU)
Result: FAIL
Failed 1/1 test programs. 1/98 subtests failed.
make: *** [Makefile:787: test_dynamic] Error 1

Part of test code:

    456 SKIP: {
    457     chmod( 0400, 'MANIFEST' );
    458     skip "Can't make MANIFEST read-only", 2 if -w 'MANIFEST' or $Config{osname} eq 'cygwin';
    459
    460     eval {
    461         maniadd({ 'foo' => 'bar' });
    462     };
    463     is( $@, '',  "maniadd() won't open MANIFEST if it doesn't need to" );
    464
    465     eval {
    466         maniadd({ 'grrrwoof' => 'yippie' });
    467     };
    468     like( $@, qr/^\Qmaniadd() could not open MANIFEST:\E/,
    469                  "maniadd() dies if it can't open the MANIFEST" );
    470
    471     chmod( 0600, 'MANIFEST' );
    472 }

Setting the test file to read-only using chmod 0400 will not provoke any error, which (so it seems to me) is expected in line 468. See the behaviour of AFS below:

% systemctl status afs.mount
● afs.mount - /afs
     Loaded: loaded (/proc/self/mountinfo)
     Active: active (mounted) since Fri 2024-01-19 13:28:15 CET; 1 month 16 days ago
      Until: Fri 2024-01-19 13:28:15 CET; 1 month 16 days ago
      Where: /afs
       What: AFS

% mkdir demo
% cd demo

% fs listacl -path .
Access list for . is
Normal rights:
  username rlidwka
  system:administrators rlidwka
  system:anyuser l

% echo Hello World > a_file

% ls -ld a_file
-rw-r--r--. 1 username grp 12 Mar  6 02:34 a_file

% cat a_file
Hello World

% chmod 0000 a_file

% ls -ld a_file
----------. 1 username grp 12 Mar  6 02:34 a_file

% getfacl a_file
# file: a_file
# owner: username
# group: grp
user::---
group::---
other::---

% cat a_file
Hello World

% echo "Have a nice day" >> a_file

% cat a_file
Hello World
Have a nice day

Perhaps a workaround analog to https://github.com/pmqs/IO-Compress/issues/56#issuecomment-1980388117 would be a solution.

djzhh commented 4 months ago

I had a look at https://github.com/tonycoz/perl5/commit/ddb756c358e14d22cc474e2a9925455716e45b36, a solution for https://github.com/Perl/perl5/issues/22067 , perhaps this might be a solution:

*** old/cpan/ExtUtils-Manifest/t/Manifest.t 2023-11-28 12:57:27.000000000 +0100
--- new/cpan/ExtUtils-Manifest/t/Manifest.t       2024-03-12 15:28:55.000000000 +0100
*************** is_deeply( $files, \%expect, 'maniadd()
*** 454,460 ****
  #maniadd({ foo => 'bar' });

  SKIP: {
!     chmod( 0400, 'MANIFEST' );
      skip "Can't make MANIFEST read-only", 2 if -w 'MANIFEST' or $Config{osname} eq 'cygwin';

      eval {
--- 454,464 ----
  #maniadd({ foo => 'bar' });

  SKIP: {
!       require Config;
!       require File::Spec;
!       my $Curdir = File::Spec->curdir;
!       skip "AFS", 2
!       if $Config{afs} eq "true" && ($Curdir eq '.' || $Curdir =~ /^\Q$Config{afsroot}/);chmod( 0400, 'MANIFEST' );
      skip "Can't make MANIFEST read-only", 2 if -w 'MANIFEST' or $Config{osname} eq 'cygwin';

      eval {

The require Config; may be obsolete, though.