New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib/perlbug.t: avoid spurious failure when testing long PATH line #15544
Comments
From @jkeenanPlease see perl5-porters discussion beginning here: http://www.nntp.perl.org/group/perl.perl5.porters/2016/08/msg239185.html lib/perlbug.t holds tests which sanity-check the operation of the 'perlbug' utility by creating bug reports without actually sending them. Earlier this year we added tests (c04bead) provided by Niko Tyni with respect to this rationale: ##### Whether this objective is met is tested by this code: ##### In this case, $B is used simply to generate dummy copy for an attachment. So, in the first of the two unit tests shown, we're testing to make sure that no bug report line other than in an attachment exceeds 1000 characters. There is however, one line in a perlbug report which can quite plausibly exceed 1000 *unbroken* characters: the line dumping the PATH environmental variable. No (unescaped) wordspaces are permitted in a PATH, so the line does not wrap. A PATH line greater than 1000 characters in length can occur in at least two plausible circumstances: (1) For business reasons, the user has many directories in her path; or (2) The PATH (a) is shorter than 1000 characters; (b) terminates with ':$PATH'; and (c) is incremented in a particular shell -- a shell in which 'lib/perlbug.t' is subsequently run -- by use of commands like 'source ~/.bashrc' which the user is invoking to modify a .*rc or .profile file. This can cause the kind of entirely spurious test failure reported in the p5p thread cited above: ##### The patch attached excludes the 'PATH' line from test #21 in lib/perlbug.t and thereby reduces the possibility of spurious failures. Here is how I tested this in a fresh shell. ##### $ cd t;./perl harness -v ../lib/perlbug.t; cd - ok 1 - config information dumped with -d Please review. Thank you very much. |
From @jkeenanPlease see perl5-porters discussion beginning here: http://www.nntp.perl.org/group/perl.perl5.porters/2016/08/msg239185.html lib/perlbug.t holds tests which sanity-check the operation of the 'perlbug' utility by creating bug reports without actually sending them. Earlier this year we added tests (c04bead) provided by Niko Tyni with respect to this rationale: ##### Whether this objective is met is tested by this code: ##### In this case, $B is used simply to generate dummy copy for an attachment. So, in the first of the two unit tests shown, we're testing to make sure that no bug report line other than in an attachment exceeds 1000 characters. There is however, one line in a perlbug report which can quite plausibly exceed 1000 *unbroken* characters: the line dumping the PATH environmental variable. No (unescaped) wordspaces are permitted in a PATH, so the line does not wrap. A PATH line greater than 1000 characters in length can occur in at least two plausible circumstances: (1) For business reasons, the user has many directories in her path; or (2) The PATH (a) is shorter than 1000 characters; (b) terminates with ':$PATH'; and (c) is incremented in a particular shell -- a shell in which 'lib/perlbug.t' is subsequently run -- by use of commands like 'source ~/.bashrc' which the user is invoking to modify a .*rc or .profile file. This can cause the kind of entirely spurious test failure reported in the p5p thread cited above: ##### The patch attached excludes the 'PATH' line from test #21 in lib/perlbug.t and thereby reduces the possibility of spurious failures. Here is how I tested this in a fresh shell. ##### $ cd t;./perl harness -v ../lib/perlbug.t; cd - ok 1 - config information dumped with -d Please review. Thank you very much. |
From @ntyniOn Mon, Aug 22, 2016 at 06:28:59AM -0700, James E Keenan wrote:
Thanks for looking at this. The patch seems to have been lost at some point? Allowing long unbroken PATH lines in the report means that bug submissions That said, excluding PATH from the wrapping check could still be |
The RT System itself - Status changed from 'new' to 'open' |
From zefram@fysh.orgNiko Tyni wrote:
There's a better way: emit the message in quoted-printable encoding, -zefram |
From @jkeenanOn Wed Aug 24 12:46:02 2016, ntyni@debian.org wrote:
Indeed! My error. Attaching original intended patch now.
-- |
From @jkeenan0001-Avoid-spurious-test-failure-due-to-PATH-line-1000-ch.patchFrom b197f9a55e2ae877b3089282cfe07f3647d240f9 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Mon, 22 Aug 2016 09:25:08 -0400
Subject: [PATCH] Avoid spurious test failure due to PATH line > 1000
characters.
---
lib/perlbug.t | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/perlbug.t b/lib/perlbug.t
index ed32c04..8ff8991 100644
--- a/lib/perlbug.t
+++ b/lib/perlbug.t
@@ -148,7 +148,7 @@ my $maxlen1 = 0; # body
my $maxlen2 = 0; # attachment
for (split(/\n/, $contents)) {
my $len = length;
- $maxlen1 = $len if $len > $maxlen1 and !/$B/;
+ $maxlen1 = $len if $len > $maxlen1 and ! (/(?:$B|PATH)/);
$maxlen2 = $len if $len > $maxlen2 and /$B/;
}
ok($maxlen1 < 1000, "[perl #128020] long body lines are wrapped: maxlen $maxlen1");
--
2.7.4
|
From @ntyniOn Wed, Aug 24, 2016 at 09:45:12PM +0100, Zefram wrote:
Indeed, at the cost of some added complexity that I was hesitant I see there's q-p functionality in cpan/MIME-Base64/, but that relies on |
P5P: What is the status of the If Thank you very much. |
…26245) Fix the perl test case bug Perl/perl5#15544 Variable PATH longer than 1000 characters (as is usual with spack) fails a perl test case The fix is: Don't test PATH in testcase perlbug.t Fixes `spack install --test=all` for specs triggering a build and test of perl!
Still happening in perl 5.34 and Focal Fossa |
Added a PR to fix this: see #20497. |
This fixes issue Perl#15544. If the user has PATH, or similar variables containing a list of directories separated by e.g. a colon character these can easily become lines with more than 1000 characters in a perlbug report, resulting in a test failure in lib/perlbug.t.
Migrated from rt.perl.org#129048 (status was 'open')
Searchable as RT129048$
The text was updated successfully, but these errors were encountered: