diff options
-rwxr-xr-x | t/22-race.t | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/t/22-race.t b/t/22-race.t index 7de17fd..335ef7c 100755 --- a/t/22-race.t +++ b/t/22-race.t @@ -11,7 +11,7 @@ use Capture::Tiny qw/ capture_merged /; use File::Temp 'tempdir'; use Cwd; -plan tests => 7; +plan tests => 8; sub emulate_race { my ($file, $caller) = @_; @@ -100,3 +100,23 @@ GIT system('rm', '-rf', $repo); system('mv', "$repo.bak", $repo); } + +# 8: emulate race in read_config +{ + my $conf_file = "/etc/sbotools/sbotools.conf"; + + mkdir "/etc/sbotools"; + rename $conf_file, "$conf_file.bak"; + system touch => $conf_file; + + no warnings 'redefine'; + + local *SBO::Lib::Util::open_read = sub { return undef, 1 }; + + my $out = capture_merged { SBO::Lib::Util::read_config(); }; + + is ($out, "Unable to open $conf_file.\n", "read_config() output correct"); + + unlink $conf_file; + rename "$conf_file.bak", $conf_file; +} |