Skip to content
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

Test::MockFile corrupts glob #158

Open
atoomic opened this issue Feb 18, 2022 · 0 comments
Open

Test::MockFile corrupts glob #158

atoomic opened this issue Feb 18, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@atoomic
Copy link
Contributor

atoomic commented Feb 18, 2022

In this case Test::MockFile is loaded in no strict mode but unused...
it's corrupting the output from glob...

#!perl

use strict;
use warnings;

use Test2::Bundle::Extended;
use Test2::Tools::Explain;
use Test2::Plugin::NoWarnings;

use File::Temp;

use Test::MockFile qw< nostrict >; # comment this line to get the expected behavior

my $dir = File::Temp->newdir;

my $log_file = "$dir/file.log";

open( my $fh, '>', $log_file );
print {$fh} "...";
close $fh;

my @logs = glob "$dir/*.log";
is \@logs, [ $log_file ];

done_testing;

Output

╰─> prove -v t/glob-issue.t
t/glob-issue.t ..
# Seeded srand with seed '20220218' from local date.
not ok 1
1..1

# Failed test at t/glob-issue.t line 23.
# +------+------------------+--------------------------+
# | PATH | GOT              | CHECK                    |
# +------+------------------+--------------------------+
# | [0]  | <DOES NOT EXIST> | /tmp/b0uZlOrzfq/file.log |
# +------+------------------+--------------------------+
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests

Test Summary Report
-------------------
t/glob-issue.t (Wstat: 256 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
Files=1, Tests=1,  0 wallclock secs ( 0.03 usr  0.01 sys +  0.14 cusr  0.01 csys =  0.19 CPU)
Result: FAIL
atoomic added a commit to atoomic/Test-MockFile that referenced this issue Feb 18, 2022
Add reproduction test for cpanel#158
@xsawyerx xsawyerx added the bug Something isn't working label Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants