cpanel / test-mockfile Goto Github PK
View Code? Open in Web Editor NEWMocks open and close
Home Page: https://metacpan.org/pod/Test::MockFile
Mocks open and close
Home Page: https://metacpan.org/pod/Test::MockFile
An idea was laid out that trace mode could be used during dev that would document file accesses.
At this time, we're considering it a feature request at low priority until someone speaks up.
idea to provide one bin
or binary
helper to avoid the boilerplate
my $mock_bin = Test::MockFile->file( '/usr/local/bin/xxx', "#!/bin/true or whatever" );
$mock_bin->chmod(0755);
so we could use
my $mock_bin = Test::MockFile->bin( '/usr/local/bin/xxx' );
This test does not work for some reason
use Test::More;
use Test::MockFile;
use Data::Dumper;
# Test that Config::MySQL::Reader does not read comments
use_ok('Config::MySQL::Reader');
my $cnf = <<INI;
[group1]
[group1]
# comment
; comment
path = foo/bar
quoted_param = "foo;bar"
numerical_param = 12345
string_param = 500M
param_with_comment = xyz # abc
# e.g. skip-name-resolve
param-without-value
param-with-two-spaces-after
param-with-tabulation-after
empty_str ""
INI
my $random_filename = 'foo.ini';
my $mock_file = Test::MockFile->file($random_filename, $cnf);
my $config = Config::MySQL::Reader->read_file($random_filename);
my $res = {
'group1' => {
'string_param' => '500M',
'param-with-two-spaces-after' => undef,
'path' => 'foo/bar',
'param-without-value' => undef,
'param_with_comment' => 'xyz',
'param-with-tabulation-after ' => undef,
'empty_str ""' => undef,
'quoted_param' => '"foo;bar"',
'numerical_param' => '12345'
}
};
is_deeply $config, $res;
done_testing;
I haven't fully investigated this problem yet, but quick code analysis of Config::MySQL::Reader show that maybe issue related to IO::File package call
perl v5.28.0, Test-MockFile v0.016 (that is what cpanel 80 is set to ATM)
#!/usr/local/cpanel/3rdparty/bin/perl
package modulino;
use strict;
use warnings;
use Data::Dumper;
require Config::Tiny;
sub main {
my $cfg = load("$ENV{HOME}/.modulino.conf");
print Dumper($cfg);
return;
}
sub load { return Config::Tiny->read(shift) }
main() unless caller;
1;
use strict;
use warnings;
use Test::More tests => 1;
use FindBin;
use Test::MockFile;
require "$FindBin::Bin/modulino";
my $file = "$ENV{HOME}/.modulino.conf";
my $mocked_conf = Test::MockFile->file( $file, "[derp]\nfoo=2\nbar=7\n" );
my $exp = { derp => { foo => 2, bar => 7 } };
# diag explain modulino::load($file);
is_deeply modulino::load($file), $exp, "can load ini file";
# prove -vw modulino.t
modulino.t ..
1..1
Modification of a read-only value attempted at /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/Test/MockFile.pm line 1070.
# Looks like your test exited with 255 before it could output anything.
Change the modulino to use open() (i.e. not Config::Tiny) adjust test accordingly and it passes:
#!/usr/local/cpanel/3rdparty/bin/perl
package modulino;
use strict;
use warnings;
use Data::Dumper;
sub main {
my $cfg = load("$ENV{HOME}/.modulino.conf");
print Dumper($cfg);
return;
}
sub load {
my ($file) = @_;
if ( open my $fh, "<", $file ) {
return <$fh>;
}
return;
}
main() unless caller;
1;
use strict;
use warnings;
use Test::More tests => 1;
use FindBin;
use Test::MockFile;
require "$FindBin::Bin/modulino";
my $file = "$ENV{HOME}/.modulino.conf";
my $cont = "oh hai $$\n";
my $mocked_conf = Test::MockFile->file( $file, $cont );
# diag explain modulino::load($file);
is_deeply modulino::load($file), $cont, "can load file";
# prove -w modulino.t
modulino.t .. ok
All tests successful.
Files=1, Tests=1, 0 wallclock secs ( 0.04 usr 0.01 sys + 0.10 cusr 0.01 csys = 0.16 CPU)
Result: PASS
This seems to happen sometimes on FreeBSD systems (non-zfs!, seen on FreeBSD versions from 9 to 11):
# Failed test '$! is set to EISDIR'
# at t/unlink.t line 39.
# +-----+----+-------+
# | GOT | OP | CHECK |
# +-----+----+-------+
# | 1 | eq | 21 |
# +-----+----+-------+
# Failed test 'unlink on a existing directory'
# at t/unlink.t line 46.
# Seeded srand with seed '20181108' from local date.
t/unlink.t ..............
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/4 subtests
when testing the code from the documentation:
https://metacpan.org/pod/release/TODDR/Test-MockFile-0.018/lib/Test/MockFile.pm#Mock-Stats
I can notice the following failure
Unknown args (3) passed to new at /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/Test/MockFile.pm line 385.
use Test::MockFile;
my $mode = 0644;
my $now = time;
my $file = q[/tmp/foo];
my $contents = q[XYZ];
Test::MockFile->new( $file, $contents, {
'dev' => 0, # stat[0]
'inode' => 0, # stat[1]
'mode' => $mode, # stat[2]
'nlink' => 0, # stat[3]
'uid' => 0, # stat[4]
'gid' => 0, # stat[5]
'rdev' => 0, # stat[6]
'atime' => $now, # stat[8]
'mtime' => $now, # stat[9]
'ctime' => $now, # stat[10]
'blksize' => 4096, # stat[11]
'fileno' => undef, # fileno()
} );
We have a test that confirms actual perl directory read behavior is that directories created after opendir are not seen when at EOF and doing a readdir.
This seems to be breaking only on freebsd for the moment.
http://matrix.cpantesters.org/?dist=Test-MockFile%200.008;os=freebsd;reports=1
Adding Test::MockFile to my test produces this error:
# Can't use string ("DH") as a symbol ref while "strict refs" in use at lib/perl5/Test/Pod/Coverage.pm line 219.
# Failed test 'all_pod_coverage_ok'
# at lib/perl5/Test2/Tools/AsyncSubtest.pm line 23.
This is happening with the latest version of Test::Pod::Coverage (1.10) and Test::MockFile (0.019)
The strict mode is a cool feature, but it dies at the first exception, it would be cool to have a warning or trace mode, that could warn about all file access without raising a die
print <$baz_fh> "replace contents\n";
Oops!
To be more consistent, we want to change opendir/glob to simply go off of the list of mocked files.
my $d = Test::MockFile->dir('/etc', ['foo', 'bar']); # DIES this is now illegal.
my $dir = '/path';
my $f = $m->dir($dir ) # Mocked but not there.
-d '/dirpath'; # False
mkdir($dir, 0755)
-d '/dirpath'; # True
dir now no longer takes a second arg or it dies.
opendir/read and glob should now go off of the mocked files or mocked + existing when not in strict mode.
$>perl -MData::Dumper -MTest::MockFile=strict -E'my $f = Test::MockFile->file( "t/data/example_email.csv", "blah" ); print Dumper \%Test::MockFile::files_being_mocked; -s "t/data/example_email.csv" && print "ok\n";'
$VAR1 = {
'/usr/local/cpanel/t/data/example_email.csv' => bless( {
'uid' => 0,
'inode' => 0,
'nlink' => 0,
'dev' => 0,
'gid' => 0,
'contents' => 'blah',
'tty' => 0,
'rdev' => 0,
'atime' => 1545326306,
'mode' => 33188,
'file_name' => '/usr/local/cpanel/t/data/example_email.csv',
'blksize' => 4096,
'readlink' => '',
'mtime' => 1545326306,
'fileno' => 900,
'ctime' => 1545326306
}, 'Test::MockFile' )
};
Use of stat to access unmocked file or directory 't/data/example_email.csv' in strict mode at -e line 1 at /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/Test/MockFile.pm line 170.
Test::MockFile::_strict_mode_violation("stat", ARRAY(0x18cd280)) called at /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/Test/MockFile.pm line 937
Test::MockFile::_real_file_access_hook("stat", ARRAY(0x18cd280)) called at /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/Test/MockFile.pm line 471
Test::MockFile::_mock_stat("stat", "t/data/example_email.csv") called at /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/x86_64-linux-64int/Overload/FileCheck.pm line 295
Overload::FileCheck::_check_from_stat("s", "t/data/example_email.csv", CODE(0x1a43fb0)) called at /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/x86_64-linux-64int/Overload/FileCheck.pm line 265
Overload::FileCheck::__ANON__("s", "t/data/example_email.csv") called at /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/x86_64-linux-64int/Overload/FileCheck.pm line 210
Overload::FileCheck::__ANON__("t/data/example_email.csv") called at /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/x86_64-linux-64int/Overload/FileCheck.pm line 586
Overload::FileCheck::_check(276, "t/data/example_email.csv") called at -e line 1
t/file_access_hooks.t fails on some systems:
# Failed test '-e on an unmocked file throws a croak'
# at t/file_access_hooks.t line 30.
# +--------------------------------+----+--------------------------------+
# | GOT | OP | CHECK |
# +--------------------------------+----+--------------------------------+
# | Use of lstat on unmocked file | =~ | (?^:^Use of stat on unmocked f |
# | /abc in strict mode at t/file_ | | ile /abc in strict mode at t/f |
# | access_hooks.t line 30.\n | | ile_access_hooks.t line \d+.\n |
# | | | $) |
# +--------------------------------+----+--------------------------------+
# Failed test '-e on an unmocked empty file name throws a croak'
# at t/file_access_hooks.t line 31.
# +--------------------------------+----+--------------------------------+
# | GOT | OP | CHECK |
# +--------------------------------+----+--------------------------------+
# | Use of lstat on unmocked file | =~ | (?^:^Use of stat on unmocked f |
# | in strict mode at t/file_acce | | ile in strict mode at t/file_ |
# | ss_hooks.t line 31.\n | | access_hooks.t line \d+.\n$) |
# +--------------------------------+----+--------------------------------+
# Seeded srand with seed '20181026' from local date.
t/file_access_hooks.t ...
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/8 subtests
This happens on:
In our code, we had:
my $dir = '/path/to/mydir/';
Test::MockFile->dir( $dir, [] ),
-d '/path/to/mydir' or die;
which failed because /path/to/mydir/
was mocked, not /path/to/mydir
. Given a trailing slash makes no sense, I think it's reasonable to maybe die when someone tries to mock an illegal path?
When mocking multiple files like this
my @mocked_files = map { Test::MockFile->file( $_ ) } @files;
Having one additional helper to get the filename would be useful
say $_->filename for @mocked_files
We should use the current user and group id when creating a file unless provided
When running this code as a non root user it fails, because the uid and gid are set to 0
{code}
id
uid=1003(foopl) gid=1003(foopl) groups=1003(foopl)
perl -MTest::MockFile -e'my $path = "/tmp/fake"; my $f = Test::MockFile->file( $path, " ", { mode => 0700 } ); print( ( -x$path) . $ / ); printf "mode: 0%o\n", (stat $path)[2]'
mode: 0100702
{code}
Of course we could do something like this uid => $>
but that should be the default behavior when not set
{code}
perl -MTest::MockFile -e'my $path = "/tmp/fake"; my $f = Test::MockFile->file(
1
mode: 0100702
{code}
On some of my smokers t/writeline.t fails. A sample report: http://www.cpantesters.org/cpan/report/b6c87bde-0ecd-11e9-b0ff-b8c4ea7c92bb
Statistical analysis suggests that this happens with older Test2::Bundle::Extended:
****************************************************************
Regression 'mod:Test2::Bundle::Extended'
****************************************************************
Name Theta StdErr T-stat
[0='const'] -0.0000 0.0000 -3.38
[1='eq_0.000032'] -0.0000 0.0000 -1.60
[2='eq_0.000058'] 1.0000 0.0000 8791987084298526.00
[3='eq_0.000060'] 1.0000 0.0000 5755706617553155.00
[4='eq_0.000067'] 1.0000 0.0000 8791987084298528.00
[5='eq_0.000070'] 1.0000 0.0000 9631139302728756.00
[6='eq_0.000072'] 1.0000 0.0000 11511413235106310.00
[7='eq_0.000077'] 1.0000 0.0000 9631139302728754.00
[8='eq_0.000083'] 1.0000 0.0000 5755706617553157.00
[9='eq_0.000097'] 1.0000 0.0000 5755706617553153.00
[10='eq_0.000100'] 1.0000 0.0000 5755706617553157.00
[11='eq_0.000108'] 1.0000 0.0000 5755706617553156.00
[12='eq_0.000111'] 1.0000 0.0000 7614084164747197.00
[13='eq_0.000114'] 1.0000 0.0000 11795688466675010.00
[14='eq_0.000115'] 1.0000 0.0000 13429982107624026.00
[15='eq_0.000116'] 1.0000 0.0000 12870151255394236.00
[16='eq_0.000117'] 1.0000 0.0000 14285288145180914.00
R^2= 1.000, N= 125, K= 17
****************************************************************
So it fails if 0.000032 is installed.
Perl Prints something like this:
Filehandle $fh opened only for input at t/readline.t line 27, <$fh> line 2.
But a tied object (even using caller might not be able to determine the SV name that led to the tied sub being called.
The logic for tell/seek in our tied file handle accesses the contents and reads or writes content based on the use of substr and length. Both methods are dependant on if the strings are utf8 or not. So if utf8 data was fed to these methods but the SV didn't have a utf8 flag, unexpected things might happen.
I'm not sure how common a problem this is and at the moment BINMODE
isn't even supported so for the moment I'm going to pass on worrying about it.
> perl -MTest::MockFile -e'my $file = Test::MockFile->file("/foo/bar", undef);
die "huh" if -e "/foo/bar"; print "$!"'
Bad file descriptor
^^ The above should say something like, No such file or directory
.
This breaks anything that verifies $! after -e
fails (which probably ought to be almost everything).
Test::MockFile symlinks seem broken, am I doing it wrong?
The object looks right:
$VAR1 = bless( {
'nlink' => 0,
'gid' => 0,
'mode' => 45055,
'atime' => 1544466989,
'tty' => 0,
'rdev' => 0,
'fileno' => 900,
'inode' => 0,
'uid' => 0,
'readlink' => 'trg',
'mtime' => 1544466989,
'blksize' => 4096,
'contents' => undef,
'dev' => 0,
'file_name' => '/foo/bar',
'ctime' => 1544466989
}, 'Test::MockFile' );
but then readlink()
and lstat()
don’t return what you'd expect:
perl -MTest::MockFile -MData::Dumper -e 'my $sym=Test::MockFile->symlink("trg", "/foo/bar");print Dumper({ $sym->{file_name} => readlink($sym->{file_name}) })'
$VAR1 = {
'/foo/bar' => undef
};
perl -MTest::MockFile -MData::Dumper -e 'my $sym=Test::MockFile->symlink("trg", "/foo/bar");print Dumper({ $sym->{file_name} => [lstat($sym->{file_name})] })'
$VAR1 = {
'/foo/bar' => []
};
readlink()
should be trg
and lstat()
should have much of the data from the object dump?
Ran into a case today where having fileno implemented would have been great for BoxTrapper::CORE.
Thanks
On some of my smokers (freebsd 13 + 14 with zfs) t/readlink.t fails like this:
# Failed test '$! is ENOENT for a readlink(undef)'
# at t/readlink.t line 52.
# +-----+----+-------+
# | GOT | OP | CHECK |
# +-----+----+-------+
# | 22 | eq | 2 |
# +-----+----+-------+
# Failed test '$! is ENOENT for a readlink(undef)'
# at t/readlink.t line 58.
# +-----+----+-------+
# | GOT | OP | CHECK |
# +-----+----+-------+
# | 22 | eq | 2 |
# +-----+----+-------+
# Seeded srand with seed '20211227' from local date.
t/readlink.t ............
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/32 subtests
The problem can be reproduced with a oneliner:
$ perl -e 'readlink(undef); warn "$!"'
Invalid argument at -e line 1.
On freebsd 12 and older (and linux systems) it looks differently:
$ perl -e 'readlink(undef); warn "$!"'
No such file or directory at -e line 1.
my $f = Test::MockFile->file("/abc", "content");
open(my $fh, "<", "/abc");
open(my $fh2, "<", "/abc"); # This'll break stuff.
When creating a symlink file controlled by Test::MockFile calling symlink
later would not update its location as show in the example below. readlink
is returning an accurate value
use Test::More;
use Test::MockFile;
{
# unmocked version
# cleanup on startup
unlink('/bin/foo');
unlink('/not/there');
# create a symlink
ok symlink( '/not-there', '/bin/foo' );
ok -l '/bin/foo';
is readlink('/bin/foo'), '/not-there';
ok !-e '/bin/foo';
ok unlink('/bin/foo');
ok !-l '/bin/foo';
ok symlink( '/abcd', '/bin/foo' );
is readlink('/bin/foo'), '/abcd', 'symlink now points to /abcd';
}
{
# now testing with MockFile
# cleanup
unlink('/bin/foo');
unlink('/not/there');
# we want to take control of that file and set it as a symlink
my $mock_bin_foo = Test::MockFile->symlink( "/not-there", "/bin/foo" );
ok -l '/bin/foo';
is readlink('/bin/foo'), '/not-there';
ok !-e '/bin/foo';
ok unlink('/bin/foo');
ok !-l '/bin/foo';
ok symlink( '/abcd', '/bin/foo' );
is readlink('/bin/foo'), '/abcd', 'symlink now points to /abcd';
# ^^ symlink on a Test::MockFile symlinked file is not updating its location
}
done_testing;
output
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8 - symlink now points to /abcd
ok 9
ok 10
ok 11
ok 12
ok 13
ok 14
not ok 15 - symlink now points to /abcd
# Failed test 'symlink now points to /abcd'
# at test.t line X.
# got: undef
# expected: '/abcd'
1..15
# Caught exception in subtest: Use of stat to access unmocked file or directory 'GLOB(0x2fbca30)' in strict mode at …
There’s no reason to block this stat() since the file is already open()ed. If the test allowed the open(), then the stat() should also be allowed.
> perl -MTest::MockFile -e'my $m = Test::MockFile->file("/haha"); open my $h, ">", "/haha"; print {$h} "one\ntwo\nthree"; close $h; open my $rh, "<", "/haha"; print <$rh>'
one
The section for Mock Stats is missing the closing parenthesis for the new(), after the } and before the ;
Also, it appears that example should use ->file() rather than ->new(), as new fails with 3 args as provided in the doc.
$>perl -Mautodie -MTest::MockFile -E'my $file = "/log"; my $logg = Test::MockFile->file( $file, "one\ntwo\n"); open(my $fh, "<", $file) or die($!); say <$fh>'
Can't open '/log' for reading: 'No such file or directory' at -e line 1
190503.133746 [email protected] (/usr/local/cpanel)
$>perl -MTest::MockFile -E'my $file = "/log"; my $logg = Test::MockFile->file( $file, "one\ntwo\n"); open(my $fh, "<", $file) or die($!); say <$fh>'
one
two
#!/usr/local/cpanel/3rdparty/bin/perl
use strict;
use warnings;
use Test::MockFile;
my $mock_obj = Test::MockFile->dir( '/some/dir' );
$mock_obj->contents( [ qw/uh like whut/ ] );
my $mock_obj2 = Test::MockFile->dir( '/some/dir2', [qw/uno dos tres/] );
foreach my $mock( $mock_obj, $mock_obj2 ) {
print "--[ $mock->{'file_name'} ]----------\n";
if( opendir( my $dh, $mock->{'file_name'} ) ) {
while( my $file = readdir $dh ) {
print "- $file\n";
}
closedir( $dh );
} else {
print "cannah do iht capt'n\n";
}
}
--[ /some/dir ]----------
- uh
- like
- whut
--[ /some/dir2 ]----------
- .
- ..
- uno
- dos
- tres
#!/usr/bin/perl
use strict;
use warnings;
use Test::MockFile;
my $mock_obj = Test::MockFile->dir( '/path', [qw/uh like whut/] );
if ( opendir( my $dh, $mock_obj->{'file_name'} ) ) {
print "opened dir $mock_obj->{'file_name'}\n";
while ( readdir $dh ) {
print "- $_\n";
}
closedir($dh);
}
else {
print "cannah do iht capt'n\n";
}
$>perl foo.pl
opened dir /path
Use of uninitialized value $_ in concatenation (.) or string at foo.pl line 12.
-
Use of uninitialized value $_ in concatenation (.) or string at foo.pl line 12.
-
Use of uninitialized value $_ in concatenation (.) or string at foo.pl line 12.
-
Use of uninitialized value $_ in concatenation (.) or string at foo.pl line 12.
-
Use of uninitialized value $_ in concatenation (.) or string at foo.pl line 12.
-
This could be a bug in Overload::FileCheck not sure at this time
use Test::MockFile;
use File::Find;
sub f {
my @list;
File::Find::find(
{ no_chdir => 1,
wanted => sub { }
},
'/dir'
);
return \@list;
}
my @a;
push @a, @{ f() };
this is raising a warning from Overload::FileCheck
Bizarre copy of ARRAY in list assignment at /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/x86_64-linux-64int/Overload/FileCheck.pm line 579.
When testing a module that includes sysseek() the SEEK() method was returning 1 on success like seek(), but this breaks sysseek() since it expects SEEK() to return the new position, not success or failure.
Here is an example that illustrates the problem:
perl -e '
use Test::More;
use Test::MockFile;
my $mock = Test::MockFile->file("/fake", "hello world");
if (open(my $fh, "<", "/fake")) {
ok seek($fh, 6, 0), "seek returns truthful when successful.";
is sysseek($fh, 6, 0), 6, "sysseek returns new position when successful.";
}
'
The second assertion fails since SEEK return 1 no matter what position you seek. It seems like it need to return the new position in addition to setting the new position.
With a non-English locale (e.g.LC_ALL=de_DE.UTF-8
) and an older perl (<5.22) the test suite fails:
# Failed test '$! text is right.'
# at t/dir.t line 40.
# +--------------------------------+----+--------------------------------+
# | GOT | OP | CHECK |
# +--------------------------------+----+--------------------------------+
# | Datei oder Verzeichnis nicht g | eq | No such file or directory |
# | efunden | | |
# +--------------------------------+----+--------------------------------+
# Seeded srand with seed '20181025' from local date.
t/dir.t ...........
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/30 subtests
...
# Failed test '$! text message'
# at t/mock_stat.t line 60.
# Unicode::GCString is not installed, table may not display all unicode characters properly
# +--------------------------------+----+--------------------------------+
# | GOT | OP | CHECK |
# +--------------------------------+----+--------------------------------+
# | Zu viele symbolische Links (zi | eq | Too many levels of symbolic li |
# | rkulär?) | | nks |
# +--------------------------------+----+--------------------------------+
# Seeded srand with seed '20181025' from local date.
t/mock_stat.t .....
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/26 subtests
The test case 'unlink on a existing directory' seems to fail with older perls (5.18.4 and older):
# Failed test '$! is set to EISDIR'
# at t/unlink.t line 47.
# +-----+----+-------+
# | GOT | OP | CHECK |
# +-----+----+-------+
# | 2 | eq | 1 |
# +-----+----+-------+
# Failed test 'unlink on a existing directory'
# at t/unlink.t line 49.
# Seeded srand with seed '20211228' from local date.
t/unlink.t ..............
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/4 subtests
See also http://matrix.cpantesters.org/?dist=Test-MockFile%200.022 for an overview.
TestMe.pm
somewhere in @INC
.package TestMe;
use strict;
use warnings;
sub dir {
opendir DH, ".";
}
1;
Can't use string ("DH") as a symbol ref while "strict refs" in use at …
While we could update TestMe.pm (w/ a no strict "refs";
before the opendir
or better yet to not use a bareword handle) that won't help anyone who needs to use a module they have no control over.
The following one-liner raises a modification of a read-only value
$> perl -MTest::MockFile -E 'use File::Find;
my $d = Test::MockFile->dir( q[/dir], [ "file" ] );
File::Find::find( { no_chdir => 1, wanted => sub { 1 } }, "/dir" )'
# [
# 267,
# '/dir'
# ]
Modification of a read-only value attempted at /usr/local/cpanel/3rdparty/perl/528/lib/perl5/cpanel_lib/Test/MockFile.pm line 1157.
seems to come from *CORE::GLOBAL::opendir override
# This isn't a real IO::Dir.
$_[0] = Test::MockFile::DirHandle->new( $abs_path, $mock_dir->{'contents'} );
On some of my smokers the test suite fails like this:
************************************************************************
* COULD NOT LOAD FORMATTER 'Test2::Formatter::TAP' (default formatter) *
************************************************************************
Bareword "STDOUT" not allowed while "strict subs" in use at /opt/perl-5.18.4/lib/site_perl/5.18.4/Test2/Formatter/TAP.pm line 121.
Bareword "STDERR" not allowed while "strict subs" in use at /opt/perl-5.18.4/lib/site_perl/5.18.4/Test2/Formatter/TAP.pm line 125.
Compilation failed in require at /opt/perl-5.18.4/lib/site_perl/5.18.4/Test2/API/Instance.pm line 128.
t/dir.t ...........
Dubious, test returned 255 (wstat 65280, 0xff00)
No subtests run
(t/mock_stat.t and t/sysopen.t fail with the same error)
This seems to happen if older Test::More is installed:
****************************************************************
Regression 'mod:Test::More'
****************************************************************
Name Theta StdErr T-stat
[0='const'] -0.0000 0.0000 -2.80
[1='eq_1.302056'] 0.0000 0.0000 2.69
[2='eq_1.302073'] 0.0000 0.0000 2.64
[3='eq_1.302075'] 0.0000 0.0000 2.64
[4='eq_1.302078'] 0.0000 0.0000 1.08
[5='eq_1.302083'] 0.0000 0.0000 1.62
[6='eq_1.302086'] 1.0000 0.0000 9698626133968694.00
[7='eq_1.302096'] 1.0000 0.0000 13012072394345986.00
[8='eq_1.302106'] 1.0000 0.0000 9698626133968692.00
[9='eq_1.302133'] 1.0000 0.0000 9698626133968692.00
[10='eq_1.302136'] 1.0000 0.0000 14197334927460896.00
[11='eq_1.302140'] 1.0000 0.0000 14547939200953038.00
R^2= 1.000, N= 26, K= 12
****************************************************************
With 0.002 it seems to fail on all systems:
Bailout called. Further testing stopped:
# Failed test 'use Test::MockFile;'
# at t/00-load.t line 10.
# Tried to use 'Test::MockFile'.
# Error: Can't modify constant item in scalar assignment at /home/cpansand/.cpan/build/2018102415/Test-MockFile-0.002-GpBvmb/blib/lib/Test/MockFile.pm line 16, near "O_NOFOLLOW;"
# BEGIN not safe after errors--compilation aborted at /home/cpansand/.cpan/build/2018102415/Test-MockFile-0.002-GpBvmb/blib/lib/Test/MockFile.pm line 16.
# Compilation failed in require at t/00-load.t line 10.
# BEGIN failed--compilation aborted at t/00-load.t line 10.
Use of uninitialized value $Test::MockFile::VERSION in concatenation (.) or string at t/00-load.t line 13.
# Testing Test::MockFile , Perl 5.022002, /usr/perl5.22.2t/bin/perl
# Looks like you failed 1 test of 1.
FAILED--Further testing stopped.
*** Error code 1
See subject. A sample fail report: http://www.cpantesters.org/cpan/report/c3960358-e403-11e8-98d5-bb14e5798fec
This seems to happen only with perl 5.10.1.
Unexpected warning: Use of uninitialized value $_ in concatenation (.) or string at Test/MockFile/FileHandle.pm line 101.
Currently we don't check perms with file access. Given we're providing modes, we might as well check current UID/GID and do the right fail if necessary.
Currently open will not follow symlinks. This is not how Perl behaves so we need to fix it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.