Skip Menu |

This queue is for tickets about the File-HomeDir CPAN distribution.

Report information
The Basics
Id: 127609
Status: rejected
Priority: 0/
Queue: File-HomeDir

People
Owner: Nobody in particular
Requestors: GUIDO [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Test should not fail if directory does not exist
The fact that a location is well known, does not mean that it must exist or must be a directory. It's my home directory and my hard disk after all. My ~/Photos is on an external hard disk. The tests should really not fail while that device is not mounted. The module's original purpose was a portable way to locate a user's home directory. To fail, when the home directory of the user that runs the tests does not exist is probably legitimate. But what about making all other tests author tests that are not normally run for installation?
On Fri Nov 09 10:45:38 2018, GUIDO wrote: Show quoted text
> The fact that a location is well known, does not mean that it must > exist or must be a directory. It's my home directory and my hard disk > after all. > > My ~/Photos is on an external hard disk. The tests should really not > fail while that device is not mounted. > > The module's original purpose was a portable way to locate a user's > home directory. To fail, when the home directory of the user that runs > the tests does not exist is probably legitimate. > > But what about making all other tests author tests that are not > normally run for installation?
Seems to be kind-of duplicate of #110049. I do not agree that the test shouldn't fail. The test should fail, you as someone who is using software library telling other software about your home-directory layout need to know whether everything is as expected or not. And then, with that information, that it's not as expected, you can either ignore (install without tests) or provide a patch which ensures integrity in another way the maintainer didn't realize. OTOH: Use File::HomeDir::Tiny when you don't need the feature-rich File::HomeDir, it's much simpler and needs lesser tests ... Objections?
Am Fr 09. Nov 2018, 11:06:54, REHSACK schrieb: Show quoted text
> On Fri Nov 09 10:45:38 2018, GUIDO wrote: > Seems to be kind-of duplicate of #110049.
Sorry, I didn't search good enough, my bad. Show quoted text
> I do not agree that the test shouldn't fail. The test should fail, you > as someone who is using software library telling other software about > your home-directory layout need to know whether everything is as > expected or not.
Such directories can be removed or restored any time later. Likewise, they may become unreadable, the x bit may be unset, and so on. There are plenty of reasons why something can go wrong later. Show quoted text
> And then, with that information, that it's not as expected, you can > either ignore (install without tests) or provide a patch which ensures > integrity in another way the maintainer didn't realize.
Can you explain where you see an integrity issue if for example a blind person removes their directory ~/Photos? Yes, sorry, but it shows the point. Show quoted text
> > OTOH: Use File::HomeDir::Tiny when you don't need the feature-rich > File::HomeDir, it's much simpler and needs lesser tests ...
I don't use File::HomeDir directly. It's one of my dependencies. Show quoted text
> > Objections?
Yes. ;) A lot of these "standard" directories don't exist on my two machines, a Mac and a Gentoo laptop. I have deleted those that I don't need, and the Gentoo installation was done so long ago, that these directories had never been creaeted. I have never run into issues with that because even software on the Mac simply prompts for another location if the expected one is not available. And that's the way it should be. Furthermore, it is good practice to let _services_ run in as much isolation as possible. It's certainly not bad practice to give system users like "nginx" or "apache" their own private Perl environment. But does my nginx system user really need "~/My Music" or "~/My Documents"? Besides, the tests are run for the user that *builds* the software, not the one that uses it. When I install File::HomeDir with sudo and my vendor's Perl the tests succeed. When I install it with perlbrew they fail. The concept of a home directory is a well established standard. Dedicated directories for certain file types is nothing but a convention. Not even Apple or Microsoft enforce that convention. Why does a Perl module?
On Fri Nov 09 12:56:08 2018, GUIDO wrote: Show quoted text
> Am Fr 09. Nov 2018, 11:06:54, REHSACK schrieb:
> > On Fri Nov 09 10:45:38 2018, GUIDO wrote: > > Seems to be kind-of duplicate of #110049.
> > Sorry, I didn't search good enough, my bad. >
> > I do not agree that the test shouldn't fail. The test should fail, > > you > > as someone who is using software library telling other software about > > your home-directory layout need to know whether everything is as > > expected or not.
> > Such directories can be removed or restored any time later. Likewise, > they may become unreadable, the x bit may be unset, and so on. There > are plenty of reasons why something can go wrong later.
Sure. But you have one snapshot where it worked correctly - it was the time installing the module. So from there you can reconstruct ... Show quoted text
> > And then, with that information, that it's not as expected, you can > > either ignore (install without tests) or provide a patch which > > ensures > > integrity in another way the maintainer didn't realize.
> > Can you explain where you see an integrity issue if for example a > blind person removes their directory ~/Photos? Yes, sorry, but it > shows the point.
In such a case the module wouldn't simply install without extra effort (disable tests) and the failing test explain what was missing. So you can record this and at any later point in time when a software fails which requires the photos, you know - test failed, could be the missing photos. The module tests all it functions whether they work correctly or not. This ensures integrity of the implementation for the installed environment. Everything else would just be guessing ... Show quoted text
> > OTOH: Use File::HomeDir::Tiny when you don't need the feature-rich > > File::HomeDir, it's much simpler and needs lesser tests ...
> > I don't use File::HomeDir directly. It's one of my dependencies. >
> > > > Objections?
> > Yes. ;) > > A lot of these "standard" directories don't exist on my two machines, > a Mac and a Gentoo laptop. I have deleted those that I don't need, and > the Gentoo installation was done so long ago, that these directories > had never been creaeted. I have never run into issues with that > because even software on the Mac simply prompts for another location > if the expected one is not available. And that's the way it should be.
Then it's good that you run into those issues now. Your dependency decided for File::HomeDir for a good reason (hopefully) and trusts whether it works correctly. Show quoted text
> Furthermore, it is good practice to let _services_ run in as much > isolation as possible. It's certainly not bad practice to give system > users like "nginx" or "apache" their own private Perl environment. But > does my nginx system user really need "~/My Music" or "~/My > Documents"?
You shouldn't use File::HomeDir in a service which runs as an nginx service. That's insane. File::HomeDir is the wrong solution then. Show quoted text
> Besides, the tests are run for the user that *builds* the software, > not the one that uses it. When I install File::HomeDir with sudo and > my vendor's Perl the tests succeed. When I install it with perlbrew > they fail.
Without seeing the output and the tape archive of the tested environemnt, I can't say anything to that. Show quoted text
> The concept of a home directory is a well established standard. > Dedicated directories for certain file types is nothing but a > convention. Not even Apple or Microsoft enforce that convention. Why > does a Perl module?
Just because simply using $HOME is not enough. Showing the right name for Bilder (~/Photos) in i18n environments (or ~/Movies ...) is important. When you think you don't need all that Freedesktop specified locations, then File::HomeDir is the wrong answer for your question. Rethink your question, please.
Am Fr 09. Nov 2018, 13:14:10, REHSACK schrieb: Show quoted text
> On Fri Nov 09 12:56:08 2018, GUIDO wrote:
> > Am Fr 09. Nov 2018, 11:06:54, REHSACK schrieb:
> > > On Fri Nov 09 10:45:38 2018, GUIDO wrote:
> > Such directories can be removed or restored any time later. Likewise, > > they may become unreadable, the x bit may be unset, and so on. There > > are plenty of reasons why something can go wrong later.
> > Sure. But you have one snapshot where it worked correctly - it was the > time installing the module. So from there you can reconstruct ...
It always works correctly, whether the directory exists or not. A Unix user needs a home directory but it can be empty. In fact, not even the home directory has to exist. Show quoted text
> > Can you explain where you see an integrity issue if for example a > > blind person removes their directory ~/Photos? Yes, sorry, but it > > shows the point.
> > In such a case the module wouldn't simply install without extra effort > (disable tests) and the failing test explain what was missing.
"Failed test 'Our pictures directory exists'". I understood it after looking into the source code of the test. Show quoted text
> > The module tests all it functions whether they work correctly or not. > This ensures integrity of the implementation for the installed > environment. Everything else would just be guessing ...
The test checks whether the returned string is the name of a directory. Following your logic you would have to test that it's also readable and writable. Show quoted text
> > A lot of these "standard" directories don't exist on my two machines, > > a Mac and a Gentoo laptop. I have deleted those that I don't need, > > and > > the Gentoo installation was done so long ago, that these directories > > had never been creaeted. I have never run into issues with that > > because even software on the Mac simply prompts for another location > > if the expected one is not available. And that's the way it should > > be.
> > Then it's good that you run into those issues now. Your dependency > decided for File::HomeDir for a good reason (hopefully) and trusts > whether it works correctly.
Dist/Zilla.pm: require File::HomeDir; my $homedir = File::HomeDir->my_home or Carp::croak("couldn't determine home directory"); Where is the good reason? https://metacpan.org/requires/distribution/File-HomeDir?p=1&size=500&sort=%5B%5B2%2C1%5D%5D How many of these modules will not work if the user running it has no photos directory? Show quoted text
> > Furthermore, it is good practice to let _services_ run in as much > > isolation as possible. It's certainly not bad practice to give system > > users like "nginx" or "apache" their own private Perl environment. > > But > > does my nginx system user really need "~/My Music" or "~/My > > Documents"?
> > You shouldn't use File::HomeDir in a service which runs as an nginx > service. That's insane. File::HomeDir is the wrong solution then.
See the reverse dependency list above. File::HomeDir is depended on by too many other modules for that argument. Show quoted text
> > Besides, the tests are run for the user that *builds* the software, > > not the one that uses it. When I install File::HomeDir with sudo and > > my vendor's Perl the tests succeed. When I install it with perlbrew > > they fail.
> > Without seeing the output and the tape archive of the tested > environemnt, I can't say anything to that.
Run the test as root. It succeeds. But does your uid 0 have a photos directory? Tests for Perl modules are run on the *build* system. In the vast majority of cases, end users never run these tests. They just use the installed software. Show quoted text
> > The concept of a home directory is a well established standard. > > Dedicated directories for certain file types is nothing but a > > convention. Not even Apple or Microsoft enforce that convention. Why > > does a Perl module?
> > Just because simply using $HOME is not enough. Showing the right name > for Bilder (~/Photos) in i18n environments (or ~/Movies ...) is > important. When you think you don't need all that Freedesktop > specified locations, then File::HomeDir is the wrong answer for your > question.
Look at the reverse dependencies. Most of them have nothing to do with desktop applications. They use use File::HomeDir for getting the home directory. Show quoted text
> > Rethink your question, please.
I did. My point is that these tests fail for conditions that are not errors at all. File::HomeDir provides a portable way to get the default locations for certain file types. If a software - whether it's using File::HomeDir or not - breaks just because such a location does not exist under certain conditions, then that software has a serious flaw. ENOENT and ENOTDIR are just two out of many error conditions and errors are there to be caught. Maybe we just disagree? I also think that testing whether a file exists before opening it is a waste of time and a recipe for races. Then it's only natural that I don't see the point in testing whether a certain file exists on the build system for the build user at build time.
On Fri Nov 09 14:10:38 2018, GUIDO wrote: Show quoted text
> Am Fr 09. Nov 2018, 13:14:10, REHSACK schrieb:
> > On Fri Nov 09 12:56:08 2018, GUIDO wrote:
> > > Am Fr 09. Nov 2018, 11:06:54, REHSACK schrieb:
> > > > On Fri Nov 09 10:45:38 2018, GUIDO wrote:
> > > Such directories can be removed or restored any time later. > > > Likewise, > > > they may become unreadable, the x bit may be unset, and so on. > > > There > > > are plenty of reasons why something can go wrong later.
> > > > Sure. But you have one snapshot where it worked correctly - it was > > the > > time installing the module. So from there you can reconstruct ...
> > It always works correctly, whether the directory exists or not. A Unix > user needs a home directory but it can be empty. In fact, not even the > home directory has to exist.
But you cannot verify whether it works or not until you prove. Because the approval can fail for many reasons, the success is unfortunately the only reasonable one. Unless you have a new argument, this chapter is closed. Show quoted text
> > > Can you explain where you see an integrity issue if for example a > > > blind person removes their directory ~/Photos? Yes, sorry, but it > > > shows the point.
> > > > In such a case the module wouldn't simply install without extra > > effort > > (disable tests) and the failing test explain what was missing.
> > "Failed test 'Our pictures directory exists'". I understood it after > looking into the source code of the test.
Fair enough. Otherwise please contact your support and they'll looking in the source code for you. Show quoted text
> > The module tests all it functions whether they work correctly or not. > > This ensures integrity of the implementation for the installed > > environment. Everything else would just be guessing ...
> > The test checks whether the returned string is the name of a > directory. Following your logic you would have to test that it's also > readable and writable.
There is no need for a directory being readable unless you want to traverse it. You can open files or set it as cwd when it has x bit set. Show quoted text
> > > A lot of these "standard" directories don't exist on my two > > > machines, > > > a Mac and a Gentoo laptop. I have deleted those that I don't need, > > > and > > > the Gentoo installation was done so long ago, that these > > > directories > > > had never been creaeted. I have never run into issues with that > > > because even software on the Mac simply prompts for another > > > location > > > if the expected one is not available. And that's the way it should > > > be.
> > > > Then it's good that you run into those issues now. Your dependency > > decided for File::HomeDir for a good reason (hopefully) and trusts > > whether it works correctly.
> > Dist/Zilla.pm: > > require File::HomeDir; > my $homedir = File::HomeDir->my_home > or Carp::croak("couldn't determine home directory"); > > Where is the good reason?
Don't ask that me! Dist::Zilla authors wrote that code. Show quoted text
> https://metacpan.org/requires/distribution/File- > HomeDir?p=1&size=500&sort=%5B%5B2%2C1%5D%5D > > How many of these modules will not work if the user running it has no > photos directory?
Since you're the first one asking - not so less. It's - however - not reasonable to delete that directory. Please refer freedesktop.org spec for further details. Show quoted text
> > > Furthermore, it is good practice to let _services_ run in as much > > > isolation as possible. It's certainly not bad practice to give > > > system > > > users like "nginx" or "apache" their own private Perl environment. > > > But > > > does my nginx system user really need "~/My Music" or "~/My > > > Documents"?
> > > > You shouldn't use File::HomeDir in a service which runs as an nginx > > service. That's insane. File::HomeDir is the wrong solution then.
> > See the reverse dependency list above. File::HomeDir is depended on by > too many other modules for that argument.
Wrong. Show quoted text
> > > Besides, the tests are run for the user that *builds* the software, > > > not the one that uses it. When I install File::HomeDir with sudo > > > and > > > my vendor's Perl the tests succeed. When I install it with perlbrew > > > they fail.
> > > > Without seeing the output and the tape archive of the tested > > environemnt, I can't say anything to that.
> > Run the test as root. It succeeds. But does your uid 0 have a photos > directory?
Read freedesktop specification, please. Show quoted text
> Tests for Perl modules are run on the *build* system. In the vast > majority of cases, end users never run these tests. They just use the > installed software.
That is incredibly wrong. Show quoted text
> > > The concept of a home directory is a well established standard. > > > Dedicated directories for certain file types is nothing but a > > > convention. Not even Apple or Microsoft enforce that convention. > > > Why > > > does a Perl module?
> > > > Just because simply using $HOME is not enough. Showing the right name > > for Bilder (~/Photos) in i18n environments (or ~/Movies ...) is > > important. When you think you don't need all that Freedesktop > > specified locations, then File::HomeDir is the wrong answer for your > > question.
> > Look at the reverse dependencies. Most of them have nothing to do with > desktop applications. They use use File::HomeDir for getting the home > directory. >
> > > > Rethink your question, please.
> > I did. > > My point is that these tests fail for conditions that are not errors > at all. File::HomeDir provides a portable way to get the default > locations for certain file types. If a software - whether it's using > File::HomeDir or not - breaks just because such a location does not > exist under certain conditions, then that software has a serious flaw. > ENOENT and ENOTDIR are just two out of many error conditions and > errors are there to be caught. > > Maybe we just disagree? I also think that testing whether a file > exists before opening it is a waste of time and a recipe for races. > Then it's only natural that I don't see the point in testing whether a > certain file exists on the build system for the build user at build > time.
We are done here. I told you, it's not correct with a given answer that every question applies. I explained you where your questions are wrong. You don't want to understand but to argue. But this is not the right place to train arguing.
In a nutshell, these tests that are determined to fail are integration tests, when they should be unit tests. They don't test functionality of the library but evaluate assumptions about the build system.
On Fri Nov 09 17:18:50 2018, GUIDO wrote: Show quoted text
> In a nutshell, these tests that are determined to fail are integration > tests, when they should be unit tests. They don't test functionality > of the library but evaluate assumptions about the build system.
Patches welcome. And in long: Patches which improve are welcome. Patches which just disable tests will be rejected. You can visit niederrhein.pm or GPW and discuss the bigger perspective vis-a-vis a little longer.