Skip to content

Commit c6e9b3f

Browse files
committed
Satisfy perltidy
1 parent 34badd2 commit c6e9b3f

File tree

2 files changed

+74
-35
lines changed

2 files changed

+74
-35
lines changed

lib/Rex/CLI.pm

+1
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ sub load_rexfile {
761761
if (@warnings) {
762762
Rex::Logger::info( "You have some code warnings:", 'warn' );
763763
for (@warnings) {
764+
764765
# remove /loader/.../ prefix before filename
765766
s|/loader/[^/]+/||;
766767
Rex::Logger::info( "\t$_", 'warn' );

t/load_rexfile.t

+73-35
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ use File::Spec;
99
use Rex::CLI;
1010

1111
#diag 'create some rexfiles to test...';
12-
my $fh = undef;
13-
my $testdir = File::Temp->newdir('rextest.XXXX', TMPDIR => 1, CLEANUP => 1);
12+
my $fh = undef;
13+
my $testdir = File::Temp->newdir( 'rextest.XXXX', TMPDIR => 1, CLEANUP => 1 );
1414
while (<DATA>) {
1515
last if /^__END__$/;
1616
if (/^@@ *(\S+)$/) {
17+
1718
#diag "prepare file $1";
1819
close($fh) if $fh;
19-
open($fh, '>', File::Spec->catfile($testdir, $1)) or die $!;
20+
open( $fh, '>', File::Spec->catfile( $testdir, $1 ) ) or die $!;
2021
next;
2122
}
2223
print $fh $_ if $fh;
@@ -36,78 +37,113 @@ use warnings 'redefine';
3637
$::QUIET = 1;
3738

3839
#$Rex::Logger::no_color = 1;
39-
my $logfile = File::Spec->catfile($testdir, 'log');
40+
my $logfile = File::Spec->catfile( $testdir, 'log' );
4041
Rex::Config->set_log_filename($logfile);
4142

42-
4343
# NOW TEST
4444

4545
# No Rexfile warning (via Rex::Logger)
46-
Rex::CLI::load_rexfile(File::Spec->catfile($testdir, 'no_Rexfile'));
46+
Rex::CLI::load_rexfile( File::Spec->catfile( $testdir, 'no_Rexfile' ) );
4747
my $content = _get_log();
48-
like($content, qr/WARN - No Rexfile found/, 'No Rexfile warning (via logger)');
48+
like( $content, qr/WARN - No Rexfile found/,
49+
'No Rexfile warning (via logger)' );
4950

5051
# Valid Rexfile
5152
_reset_test();
5253
output_like {
53-
Rex::CLI::load_rexfile(File::Spec->catfile($testdir, 'Rexfile_noerror'));
54-
} qr/^$/, qr/^$/, 'No stdout/stderr messages on valid Rexfile';
54+
Rex::CLI::load_rexfile( File::Spec->catfile( $testdir, 'Rexfile_noerror' ) );
55+
}
56+
qr/^$/, qr/^$/, 'No stdout/stderr messages on valid Rexfile';
5557
$content = _get_log();
56-
is($content, '', 'No warnings on valid Rexfile (via logger)');
58+
is( $content, '', 'No warnings on valid Rexfile (via logger)' );
5759

5860
# Rexfile with warnings
5961
_reset_test();
6062
output_like {
61-
Rex::CLI::load_rexfile(File::Spec->catfile($testdir, 'Rexfile_warnings'));
62-
} qr/^$/, qr/^$/, 'No stdout/stderr messages on Rexfile with warnings';
63+
Rex::CLI::load_rexfile( File::Spec->catfile( $testdir, 'Rexfile_warnings' ) );
64+
}
65+
qr/^$/, qr/^$/, 'No stdout/stderr messages on Rexfile with warnings';
6366
$content = _get_log();
64-
ok(!$exit_was_called, 'sub load_rexfile() not exit');
65-
like($content, qr/WARN - You have some code warnings/, 'Code warnings via logger');
66-
like($content, qr/This is warning/, 'warn() warning via logger');
67-
like($content, qr/Use of uninitialized value \$undef/, 'perl warning via logger');
68-
unlike($content, qr#at /loader/0x#, 'loader prefix is filtered in warnings report');
67+
ok( !$exit_was_called, 'sub load_rexfile() not exit' );
68+
like(
69+
$content,
70+
qr/WARN - You have some code warnings/,
71+
'Code warnings via logger'
72+
);
73+
like( $content, qr/This is warning/, 'warn() warning via logger' );
74+
like(
75+
$content,
76+
qr/Use of uninitialized value \$undef/,
77+
'perl warning via logger'
78+
);
79+
unlike(
80+
$content,
81+
qr#at /loader/0x#,
82+
'loader prefix is filtered in warnings report'
83+
);
6984

7085
# Rexfile with fatal errors
7186
_reset_test();
7287
output_like {
73-
Rex::CLI::load_rexfile(File::Spec->catfile($testdir, 'Rexfile_fatal'));
74-
} qr/^$/, qr/^$/, 'No stdout/stderr messages on Rexfile with errors';
88+
Rex::CLI::load_rexfile( File::Spec->catfile( $testdir, 'Rexfile_fatal' ) );
89+
}
90+
qr/^$/, qr/^$/, 'No stdout/stderr messages on Rexfile with errors';
7591
$content = _get_log();
76-
ok($exit_was_called, 'sub load_rexfile() aborts');
77-
like($content, qr/ERROR - Compile time errors/, 'Fatal errors via logger');
78-
like($content, qr/syntax error at/, 'syntax error is fatal error via logger');
79-
unlike($content, qr#at /loader/0x#, 'loader prefix is filtered in errors report');
92+
ok( $exit_was_called, 'sub load_rexfile() aborts' );
93+
like( $content, qr/ERROR - Compile time errors/, 'Fatal errors via logger' );
94+
like( $content, qr/syntax error at/, 'syntax error is fatal error via logger' );
95+
unlike(
96+
$content,
97+
qr#at /loader/0x#,
98+
'loader prefix is filtered in errors report'
99+
);
80100

81101
# Now print messages to STDERR/STDOUT
82102
# Valid Rexfile
83103
_reset_test();
84104
output_like {
85-
Rex::CLI::load_rexfile(File::Spec->catfile($testdir, 'Rexfile_noerror_print'));
86-
} qr/^This is STDOUT message$/, qr/^This is STDERR message$/, 'Correct stdout/stderr messages printed from valid Rexfile';
105+
Rex::CLI::load_rexfile(
106+
File::Spec->catfile( $testdir, 'Rexfile_noerror_print' ) );
107+
}
108+
qr/^This is STDOUT message$/, qr/^This is STDERR message$/,
109+
'Correct stdout/stderr messages printed from valid Rexfile';
87110
$content = _get_log();
88-
is($content, '', 'No warnings via logger on valid Rexfile that print messages');
111+
is( $content, '',
112+
'No warnings via logger on valid Rexfile that print messages' );
89113

90114
# Rexfile with warnings
91115
_reset_test();
92116
output_like {
93-
Rex::CLI::load_rexfile(File::Spec->catfile($testdir, 'Rexfile_warnings_print'));
94-
} qr/^This is STDOUT message$/, qr/^This is STDERR message$/, 'Correct stdout/stderr messages printed from Rexfile with warnings';
117+
Rex::CLI::load_rexfile(
118+
File::Spec->catfile( $testdir, 'Rexfile_warnings_print' ) );
119+
}
120+
qr/^This is STDOUT message$/, qr/^This is STDERR message$/,
121+
'Correct stdout/stderr messages printed from Rexfile with warnings';
95122
$content = _get_log();
96-
like($content, qr/WARN - You have some code warnings/, 'Code warnings exist via logger');
123+
like(
124+
$content,
125+
qr/WARN - You have some code warnings/,
126+
'Code warnings exist via logger'
127+
);
97128

98129
# Rexfile with fatal errors
99130
_reset_test();
100131
output_like {
101-
Rex::CLI::load_rexfile(File::Spec->catfile($testdir, 'Rexfile_fatal_print'));
102-
} qr/^$/, qr/^$/, 'No stdout/stderr messages printed from Rexfile that has errors';
132+
Rex::CLI::load_rexfile(
133+
File::Spec->catfile( $testdir, 'Rexfile_fatal_print' ) );
134+
}
135+
qr/^$/, qr/^$/,
136+
'No stdout/stderr messages printed from Rexfile that has errors';
103137
$content = _get_log();
104-
ok($exit_was_called, 'sub load_rexfile() aborts');
105-
like($content, qr/ERROR - Compile time errors/, 'Fatal errors exist via logger');
106-
138+
ok( $exit_was_called, 'sub load_rexfile() aborts' );
139+
like(
140+
$content,
141+
qr/ERROR - Compile time errors/,
142+
'Fatal errors exist via logger'
143+
);
107144

108145
done_testing;
109146

110-
111147
# from logger.t
112148
sub _get_log {
113149
local $/;
@@ -121,9 +157,11 @@ sub _get_log {
121157

122158
sub _reset_test {
123159
$exit_was_called = undef;
160+
124161
# reset log
125162
open my $fh, '>', $logfile or die $!;
126163
close $fh;
164+
127165
# reset require
128166
delete $INC{'__Rexfile__.pm'};
129167
}

0 commit comments

Comments
 (0)