Skip Menu |
Report information
Id: 124050
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: shay <steve.m.hay [at] googlemail.com>
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version: (no value)
Fixed In: (no value)

Attachments
0001-RT-124050-Try-really-hard-not-to-run-tests-outside-o.patch



Subject: t/harness can mistakenly run tests outside of the perl source tree
Download (untitled) / with headers
text/plain 626b
If I have a cpan/Text-Balanced folder (containing a Git workspace of the CPAN Text-Balanced distro) alongside my perl source tree then t/harness will mistakenly run the tests in ../../cpan/Text-Balanced/t/ (outside the perl source tree) instead of the intended ../cpan/Text-Balanced/t/ (inside the perl source tree). It happens because of this little snippet in t/harness: # Allow eg ./perl t/harness t/op/lc.t for (@tests) { if (-f "../$_") { $_ = "../$_"; s{^\.\./t/}{}; } } but I'm not sure off-hand how best to fix it to be absolutely sure that it doesn't end up outside of the perl source tree.
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 882b
On Thu Mar 12 02:24:36 2015, shay wrote: Show quoted text
> If I have a cpan/Text-Balanced folder (containing a Git workspace of > the CPAN Text-Balanced distro) alongside my perl source tree then > t/harness will mistakenly run the tests in ../../cpan/Text-Balanced/t/ > (outside the perl source tree) instead of the intended ../cpan/Text- > Balanced/t/ (inside the perl source tree). > > It happens because of this little snippet in t/harness: > > # Allow eg ./perl t/harness t/op/lc.t > for (@tests) { > if (-f "../$_") { > $_ = "../$_"; > s{^\.\./t/}{}; > } > } > > but I'm not sure off-hand how best to fix it to be absolutely sure > that it doesn't end up outside of the perl source tree.
Unless someone has a brainstorm about this, I would suggest simply documenting it in pod/perlhack.pod as a known limitation of t/harness. -- James E Keenan (jkeenan@cpan.org)
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 373b
On Sat Mar 14 16:14:00 2015, jkeenan wrote: Show quoted text
> Unless someone has a brainstorm about this, I would suggest simply > documenting it in pod/perlhack.pod as a known limitation of t/harness.
I've either reported (and someone else fixed) or fixed a dozen of these bugs in the last 3 years. This is a common class of bugs with the perl distro. -- bulk88 ~ bulk88 at hotmail.com
Subject: Re: [perl #124050] t/harness can mistakenly run tests outside of the perl source tree
CC: "bugs-bitbucket [...] rt.perl.org" <bugs-bitbucket [...] rt.perl.org>
To: Perl5 Porters <perl5-porters [...] perl.org>
From: "Matthew Horsfall (alh)" <wolfsage [...] gmail.com>
Date: Sun, 24 Apr 2016 13:46:59 -0400
Download (untitled) / with headers
text/plain 859b
On Thu, Mar 12, 2015 at 5:24 AM, Steve Hay <perlbug-followup@perl.org> wrote: Show quoted text
> If I have a cpan/Text-Balanced folder (containing a Git workspace of the CPAN Text-Balanced distro) alongside my perl source tree then t/harness will mistakenly run the tests in ../../cpan/Text-Balanced/t/ (outside the perl source tree) instead of the intended ../cpan/Text-Balanced/t/ (inside the perl source tree). > > It happens because of this little snippet in t/harness: > > # Allow eg ./perl t/harness t/op/lc.t > for (@tests) { > if (-f "../$_") { > $_ = "../$_"; > s{^\.\./t/}{}; > } > } > > but I'm not sure off-hand how best to fix it to be absolutely sure that it doesn't end up outside of the perl source tree. >
Possible patch attached. This may be 'better than nothing' (provided I didn't break something else). -- Matthew Horsfall (alh)

Message body is not shown because sender requested not to inline it.

To: "Matthew Horsfall (alh)" <wolfsage [...] gmail.com>
CC: Perl5 Porters <perl5-porters [...] perl.org>, "bugs-bitbucket [...] rt.perl.org" <bugs-bitbucket [...] rt.perl.org>
From: Dave Mitchell <davem [...] iabyn.com>
Subject: Re: [perl #124050] t/harness can mistakenly run tests outside of the perl source tree
Date: Mon, 20 Jun 2016 12:00:20 +0100
Download (untitled) / with headers
text/plain 3.1k
On Sun, Apr 24, 2016 at 01:46:59PM -0400, Matthew Horsfall (alh) wrote: Show quoted text
> On Thu, Mar 12, 2015 at 5:24 AM, Steve Hay <perlbug-followup@perl.org> wrote:
> > If I have a cpan/Text-Balanced folder (containing a Git workspace of the CPAN Text-Balanced distro) alongside my perl source tree then t/harness will mistakenly run the tests in ../../cpan/Text-Balanced/t/ (outside the perl source tree) instead of the intended ../cpan/Text-Balanced/t/ (inside the perl source tree). > > > > It happens because of this little snippet in t/harness: > > > > # Allow eg ./perl t/harness t/op/lc.t > > for (@tests) { > > if (-f "../$_") { > > $_ = "../$_"; > > s{^\.\./t/}{}; > > } > > } > > > > but I'm not sure off-hand how best to fix it to be absolutely sure that it doesn't end up outside of the perl source tree. > >
> > Possible patch attached. This may be 'better than nothing' (provided I > didn't break something else). > > -- Matthew Horsfall (alh)
Show quoted text
> From 8999852eaf7db1cb193127c786127a0bb2a32a1e Mon Sep 17 00:00:00 2001 > From: Matthew Horsfall <wolfsage@gmail.com> > Date: Sun, 24 Apr 2016 13:43:00 -0400 > Subject: [PATCH] RT: #124050 - Try really hard not to run tests outside of > source tree. > > Assume if the user passed in a path with '../' that they were in t/ > aiming for a test a level up somewhere. > --- > t/harness | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/t/harness b/t/harness > index d069472..f0cbcd6 100644 > --- a/t/harness > +++ b/t/harness > @@ -188,7 +188,7 @@ if ($^O eq 'MSWin32') { > > # Allow eg ./perl t/harness t/op/lc.t > for (@tests) { > - if (-f "../$_") { > + if ($_ !~ /^\.\./ && -f "../$_") { > $_ = "../$_"; > s{^\.\./t/}{}; > }
I've applied a slightly enhanced version of that: commit 683433bde86eadff5e1a6ecebc027e0eefcd25ca Author: David Mitchell <davem@iabyn.com> AuthorDate: Mon Jun 20 11:48:35 2016 +0100 Commit: David Mitchell <davem@iabyn.com> CommitDate: Mon Jun 20 11:48:35 2016 +0100 t/harness: avoid tests outside the src tree [perl #124050] t/harness can mistakenly run tests outside of the perl source tree cfa562529cf24 made t/harness prepend '../' to test filenames if such a file existed. This allowed things like ./perl t/harness cpan/foo/t/foo.t to work even after harness had done a chdir("t"). However, it was then picking up a ../cpan/foo/t/foo.t file outside the src tree in preference to the one inside. Add belt-and-brace conditions: only modify the filename if the unmodified file doesn't exist, and only only if it doesn't already start with ../. Based on an earlier patch by Matthew Horsfall Affected files ... M t/harness Differences ... diff --git a/t/harness b/t/harness index d069472..b46582d 100644 --- a/t/harness +++ b/t/harness @@ -188,7 +188,7 @@ if ($^O eq 'MSWin32') { # Allow eg ./perl t/harness t/op/lc.t for (@tests) { - if (-f "../$_") { + if (! -f $_ && !/^\.\./ && -f "../$_") { $_ = "../$_"; s{^\.\./t/}{}; } -- Indomitable in retreat, invincible in advance, insufferable in victory -- Churchill on Montgomery
CC: Perl5 Porters <perl5-porters [...] perl.org>, "bugs-bitbucket [...] rt.perl.org" <bugs-bitbucket [...] rt.perl.org>
To: Dave Mitchell <davem [...] iabyn.com>
Subject: Re: [perl #124050] t/harness can mistakenly run tests outside of the perl source tree
From: "Matthew Horsfall (alh)" <wolfsage [...] gmail.com>
Date: Mon, 20 Jun 2016 07:53:00 -0400
Download (untitled) / with headers
text/plain 183b
On Mon, Jun 20, 2016 at 7:00 AM, Dave Mitchell <davem@iabyn.com> wrote: Show quoted text
> I've applied a slightly enhanced version of that:
Ah yes, much better. Thanks. -- Matthew Horsfall (alh)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org