From 3950a92003503d7b47c406a17bb17216089349e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C5=8Dan?= Date: Thu, 12 Mar 2026 13:35:56 -0600 Subject: [PATCH] fix: add missing _throw_autodie calls for link ELOOP and rename ENOTEMPTY __link's CIRCULAR_SYMLINK error path and __rename's ENOTEMPTY error path both set $! but skipped _throw_autodie(), breaking autodie compatibility. Also removes dead $set_error variable in __chown (declared but never set). Co-Authored-By: Claude Opus 4.6 --- lib/Test/MockFile.pm | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/Test/MockFile.pm b/lib/Test/MockFile.pm index 86e3781..91da76c 100644 --- a/lib/Test/MockFile.pm +++ b/lib/Test/MockFile.pm @@ -3410,6 +3410,7 @@ sub __link ($$) { } if ( $target_path eq CIRCULAR_SYMLINK ) { $! = ELOOP; + _throw_autodie( 'link', @_ ) if _caller_has_autodie_for('link'); return 0; } $source_mock = $files_being_mocked{$target_path}; @@ -3626,6 +3627,7 @@ sub __rename ($$) { if ( $mock_old->is_dir && $mock_new->exists && $mock_new->is_dir ) { if ( grep { $_->exists } _files_in_dir( $mock_new->{'path'} ) ) { $! = ENOTEMPTY; + _throw_autodie( 'rename', @_ ) if _caller_has_autodie_for('rename'); return 0; } } @@ -3746,7 +3748,6 @@ sub __chown (@) { } } - my $set_error; my $num_changed = 0; foreach my $file (@files) { my $mock = $mocked_files{$file}; @@ -3761,23 +3762,17 @@ sub __chown (@) { # Handle broken/circular symlink errors if ( ref $mock eq 'A::BROKEN::SYMLINK' ) { - $set_error - or $! = ENOENT; + $! = ENOENT; next; } if ( ref $mock eq 'A::CIRCULAR::SYMLINK' ) { - $set_error - or $! = ELOOP; + $! = ELOOP; next; } # Even if you're root, nonexistent file is nonexistent if ( !$mock->exists() ) { - - # Only set the error once - $set_error - or $! = ENOENT; - + $! = ENOENT; next; }