Skip to content

Commit 61b60ef

Browse files
committed
Merge pull request #1563 from RexOps/rexfile_path
Expect original Rexfile path in messages
2 parents 1b4db2b + 0aef1e7 commit 61b60ef

8 files changed

+20
-20
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Revision history for Rex
1313
- Correct example for file_read command
1414

1515
[ENHANCEMENTS]
16+
- Show Rexfile path in loading messages
1617

1718
[MAJOR]
1819

lib/Rex/CLI.pm

+10-12
Original file line numberDiff line numberDiff line change
@@ -763,13 +763,9 @@ sub load_rexfile {
763763
for (@warnings) {
764764
chomp;
765765

766-
# remove /loader/.../ prefix before filename
767-
s{/loader/[^/]+/}{}sxm;
766+
my $message = _tidy_loading_message( $_, $rexfile );
768767

769-
# convert Rexfile to human-friendly name
770-
s{__Rexfile__.pm}{Rexfile}msx;
771-
772-
Rex::Logger::info( "\t$_", 'warn' );
768+
Rex::Logger::info( "\t$message", 'warn' );
773769
}
774770
}
775771

@@ -780,12 +776,7 @@ sub load_rexfile {
780776
my $e = $@;
781777
chomp $e;
782778

783-
# remove the strange path to the Rexfile which exists because
784-
# we load the Rexfile via our custom code block.
785-
$e =~ s|/loader/[^/]+/||smg;
786-
787-
# convert Rexfile to human-friendly name
788-
$e =~ s{__Rexfile__.pm}{Rexfile}msx;
779+
$e = _tidy_loading_message( $e, $rexfile );
789780

790781
my @lines = split( $/, $e );
791782

@@ -796,6 +787,13 @@ sub load_rexfile {
796787
}
797788
}
798789

790+
sub _tidy_loading_message {
791+
my ( $message, $rexfile ) = @_;
792+
793+
$message =~ s{/loader/[^/]+/__Rexfile__[.]pm}{$rexfile}gmsx;
794+
return $message;
795+
}
796+
799797
sub exit_rex {
800798
my ( $exit_code_override, $signal ) = @_;
801799

t/load_rexfile.t

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ sub _setup_test {
6868

6969
$expected->{$extension} = -r $file ? cat($file) : $default_content;
7070
$expected->{$extension} =~ s{%REX_CLI_PATH%}{$rex_cli_path}msx;
71+
$expected->{$extension} =~ s{%REXFILE_PATH%}{$rexfile}gmsx;
7172
}
7273

7374
# reset log

t/rexfiles/Rexfile_fatal.log

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ERROR - Compile time errors:
2-
ERROR - syntax error at Rexfile line 5, near "abc
2+
ERROR - syntax error at %REXFILE_PATH% line 5, near "abc
33
ERROR -
44
ERROR - task "
55
ERROR - Compilation failed in require at %REX_CLI_PATH% line 756.

t/rexfiles/Rexfile_fatal_print.log

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ERROR - Compile time errors:
2-
ERROR - syntax error at Rexfile line 8, near "abc
2+
ERROR - syntax error at %REXFILE_PATH% line 8, near "abc
33
ERROR -
44
ERROR - print"
55
ERROR - Compilation failed in require at %REX_CLI_PATH% line 756.

t/rexfiles/Rexfile_warnings.log

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
WARN - You have some code warnings:
2-
WARN - This is warning at Rexfile line 5.
3-
WARN - Use of uninitialized value in concatenation (.) or string at Rexfile line 6.
2+
WARN - This is warning at %REXFILE_PATH% line 5.
3+
WARN - Use of uninitialized value in concatenation (.) or string at %REXFILE_PATH% line 6.

t/rexfiles/Rexfile_warnings_print.log

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
WARN - You have some code warnings:
2-
WARN - This is warning at Rexfile line 5.
3-
WARN - Use of uninitialized value in concatenation (.) or string at Rexfile line 6.
2+
WARN - This is warning at %REXFILE_PATH% line 5.
3+
WARN - Use of uninitialized value in concatenation (.) or string at %REXFILE_PATH% line 6.
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
This is STDERR message
22
WARN - You have some code warnings:
3-
WARN - This is warning at Rexfile line 5.
4-
WARN - Use of uninitialized value in concatenation (.) or string at Rexfile line 6.
3+
WARN - This is warning at %REXFILE_PATH% line 5.
4+
WARN - Use of uninitialized value in concatenation (.) or string at %REXFILE_PATH% line 6.

0 commit comments

Comments
 (0)