diff --git a/lib/OpenQA/Git.pm b/lib/OpenQA/Git.pm index a62d93fec45..1d0ce5224d3 100644 --- a/lib/OpenQA/Git.pm +++ b/lib/OpenQA/Git.pm @@ -6,7 +6,7 @@ package OpenQA::Git; use Mojo::Base -base, -signatures; use Mojo::Util 'trim'; use Cwd 'abs_path'; -use File::Touch; +use Mojo::File 'path'; use OpenQA::Utils qw(run_cmd_with_log_return_error); has 'app'; @@ -160,7 +160,7 @@ sub is_workdir_clean ($self) { sub cache_ref ($self, $ref, $relative_path, $output_file) { if (-f $output_file) { - eval { touch $output_file }; + eval { path($output_file)->touch }; return $@ ? $@ : undef; } my @git = $self->_prepare_git_command; diff --git a/t/14-grutasks.t b/t/14-grutasks.t index d60f0ecccca..c76e2e3aea0 100644 --- a/t/14-grutasks.t +++ b/t/14-grutasks.t @@ -25,7 +25,6 @@ use OpenQA::Test::Case; use File::Which 'which'; use File::Path (); use Mojo::Util qw(dumper scope_guard); -use File::Touch (); use Date::Format 'time2str'; use Fcntl ':mode'; use Mojo::File qw(path tempdir); @@ -419,8 +418,16 @@ subtest 'limit_temp_needle_refs task cleans up temp needle refs exceeding retent my @old_needle_files = ("$temp_dir/ref1/needle_old.png", "$temp_dir/ref1/needle_old.json"); my @new_needle_files = ("$temp_dir/ref2/needle_new.png", "$temp_dir/ref2/needle_new.json"); my $now = time; - File::Touch->new(time => $now - (120 * ONE_MINUTE + 1))->touch(@old_needle_files); - File::Touch->new(time => $now + ONE_MINUTE)->touch(@new_needle_files); + my $old_timestamp = $now - (120 * ONE_MINUTE + 1); + my $new_timestamp = $now - ONE_MINUTE + 1; + foreach my $file (@old_needle_files) { + path($file)->touch; + utime $old_timestamp, $old_timestamp, $file; + } + foreach my $file (@new_needle_files) { + path($file)->touch; + utime $new_timestamp, $new_timestamp, $file; + } # enqueue and run cleanup my $minion = $t->app->minion;