Comments (4)
A perusal of File.pm does indeed show it doesn't actually test to make sure the file tests are actually against .... files.
Well, if you come from a Unix background, you're used to the philosophy of "everything is a file": a device is a file, a socket is a file, a symlink is a flle, and, ultimately, a directory is a file too. In later versions of Unixoid systems, directories have diverged from files more significantly, but I'm old enough to remember when you could actually cat
a directory. ;-> Of course, in Windows-world, a file and a directory were always completely different animals.
Now, all that having been said: While I don't think it's necessarily a good thing in general for file tests to refuse to work on directories, I do agree that this particular one could be a surprising result. Even more suprising is that, as far as this test is concerned, a directory is never empty: if you run it on a newly created directory, it still says "ok." I suppose that even a fresh directory contains .
and ..
, so in that sense it's not empty, but it still feels a bit wonky.
But, then, what should it do? Should a directory fail both the file_empty_ok
test and the file_not_empty_ok
test (sort of like a NULL
in SQL)? Should it perhaps throw some sort of "don't use file tests on a directory" exception? I'm not entirely sure.
Ultimately this has to be brian d foy's call. I just wanted to weigh in and point out that the answers are not as obvious as one might think. ;->
from test-file.
I've added a test diagnostic message to each of the functions where a directory might be inappropriate. This gives me some time to warn people that these functions might later disallow these things.
from test-file.
I've been thinking a lot about this one, and I'm going to deprecate directories as arguments for these. This basically punts the problem to the future. I'll see what turns up if people get these deprecation messages.
from test-file.
So this is now in v1.991 and I'll see who complains. There have been warnings for a couple years and I haven't heard anyone complain, so we might be good.
If there are more problems, someone can respond to this issue to re-open it, or start a new issue.
from test-file.
Related Issues (17)
- Request for feature: dir_exists_ok HOT 2
- symlink_target_is_absolute_ok HOT 3
- Test::README Overwrites File From Test-MockObject HOT 6
- [PATCH] After the removal of cwd from @INC t/setup_common is not found. HOT 3
- can not install using CPANPLUS 0.9160, perl 5.10.1 HOT 4
- Test::Manifest changes which tests run HOT 1
- Tests fail on some cygwin systems HOT 3
- Mismatching license HOT 1
- Tests fails on Windows 10, MSYS2
- Documentation mentions non-existent package Test2::Tool::File HOT 2
- Test::File does not account for user names that are only numbers HOT 5
- Failed test 'file_mtime_lt_ok success works' HOT 2
- Request for feature: file_contains_ok HOT 7
- t\links.t on systems that support symlink but when current user is not allowed (Windows case) HOT 13
- Check file contents in utf8 or other encoding HOT 6
- Would you welcome merge for file_mtime_?_ok 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-file.