Skip to content

Test::MockFile corrupts glob #158

Open
@atoomic

Description

@atoomic

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions