Skip to content

Commit

Permalink
Drop use of undeclared File::Touch dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
kalikiana committed Oct 31, 2024
1 parent ce26602 commit e134fff
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/OpenQA/Git.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;

Check warning on line 164 in lib/OpenQA/Git.pm

View check run for this annotation

Codecov / codecov/patch

lib/OpenQA/Git.pm#L161-L164

Added lines #L161 - L164 were not covered by tests
}
my @git = $self->_prepare_git_command;
Expand Down
13 changes: 10 additions & 3 deletions t/14-grutasks.t
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e134fff

Please sign in to comment.