From ffc7cee0d1a03464f981c06edd99ddf91651d276 Mon Sep 17 00:00:00 2001 From: Guillaume Bougard Date: Mon, 10 Jun 2024 15:34:34 +0200 Subject: [PATCH] test: Fix skipped tests under MSWin32 --- t/agent/tools/archive.t | 52 ++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/t/agent/tools/archive.t b/t/agent/tools/archive.t index 21764ad82..dd7ee8e71 100644 --- a/t/agent/tools/archive.t +++ b/t/agent/tools/archive.t @@ -18,10 +18,6 @@ use GLPI::Agent::Config; use GLPI::Agent::Logger; use GLPI::Agent::Tools::Archive; -if ($OSNAME eq 'MSWin32') { - plan skip_all => 'not working on Windows, but tested module not used on Windows'; -} - my %archives = ( 'tar' => { file => "config.tar", @@ -79,31 +75,35 @@ my $logger = GLPI::Agent::Logger->new( ) ); -foreach my $test (keys %archives) { - my $folder = tempdir(CLEANUP => 1); - my $file = "resources/archive/". $archives{$test}->{file}; - ; +SKIP: { + skip 'not working on Windows, but tested module not used on Windows', 4 * (scalar keys %archives) + if $OSNAME eq 'MSWin32'; - my $archive; - lives_ok { - $archive = GLPI::Agent::Tools::Archive->new( - archive => $file, - type => $archives{$test}->{type} // "", - logger => $logger, - ); - } "$test: archive object"; + foreach my $test (keys %archives) { + my $folder = tempdir(CLEANUP => 1); + my $file = "resources/archive/". $archives{$test}->{file}; - lives_ok { - $archive->extract(to => $folder); - } "$test: archive extract"; + my $archive; + lives_ok { + $archive = GLPI::Agent::Tools::Archive->new( + archive => $file, + type => $archives{$test}->{type} // "", + logger => $logger, + ); + } "$test: archive object"; - $file = File::Spec->catfile($folder, $archives{$test}->{check}); - ok(-e $file, "$test: extracted file"); + lives_ok { + $archive->extract(to => $folder); + } "$test: archive extract"; - if (-e $file) { - my $sha = Digest::SHA->new(256)->addfile($file); - is($sha->hexdigest, $archives{$test}->{sha256}, "$test: sha256 checked file"); - } else { - fail "$test: sha256 checked file with missing file"; + $file = File::Spec->catfile($folder, $archives{$test}->{check}); + ok(-e $file, "$test: extracted file"); + + if (-e $file) { + my $sha = Digest::SHA->new(256)->addfile($file); + is($sha->hexdigest, $archives{$test}->{sha256}, "$test: sha256 checked file"); + } else { + fail "$test: sha256 checked file with missing file"; + } } }