Comments (12)
1 would be EPERM instead of EISDIR.
I'm getting this on centos. What do you get?
$>perl -MFile::Temp=tempdir -e'my $t = tempdir( CLEANUP => 1 ); unlink $t; print "Got: " . ($! +0) . " - $!\n"'
Got: 21 - Is a directory
Is it possible your /tmp is setup wrong or that $TMP is set to something funny?
from test-mockfile.
I have now a truss log of a failed run. The interesting lines:
71712: 0.356629683 0.000124038 mkdir("/tmp/7EjVXM5y2G",0700) = 0 (0x0)
71712: 0.356824121 0.000006146 stat("/tmp/7EjVXM5y2G",{ mode=drwx------ ,inode=81848,size=512,blksize=32768 }) = 0 (0x0)
71712: 0.367991462 0.000013130 unlink("/tmp/7EjVXM5y2G") ERR#1 'Operation not permitted'
That's correct, unlink on directories is forbidden. From the unlink(2) manpage:
[EPERM] The named file is a directory.
from test-mockfile.
I'm trying to decide how big of a problem this is going to be. If it's going to be a frequent problem, then I have to determine what these values will be at Makfile.PL time and then bake it into the module.
My other option would be to do a one off exception for $^X eq 'freebsd' but it sounds like you're saying only very specific versions of freebsd behave this way?
from test-mockfile.
Let's try 1e18f8a for a fix in 0.012
from test-mockfile.
Hmmm, I still get the same errors in 0.012.
And it seems that this problem is not freebsd-specific --- the same failure happens also on other BSD systems (NetBSD), and even Debian with FreeBSD kernel (see http://matrix.cpantesters.org/?dist=Test-MockFile%200.011 ). Also, there are no reports at all for recent Test-MockFile versions on darwin --- I guess it could happen there, too.
from test-mockfile.
BTW, the oneliner above prints also errno 21 on a FreeBSD 13 system with perl 5.26.2:
$ perl -MFile::Temp=tempdir -e'my $t = tempdir( CLEANUP => 1 ); warn "about to unlink\n"; unlink $t; warn "Got: " . ($! +0) . " - $!\n"'
about to unlink
Got: 21 - Is a directory
But the truss log is interesting:
59591: 0.215535940 0.000123740 write(2,"about to unlink\n",16) = 16 (0x10)
59591: 0.215628960 0.000020820 fstatat(AT_FDCWD,"/tmp/rpFZl9wT6c",{ mode=drwx------ ,inode=212,size=2,blksize=131072 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
59591: 0.215732180 0.000035070 fstatat(AT_FDCWD,"/usr/share/nls/C/libc.cat",0x7fffffffe340,0x0) ERR#2 'No such file or directory'
59591: 0.215795310 0.000018940 fstatat(AT_FDCWD,"/usr/share/nls/libc/C",0x7fffffffe340,0x0) ERR#2 'No such file or directory'
59591: 0.215857350 0.000020320 fstatat(AT_FDCWD,"/usr/local/share/nls/C/libc.cat",0x7fffffffe340,0x0) ERR#2 'No such file or directory'
59591: 0.215917220 0.000018780 fstatat(AT_FDCWD,"/usr/local/share/nls/libc/C",0x7fffffffe340,0x0) ERR#2 'No such file or directory'
59591: 0.216081980 0.000097270 write(2,"Got: 21 - Is a directory\n",25) = 25 (0x19)
So it looks like unlink()
isn't called at all, but only a stat
call instead; maybe the result of this call is inspected and turned into an "artificial" errno 21.
from test-mockfile.
The behavior changed between perl 5.18 and 5.20. On a freebsd 9 system:
for i in /usr/perl*/bin/perl; do env LC_ALL=C $i -MFile::Temp=tempdir -e'my $t = tempdir( CLEANUP => 1 ); unlink $t; warn "$]: Got: " . ($! +0) . " - $!\n"'; done
5.010001: Got: 1 - Operation not permitted
5.014004: Got: 1 - Operation not permitted
5.016003: Got: 1 - Operation not permitted
5.018002: Got: 1 - Operation not permitted
5.020000: Got: 21 - Is a directory
5.008009: Got: 1 - Operation not permitted
And on a freebsd 10 system:
for i in /usr/perl*/bin/perl; do env LC_ALL=C $i -MFile::Temp=tempdir -e'my $t = tempdir( CLEANUP => 1 ); unlink $t; warn "$]: Got: " . ($! +0) . " - $!\n"'; done
5.018004: Got: 1 - Operation not permitted
5.020001: Got: 21 - Is a directory
5.020001: Got: 21 - Is a directory
5.020002: Got: 21 - Is a directory
5.020003: Got: 21 - Is a directory
5.022000: Got: 21 - Is a directory
5.022001: Got: 21 - Is a directory
5.022002: Got: 21 - Is a directory
5.022002: Got: 21 - Is a directory
5.022003: Got: 21 - Is a directory
5.022004: Got: 21 - Is a directory
5.024000: Got: 21 - Is a directory
5.024001: Got: 21 - Is a directory
5.024002: Got: 21 - Is a directory
5.024003: Got: 21 - Is a directory
5.026000: Got: 21 - Is a directory
5.026001: Got: 21 - Is a directory
5.027010: Got: 21 - Is a directory
5.027011: Got: 21 - Is a directory
5.027006: Got: 21 - Is a directory
5.027007: Got: 21 - Is a directory
5.027008: Got: 21 - Is a directory
5.027009: Got: 21 - Is a directory
5.028000: Got: 21 - Is a directory
from test-mockfile.
Also, there are no reports at all for recent Test-MockFile versions on darwin --- I guess it could happen there, too.
Yes. EPERM is also returned on Mac systems with system perl (currently 5.18.2), see https://travis-ci.org/eserte/sandbox/jobs/456396139
Test script was: https://github.com/eserte/sandbox/blob/daea395b488369cc935392025ebc3f75927e2cfe/t/unlink-dir.t#L19
from test-mockfile.
Yeah this was just a test. I’ve already concluded that I’m going to have to template the module before install
from test-mockfile.
I think the final fix for this is 4ee9f77 It would have helped had I had access to BSD ¯_(ツ)_/¯
from test-mockfile.
There are test changes but the entirety of the fix is basically this conditional. https://github.com/CpanelInc/Test-MockFile/blob/master/lib/Test/MockFile.pm#L625
from test-mockfile.
0.016 looks good on (almost) all of my FreeBSD & darwin systems. The "almost" is a different issue.
I think this issue may be closed.
from test-mockfile.
Related Issues (20)
- Only show files within the directory HOT 2
- Setting time for a file does not change the time for a directory
- strict mode does not understand open with two args HOT 5
- Clean up the tests to remove localized error strings ($!) HOT 1
- Failing tests HOT 1
- Document how to allow loading the debugger
- t/readline.t fails on freebsd
- t/runtime-bareword-filehandles.t fails (sometimes) on 5.16.3
- Provide a way to mock a whole dir or tree.
- Test::MockFile symlinks does not play nice with Cwd... HOT 1
- Test::MockFile corrupts glob
- chmod() should ignore filehandle arguments HOT 2
- utime() isn’t covered in strict mode
- File::Temp::tempfile() in scalar context should create an unlinked file.
- Failed test '$! is EINVAL for a readlink(undef)'
- binmode is unimplemented - cannot use File::Copy with Test::MockFile HOT 2
- Home directory isn't properly supported
- Spooky action-at-a-distance
- add_strict_rule_for_command: support for scalar usage in addition to RegEx
- When a mocked directories contents change the mocked parent directly mtime should also be updated. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from test-mockfile.