feat: add utime() override for mocked files#196
feat: add utime() override for mocked files#196Koan-Bot wants to merge 4 commits intocpanel:masterfrom
Conversation
Implement CORE::GLOBAL::utime override so that utime() works on mocked files and is covered by strict mode. Follows the same pattern as chmod() and chown() overrides. When called on mocked files, updates atime, mtime, and sets ctime to current time. Supports undef for atime/mtime (uses current time, matching CORE::utime behavior). Detects mixed mocked/unmocked file lists. Fixes cpanel#172 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
view error from smokers |
Rebase: feat: add utime() override for mocked filesBranch Actions
Automated by Kōan |
|
Failure on Perl 5.26 also seen on 5.14 It s not related to the Perl version at first glance but we provide a file path instead of an expected number |
Rebase: feat: add utime() override for mocked filesBranch Actions
Automated by Kōan |
lib/Test/MockFile.pm
Outdated
| foreach my $file (@files) { | ||
| my $mock = $mocked_files{$file}; | ||
|
|
||
| if ( !$mock ) { |
There was a problem hiding this comment.
@Koan-Bot shouldn't this conditional happen prior to the for loop?
Rebase: feat: add utime() override for mocked filesBranch Actions
Automated by Kōan |
| _real_file_access_hook( 'utime', \@_ ); | ||
| goto \&CORE::utime if _goto_is_available(); | ||
| return CORE::utime( $atime, $mtime, @files ); | ||
| } |
There was a problem hiding this comment.
this is good but I think we should have also preserved the call and check later when $mocked_files{$file} is undefined then we should also fall back to the CORE::utime
Can we extend coverage when mock is enabled (no strict) to call utime on a mocked file but also on a none mocked file to cover that scenario line 2462 when my $mock = $mocked_files{$file}; is undef
|
@Koan-Bot rebase |
Summary
CORE::GLOBAL::utimeoverride soutime()works on mocked files and triggers strict mode violations on unmocked fileschmod()andchown()overridesutimetofile_arg_position_for_commandfor strict mode filename detectionDetails
When called on mocked files:
atimeandmtimeto the provided valuesctimeto current time (matching real filesystem behavior)undeffor atime/mtime (uses current time, likeCORE::utime)CORE::utimefor unmocked files in nostrict modeTests
t/utime.t: 9 subtests covering basic usage, ctime update, undef handling, multiple files, nonexistent files, directories, empty file list, mixed files, and passthrought/utime_strict.t: 2 subtests verifying strict mode violation on unmocked files and success on mocked filesFixes #172
🤖 Generated with Kōan