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
do file: Add './' in additional cases #15934
Comments
From @jkeenanCreated by jkeenan@zareason.(none)From #p5p: Mon Mar 27 2017: (05:21:57 PM) khw: On some platforms, I'm getting I ack-ed for 'do ' under t and came up with these likely additional cases. Perl Info
|
From @jkeenan0001-Additional-cases-where-do-file-should-be-do-.-file.patch>From c9c64ceb4aea28b1a9ea252cd60d38ef2bd7098c Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Mon, 27 Mar 2017 19:31:34 -0400
Subject: [PATCH] Additional cases where 'do file' should be 'do ./file'.
---
t/comp/require.t | 4 ++--
t/loc_tools.pl | 4 ++--
t/op/threads.t | 2 +-
t/run/dtrace.t | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/t/comp/require.t b/t/comp/require.t
index c4889bb..e6fadd5 100644
--- a/t/comp/require.t
+++ b/t/comp/require.t
@@ -182,9 +182,9 @@ my $x = "ok $i - bleah.do\n";
write_file("bleah.do", <<EOT);
\$x = "not ok $i - bleah.do\\n";
EOT
-do "bleah.do" or die $@;
+do "./bleah.do" or die $@;
dofile();
-sub dofile { do "bleah.do" or die $@; };
+sub dofile { do "./bleah.do" or die $@; };
print $x;
# Test that scalar context is forced for require
diff --git a/t/loc_tools.pl b/t/loc_tools.pl
index 4b99c45..ed24c37 100644
--- a/t/loc_tools.pl
+++ b/t/loc_tools.pl
@@ -342,9 +342,9 @@ sub find_locales ($;$) {
# Locales whose name differs if the utf8 bit is on are stored in these two
# files with appropriate encodings.
if ($^H & 0x08 || (${^OPEN} || "") =~ /:utf8/) {
- @Data = do "lib/locale/utf8";
+ @Data = do "./lib/locale/utf8";
} else {
- @Data = do "lib/locale/latin1";
+ @Data = do "./lib/locale/latin1";
}
# The rest of the locales are in this file.
diff --git a/t/op/threads.t b/t/op/threads.t
index a2dbdca..39f3968 100644
--- a/t/op/threads.t
+++ b/t/op/threads.t
@@ -105,7 +105,7 @@ EOI
# http://www.nntp.perl.org/group/perl.perl5.porters/63123
fresh_perl_is(<<'EOI', 'ok', { }, 'Ensure PL_linestr can be cloned');
use threads;
-print do 'op/threads_create.pl' || die $@;
+print do './op/threads_create.pl' || die $@;
EOI
diff --git a/t/run/dtrace.t b/t/run/dtrace.t
index 2140973..b66736f 100644
--- a/t/run/dtrace.t
+++ b/t/run/dtrace.t
@@ -136,7 +136,7 @@ dtrace_like(<< 'PERL_SCRIPT',
BEGIN {@INC = '../lib'}
use strict;
require HTTP::Tiny;
- do "run/dtrace.pl";
+ do "./run/dtrace.pl";
PERL_SCRIPT
<< 'D_SCRIPT',
loading-file { printf("loading-file <%s>\n", copyinstr(arg0)) }
--
2.7.4
|
From @khwilliamsonOn 03/27/2017 05:39 PM, James E Keenan (via RT) wrote:
Here's a more complete list from a more general ack. I included 'do This is updated from the one in |
The RT System itself - Status changed from 'new' to 'open' |
From @khwilliamsonOn 03/27/2017 08:02 PM, Karl Williamson wrote:
Now attached |
From @khwilliamson |
From @jkeenanOn Tue, 28 Mar 2017 02:13:45 GMT, public@khwilliamson.com wrote:
The do.log appears to have been generated post-build. Hence, it flags some instances in generated files. I tried to look only at source code files. The pod/perlfunc.pod section on 'do' could use some additional eyeballs. Entries under 'cpan/' would first need correction upstream (if they need correction at all). There are some cases where a filename is passed to a subroutine, stored in $file and subsequently used as argument to 'do $file'. It's not clear (to me, at least) whether a correction is needed in such cases. Example: ##### my $root = $obj->{Root}; my $sg = sub_generation(); Additional patch attached. Please review, particularly for false positives. Thank you very much. |
From @jkeenan0002-2-Additional-cases-where-do-file-should-be-do-.-file.patchFrom 5416eef35cea669baca93f1e3a7d40be8d7fe2e7 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Tue, 28 Mar 2017 09:21:44 -0400
Subject: [PATCH 2/2] 2: Additional cases where 'do file' should be 'do
./file'.
---
Porting/bench.pl | 6 +++---
dist/Safe/Safe.pm | 4 ++--
dist/Time-HiRes/Makefile.PL | 2 +-
ext/XS-APItest/t/blockhooks.t | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Porting/bench.pl b/Porting/bench.pl
index 62c6aaf..53e24fc 100755
--- a/Porting/bench.pl
+++ b/Porting/bench.pl
@@ -83,7 +83,7 @@ individual test.
--benchfile=I<foo>
-The path of the file which contains the benchmarks (F<t/perf/benchmarks>
+The path of the file which contains the benchmarks (F<./t/perf/benchmarks>
by default).
=item *
@@ -314,7 +314,7 @@ usage: $0 [options] -- perl[=label] ...
--action=foo What action to perform [default: grind].
--average Only display average, not individual test results.
--benchfile=foo File containing the benchmarks;
- [default: t/perf/benchmarks].
+ [default: ./t/perf/benchmarks].
--bisect=f,min,max run a single test against one perl and exit with a
zero status if the named field is in the specified
range; exit 1 otherwise.
@@ -356,7 +356,7 @@ EOF
my %OPTS = (
action => 'grind',
average => 0,
- benchfile => 't/perf/benchmarks',
+ benchfile => './t/perf/benchmarks',
bisect => undef,
compact => undef,
debug => 0,
diff --git a/dist/Safe/Safe.pm b/dist/Safe/Safe.pm
index d78fcc5..c5a838f 100644
--- a/dist/Safe/Safe.pm
+++ b/dist/Safe/Safe.pm
@@ -3,7 +3,7 @@ package Safe;
use 5.003_11;
use Scalar::Util qw(reftype refaddr);
-$Safe::VERSION = "2.39";
+$Safe::VERSION = "2.40";
# *** Don't declare any lexicals above this point ***
#
@@ -512,7 +512,7 @@ assignment of arguments to @_ on subroutine entry.
Each compartment has an associated "operator mask". Recall that
perl code is compiled into an internal format before execution.
-Evaluating perl code (e.g. via "eval" or "do 'file'") causes
+Evaluating perl code (e.g. via "eval" or "do '/path/to/file'") causes
the code to be compiled into an internal format and then,
provided there was no error in the compilation, executed.
Code evaluated in a compartment compiles subject to the
diff --git a/dist/Time-HiRes/Makefile.PL b/dist/Time-HiRes/Makefile.PL
index ccad6a3..ca4d4dc 100644
--- a/dist/Time-HiRes/Makefile.PL
+++ b/dist/Time-HiRes/Makefile.PL
@@ -417,7 +417,7 @@ sub DEFINE {
}
sub init {
- my $hints = File::Spec->catfile("hints", "$^O.pl");
+ my $hints = File::Spec->catfile(".", "hints", "$^O.pl");
if (-f $hints) {
print "Using hints $hints...\n";
local $self;
diff --git a/ext/XS-APItest/t/blockhooks.t b/ext/XS-APItest/t/blockhooks.t
index 37590bc..e409134 100644
--- a/ext/XS-APItest/t/blockhooks.t
+++ b/ext/XS-APItest/t/blockhooks.t
@@ -121,7 +121,7 @@ is_deeply \@bhkav,
delete @INC{qw{t/Null.pm t/Block.pm}};
t::BHK->import;
- do "t/Null.pm";
+ do "./t/Null.pm";
t::BHK->unimport;
is_deeply \@bhkav,
@@ -133,7 +133,7 @@ is_deeply \@bhkav,
"do file (null)";
t::BHK->import;
- do "t/Block.pm";
+ do "./t/Block.pm";
t::BHK->unimport;
is_deeply \@bhkav,
--
2.7.4
|
From @jkeenanOn Tue, 28 Mar 2017 14:10:31 GMT, jkeenan wrote:
Could we get some eyeballs on the two patches I've already submitted for this ticket? Thank you very much. |
From @iabynOn Fri, Mar 31, 2017 at 04:59:48AM -0700, James E Keenan via RT wrote:
Here is my complete review of all the 'do' candidates found through the Unless there's any disagreement, I'll apply my and the relevant parts of What follows is divided into these sections: James has a patch which I agree should be applied I'd suggest people read up to at least the 'things which require further JAMES HAS A PATCH WHICH I AGREE SHOULD BE APPLIED t/loc_tools.pl:345: @Data = do "lib/locale/utf8"; The patch for this looks good t/run/dtrace.t:139: do "run/dtrace.pl"; The patch for this looks good JAMES HAS A PATCH WHICH I THINK NEED NOT BE APPLIED t/comp/require.t:182:write_file("bleah.do", <<EOT); Changes not needed: require.t itself adds '.' to @INC t/op/threads.t:108:print do 'op/threads_create.pl' || die $@; Adding '.' to the filename isn't needed, as fresh_perl_is() will ext/XS-APItest/t/blockhooks.t:124: do "t/Null.pm"; This test script relies on t/harness to set up an appropriate dist/Safe/Safe.pm:515:Evaluating perl code (e.g. via "eval" or "do 'file'") causes This is pod text, describing eval and do in a generic sense; I HAVE A PATCH (OR ALTERNATIVE PATCH) regen/regcharclass.pl:385: die "do '$1' failed: This script was broken under no '.' in @INC; presumably the breakage I've fixed the "require 'regen/...'" line. The "do $1" line above is never actually triggered currently. If Porting/bench.pl:507: my $ta = do $file; The original suggested patch fixed up bench.pl in a way that utils/libnetcfg.PL:346: %oldcfg = ( %{ do $libnet_cfg_in } ); I have patched it so that it can find the old config file via THINGS WHICH REQUIRE FURTHER DISCUSSION cpan/Unicode-Collate/Makefile.PL:9: do 'mkheader' or die I think it currently works due to: cpan/Test-Simple/t/Legacy/subtest/do.t:13:subtest $file => sub { do $file }; Passes now due to t/harness adding '.' to path; cpan/Test-Simple/t/Legacy/Tester/tbt_09do.t:12:my $done = do $file; Passes now due to t/harness adding '.' to path; cpan/CPAN/lib/CPAN/Distribution.pm:3451: my $x = do $buildparams; I don't know what this code does, but nothing in the test suite ext/DynaLoader/DynaLoader_pm.PL:376: eval { do $bs; }; This bit of code is for loading a non-empty .bs file, which dist/Safe/Safe.pm:458: sprintf('package %s; sub { @_ = (); do $file }', $root); This implements Safe::rdo() - a restricted version of do(). The dist/Unicode-Normalize/Makefile.PL:11: do 'mkheader' or die As for Unicode-Collate/Makefile.PL above, it probably needs fixing dist/Time-HiRes/Makefile.PL:424: do $hints; As for Unicode-Collate/Makefile.PL above, it probably needs fixing dist/XSLoader/XSLoader_pm.PL:148: eval { do $bs; }; This is a similar issue to DynaLoader (see above). win32/ce-helpers/makedist.pl:240: do $bs; NOTHING NEEDING DOING h2pl/mkvars:9: do $include; ancient perl3 script. If anyone still uses it t/run/switchC.t:70: prog => "do q($scriptfile)", runperl adds -I. so this is ok t/perf/benchmarks.t:17:my $benchmark_array = do $file; the test script adds '.' to @INC first t/re/regexp_notrie.t:11: do $file always has a ./ prefix t/op/inccode.t:65:$evalret = eval { do 'Foo2.pl'; 1 }; This uses coderefs in @INC, which removes the need for '.' in @INC t/op/require_errors.t:127: my $ret = do "strict.pm\0invalid"; Its looking for strict in lib, not '.' t/op/taint.t:1162: violates_taint(sub { do $foo }, 'do'); it dies with a taint failure before it has a chance to (fail to) t/op/do.t:34:my @a = do The script adds '.' to @INC t/op/inccode-tie.t:11: do $file has ./ prefix t/op/incfilter.t:30:do $fh or die; @INC uses coderefs t/comp/line_debug.t:25:do "comp/line_debug_0.aux"; the script adds '.' to @INC lib/_charnames.pm:243: if (my @alias = do $file) { This implements the lib/utf8_heavy.pl:534: This expects to load "unicore/foo.pl" files via @INC lib/B/Deparse.t:1724:() = (do 'file') + time; The 'do' gets deparsed but not executed. lib/B/Deparse-core.t:246:testit do => 'do $a;', 'test::do($a);'; The 'do' gets deparsed but not executed. lib/perl5db.pl:1271: do $file; The "do $file" is always called with $file being absolute or ./... win32/ce-helpers/comp.pl:42: 'do' => '', False positives in grep write_buildcustomize.pl:101: do $file and exit; This script is designed to be run my miniperl which has '.' in cpan/libnet/lib/Net/Config.pm:81: $ref = eval { local $SIG{__DIE__}; do $file }; This looks for libnet.cfg using the same pathname prefix that cpan/Unicode-Collate/Collate/Locale.pm:101: my $h = do $path; Documented (in code comments) as searching @INC. cpan/ExtUtils-MakeMaker/lib/ExtUtils/MakeMaker.pm:1166: my $ret = do $hint_file; It locally adds '.' to @INC cpan/ExtUtils-MakeMaker/lib/ExtUtils/Mksymlists.pm:173: require Config; # a reminder for once we do $^O False positive in grep cpan/Test-Simple/t/Legacy/Tester/tbt_09do_script.pl:11:test_test('test_fail caught fail message inside a do'); False positive in grep cpan/Pod-Perldoc/corpus/perlfunc.pod:1483: unless ($return = do $file) { Just sample pod symbian/config.pl:12:do "sanity.pl" or die $@; these scripts add symbian/ or similar to @INC ext/DynaLoader/Makefile.PL:43: do False positive: the 'do' is part of shell script ext/Opcode/Opcode.pm:101:Evaluating perl code (e.g. via "eval" or "do 'file'") causes Just pod dist/base/t/base-open-chunk.t:10:unless (my $return = do $test_file) { These test scripts run okay from harness which sets up @INC dist/Safe/t/safeops.t:411:dofile do 'file' The 'do' is expected to die during compilation before being dist/lib/t/01lib.t:65: is( eval { do 'Yup.pm' }, 42, 'do() works' ); This adds entries to @INC and checks that it can load files there dist/SelfLoader/t/03taint.t:7:do It adds '.' to @INC pod/perlrun.pod:481: && do "$Config{sitelib}/sitecustomize.pl"; That's pod pod/perlfunc.pod:1825: do 'stat.pl'; The man entry for 'do' has already been fixed up. -- |
From @LeontOn Tue, Apr 4, 2017 at 1:26 PM, Dave Mitchell <davem@iabyn.com> wrote:
MakeMaker doesn't set it, CPAN.pm does. We should fix this on CPAN (as
The .bs loading should be done from @INC, just like the loading of the
Correct. Leon |
From @andk
> cpan/CPAN/lib/CPAN/Distribution.pm:3451: my $x = do $buildparams; > I don't know what this code does, but nothing in the test suite $buildparams is generated as my $buildparams = File::Spec->catfile($build_dir,"_build","build_params"); so I'm tempted to believe, this needs no fixing. -- |
From @iabynOn Tue, Apr 04, 2017 at 05:13:11PM +0200, Leon Timmermans wrote:
I suppose we might as well patch the two dist/ distributions in core now,
But the "do" in XSLoader.pm etc only gets calls once a .bs file has been if (-s $bs) { # only read file if it's not empty so at this point it's clear that it's trying to load a specific file rather Since I have no idea what .bs files are used for (apart from the fact that -- |
From @craigberryOn Wed, Apr 5, 2017 at 2:51 AM, Dave Mitchell <davem@iabyn.com> wrote:
I've never used it, but C<perldoc ExtUtils::Mkbootstrap> says a little $ cat cpan/DB_File/DB_File_BS 1; |
From @iabynI've just pushed v5.25.11-47-g82421f5, a big merge commit, which has fixes On Tue, Apr 04, 2017 at 12:26:58PM +0100, Dave Mitchell wrote:
These parts are now applied.
I fixed this by adding '.'to @INC instead
These three are applied.
I've left cpan/ distributions alone.
These have been fixed and a test for executing a non-empty .bs file has
docs amended.
the blead distributions have been fixed. -- |
@iabyn - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#131069 (status was 'resolved')
Searchable as RT131069$
The text was updated successfully, but these errors were encountered: