Skip to content

Commit

Permalink
Merge pull request #1619 from RexOps/fail_tests_on_warnings
Browse files Browse the repository at this point in the history
Fix test suite warnings
  • Loading branch information
ferki committed Aug 23, 2024
2 parents c5325d5 + f3a91ff commit 5552341
Show file tree
Hide file tree
Showing 82 changed files with 179 additions and 83 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Revision history for Rex
[API CHANGES]

[BUG FIXES]
- Return only the first found command

[DOCUMENTATION]

Expand Down
8 changes: 4 additions & 4 deletions lib/Rex/Interface/Exec/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ sub can_run {
return $cache->get($cache_key_name);
}

my $output = Rex::Helper::Run::i_run "$check_with_command $command",
my @output = Rex::Helper::Run::i_run "$check_with_command $command",
fail_ok => 1;

next if ( $? != 0 );

next if ( !is_file($output) );
next if ( !is_file( $output[0] ) );

$cache->set( $cache_key_name, $output );
$cache->set( $cache_key_name, $output[0] );

return $output;
return $output[0];
}

return undef;
Expand Down
3 changes: 2 additions & 1 deletion t/0.31.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 139;
use Test::More tests => 140;
use Test::Warnings;

use Rex -feature => '0.31';

Expand Down
3 changes: 2 additions & 1 deletion t/0.54.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 13;
use Test::More tests => 14;
use Test::Warnings;

use Rex -feature => '0.54';

Expand Down
3 changes: 2 additions & 1 deletion t/01.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 3;
use Test::More tests => 4;
use Test::Warnings;

use Rex::Commands;

Expand Down
1 change: 1 addition & 0 deletions t/args.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use warnings;
our $VERSION = '9999.99.99_99'; # VERSION

use Test::More;
use Test::Warnings;

use Rex::Args;

Expand Down
3 changes: 2 additions & 1 deletion t/auth.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 48;
use Test::More tests => 49;
use Test::Warnings;

use Rex::Commands;
use Rex::Group;
Expand Down
3 changes: 2 additions & 1 deletion t/base_virt.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 2;
use Test::More tests => 3;
use Test::Warnings;

use Rex::Virtualization;

Expand Down
3 changes: 2 additions & 1 deletion t/batch.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 2;
use Test::More tests => 3;
use Test::Warnings;
use Rex::Commands;
use Rex::Batch;

Expand Down
1 change: 1 addition & 0 deletions t/before_all_tasks.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use lib 't/lib';
our $VERSION = '9999.99.99_99'; # VERSION

use Test::More;
use Test::Warnings;
use Test::Deep;

use Rex::Commands;
Expand Down
3 changes: 2 additions & 1 deletion t/can_run.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 4;
use Test::More tests => 5;
use Test::Warnings;

use Rex::Commands::Run;

Expand Down
3 changes: 2 additions & 1 deletion t/case.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 7;
use Test::More tests => 8;
use Test::Warnings;
use Rex::Commands;

my $test = "Debian";
Expand Down
3 changes: 2 additions & 1 deletion t/cmdb.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 2;
use Test::More tests => 3;
use Test::Warnings;

use Cwd qw(realpath);
use File::Spec;
Expand Down
3 changes: 2 additions & 1 deletion t/cmdb_path.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 3;
use Test::More tests => 4;
use Test::Warnings;

use Cwd qw(realpath);
use File::Spec;
Expand Down
3 changes: 2 additions & 1 deletion t/commands.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 18;
use Test::More tests => 19;
use Test::Warnings;

use Rex::Commands;

Expand Down
3 changes: 2 additions & 1 deletion t/commands/evaluate_hostnames.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 9;
use Test::More tests => 10;
use Test::Warnings;
use Rex::Commands;

my %tests = (
Expand Down
3 changes: 2 additions & 1 deletion t/commands/iptables.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 32;
use Test::More tests => 33;
use Test::Warnings;

use Rex::Commands::Iptables;

Expand Down
3 changes: 2 additions & 1 deletion t/commands_file_template.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 4;
use Test::More tests => 5;
use Test::Warnings;

use File::Basename;

Expand Down
3 changes: 2 additions & 1 deletion t/config-ssh.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use warnings;
our $VERSION = '9999.99.99_99'; # VERSION

use File::Temp;
use Test::More tests => 21;
use Test::More tests => 22;
use Test::Warnings;

use Rex::Config;

Expand Down
3 changes: 2 additions & 1 deletion t/config.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 10;
use Test::More tests => 11;
use Test::Warnings;

use Cwd qw(realpath);
use Rex::Config;
Expand Down
3 changes: 2 additions & 1 deletion t/cron.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use warnings;
our $VERSION = '9999.99.99_99'; # VERSION

use Test::More;
use Test::Warnings;

$^O =~ m/^MSWin/ ? plan tests => 83 : plan tests => 286;
$^O =~ m/^MSWin/ ? plan tests => 84 : plan tests => 287;

use Rex::Cron::Base;

Expand Down
3 changes: 2 additions & 1 deletion t/db.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ our $VERSION = '9999.99.99_99'; # VERSION

BEGIN {
use Test::More;
use Test::Warnings;
use Data::Dumper;

eval "use DBI; 1" or plan skip_all => "Could not load DBI module";
Expand All @@ -29,7 +30,7 @@ my $mysqld = Test::mysqld->new(
plan skip_all => $Test::mysqld::errstr;
};

plan tests => 38;
plan tests => 39;

$dbh = DBI->connect( $mysqld->dsn( dbname => 'test' ), );
Rex::Commands::DB->import( { dsn => $mysqld->dsn( dbname => 'test' ) } );
Expand Down
3 changes: 2 additions & 1 deletion t/df.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 36;
use Test::More tests => 37;
use Test::Warnings;

use Rex::Commands::Fs;

Expand Down
3 changes: 2 additions & 1 deletion t/dmi.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 31;
use Test::More tests => 32;
use Test::Warnings;

use Rex::Inventory::DMIDecode;

Expand Down
3 changes: 2 additions & 1 deletion t/do_task.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use warnings;
our $VERSION = '9999.99.99_99'; # VERSION

use Rex::Commands;
use Test::More tests => 4;
use Test::More tests => 5;
use Test::Warnings;

eval { Rex::Commands::do_task("non_existing_task"); };
my $result = $@;
Expand Down
3 changes: 2 additions & 1 deletion t/env.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 1;
use Test::More tests => 2;
use Test::Warnings;

use Rex::Commands::Run;

Expand Down
3 changes: 2 additions & 1 deletion t/file.t
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ my $cwd = getcwd;
use File::Spec;
use File::Temp;

use Test::More tests => 61;
use Test::More tests => 62;
use Test::Warnings;

use Rex::Commands::File;
use Rex::Commands::Fs;
Expand Down
3 changes: 2 additions & 1 deletion t/file_hooks.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 3;
use Test::More tests => 4;
use Test::Warnings;
use Test::Deep;
use Test::Output;

Expand Down
3 changes: 2 additions & 1 deletion t/fs_files.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 13;
use Test::More tests => 14;
use Test::Warnings;

use Rex::Helper::Path;
use Rex::Commands::File;
Expand Down
3 changes: 2 additions & 1 deletion t/group.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 98;
use Test::More tests => 99;
use Test::Warnings;
use Test::Exception;

use Rex -feature => '0.31';
Expand Down
3 changes: 2 additions & 1 deletion t/helper_hash.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 6;
use Test::More tests => 7;
use Test::Warnings;

use Rex::Helper::Hash;

Expand Down
3 changes: 2 additions & 1 deletion t/helper_path.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 8;
use Test::More tests => 9;
use Test::Warnings;

use File::Basename;
use Cwd 'getcwd';
Expand Down
5 changes: 4 additions & 1 deletion t/hooks.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use warnings;
our $VERSION = '9999.99.99_99'; # VERSION

BEGIN {
use Test::More tests => 8;
use Test::More tests => 9;
use Test::Warnings qw(:no_end_test had_no_warnings);
use File::Temp;
use Rex::Commands;
use Rex::RunList;
Expand Down Expand Up @@ -49,3 +50,5 @@ is $after, 1, 'after hook';
is $after_all, 1, 'after ALL hook';
is $after_task_finished, 1, 'after_task_finished hook';
is $after_task_finished_all, 1, 'after_task_finished ALL hook';

had_no_warnings();
1 change: 1 addition & 0 deletions t/hooks_in_pkg.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use lib 't/lib';
our $VERSION = '9999.99.99_99'; # VERSION

use Test::More;
use Test::Warnings;
use Test::Deep;

use Rex::Commands;
Expand Down
5 changes: 4 additions & 1 deletion t/hooks_in_rexfile.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ use warnings;
our $VERSION = '9999.99.99_99'; # VERSION

BEGIN {
use Test::More tests => 8;
use Test::More tests => 9;
use Test::Warnings qw(:no_end_test had_no_warnings);
use File::Temp;
use Rex::Commands;
use Rex::RunList;
Expand Down Expand Up @@ -52,3 +53,5 @@ is $after, 1, 'after hook';
is $after_all, 1, 'after ALL hook';
is $after_task_finished, 1, 'after_task_finished hook';
is $after_task_finished_all, 1, 'after_task_finished ALL hook';

had_no_warnings();
5 changes: 4 additions & 1 deletion t/hooks_in_rexfile_tasks_in_pkg.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use warnings;
our $VERSION = '9999.99.99_99'; # VERSION

BEGIN {
use Test::More tests => 8;
use Test::More tests => 9;
use Test::Warnings qw(:no_end_test had_no_warnings);
use lib 't/lib';
use t::tasks::alien;
use File::Temp;
Expand Down Expand Up @@ -52,3 +53,5 @@ is $after, 1, 'after hook';
is $after_all, 1, 'after ALL hook';
is $after_task_finished, 1, 'after_task_finished hook';
is $after_task_finished_all, 1, 'after_task_finished ALL hook';

had_no_warnings;
3 changes: 2 additions & 1 deletion t/host.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use warnings;

our $VERSION = '9999.99.99_99'; # VERSION

use Test::More tests => 10;
use Test::More tests => 11;
use Test::Warnings;

use Rex::Commands::Host;

Expand Down
Loading

0 comments on commit 5552341

Please sign in to comment.