texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/texi2any.pl (handle_errors): print line_nr i


From: Patrice Dumas
Subject: branch master updated: * tp/texi2any.pl (handle_errors): print line_nr if 0. Although it should not happen in practice.
Date: Mon, 21 Feb 2022 18:22:20 -0500

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new db45921ebf * tp/texi2any.pl (handle_errors): print line_nr if 0. 
Although it should not happen in practice.
db45921ebf is described below

commit db45921ebfbf5f2696d157ac96ed5742d2f31aa1
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Tue Feb 22 00:22:09 2022 +0100

    * tp/texi2any.pl (handle_errors): print line_nr if 0. Although
    it should not happen in practice.
    
    * tp/t/test_parse_texi_line.t, tp/t/test_parser_registrar.t,
    tp/t/test_protect_hashchar_at_line_beginning.t: check line error
    messages line numbers.
---
 ChangeLog                                      |  9 +++++++++
 tp/t/test_parse_texi_line.t                    | 20 ++++++++++++--------
 tp/t/test_parser_registrar.t                   | 14 +++++++++++---
 tp/t/test_protect_hashchar_at_line_beginning.t | 14 +++++++++-----
 tp/texi2any.pl                                 |  2 +-
 5 files changed, 42 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ea1c589066..9257d794af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-02-21  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/texi2any.pl (handle_errors): print line_nr if 0. Although
+       it should not happen in practice.
+
+       * tp/t/test_parse_texi_line.t, tp/t/test_parser_registrar.t,
+       tp/t/test_protect_hashchar_at_line_beginning.t: check line error
+       messages line numbers.
+
 2022-02-21  Gavin Smith  <gavinsmith0123@gmail.com>
 
        No encoding for filenames in error messages.
diff --git a/tp/t/test_parse_texi_line.t b/tp/t/test_parse_texi_line.t
index 6bfdb6a1a8..82b7c7e6e5 100644
--- a/tp/t/test_parse_texi_line.t
+++ b/tp/t/test_parse_texi_line.t
@@ -5,7 +5,7 @@ use Texinfo::ModulePath (undef, undef, 'updirs' => 2);
 
 use Test::More;
 
-BEGIN { plan tests => 30; }
+BEGIN { plan tests => 45; }
 
 use Texinfo::Convert::Texinfo;
 use Texinfo::Parser;
@@ -36,7 +36,11 @@ sub test_line($$$$)
   my $error_idx = 0;
   foreach my $error_message (@$error_warnings_list) {
     if (defined($errors_references) and $error_idx < 
scalar(@$errors_references)) {
-      is($error_message->{'error_line'}, $errors_references->[$error_idx]."\n",
+      my ($error_line_nr_reference, $error_line_reference)
+        = @{$errors_references->[$error_idx]};
+      is ($error_message->{'line_nr'}, $error_line_nr_reference,
+          "$test_explanation error line $error_idx");
+      is ($error_message->{'error_line'}, $error_line_reference."\n",
           "$test_explanation error message $error_idx");
     } else {
       warn "not caught: $error_message->{'error_line'}";
@@ -48,9 +52,9 @@ sub test_line($$$$)
 my @tests = (
 ["\@node a node\n", 'node line'],
 ["aa \@exdent in exdent", 'exdent error no end line',
-  ['warning: @exdent should only appear at the beginning of a line']],
+  [[1, 'warning: @exdent should only appear at the beginning of a line']]],
 ["aa \@exdent in exdent\n", 'exdent error with end line',
-  ['warning: @exdent should only appear at the beginning of a line']],
+  [[1, 'warning: @exdent should only appear at the beginning of a line']]],
 ['@node node
 a node
 
@@ -80,10 +84,10 @@ in chapter
 @listoffloats type
 
 @bye
-', 'long example', ['warning: @setfilename after the first element',
-                    'column fraction not a number: a',
-                    'column fraction not a number: b',
-                    '@columnfractions only meaningful on a @multitable line',
+', 'long example', [[4, 'warning: @setfilename after the first element'],
+                    [24, 'column fraction not a number: a'],
+                    [24, 'column fraction not a number: b'],
+                    [20, '@columnfractions only meaningful on a @multitable 
line'],
 ]]
 );
 
diff --git a/tp/t/test_parser_registrar.t b/tp/t/test_parser_registrar.t
index 2b02aca26a..d414c2bd32 100644
--- a/tp/t/test_parser_registrar.t
+++ b/tp/t/test_parser_registrar.t
@@ -5,7 +5,7 @@ use Texinfo::ModulePath (undef, undef, 'updirs' => 2);
 
 use Test::More;
 
-BEGIN { plan tests => 7; }
+BEGIN { plan tests => 9; }
 
 use Texinfo::Parser;
 use Texinfo::Report;
@@ -32,12 +32,20 @@ my ($error_warnings_list, $error_count) = 
$parser_registrar->errors();
 
 ok ($error_count == 2, 'error count');
 
-my @errors_references = ($initial_error, 'unmatched `@end format\'');
+# line_nr is undef with document_error()
+my @errors_references = ([undef, $initial_error],
+                         [1, 'unmatched `@end format\'']);
 
 my $error_idx = 0;
 foreach my $error_message (@$error_warnings_list) {
+  my ($error_line_nr_reference, $error_line_reference)
+          = @{$errors_references[$error_idx]};
   ok ($error_message->{'type'} eq 'error', "error type $error_idx");
-  ok ($error_message->{'error_line'} eq $errors_references[$error_idx]."\n",
+  ok (((not defined($error_message->{'line_nr'})
+       and not defined($error_line_nr_reference))
+      or $error_message->{'line_nr'} == $error_line_nr_reference),
+      "error line $error_idx");
+  ok ($error_message->{'error_line'} eq $error_line_reference."\n",
       "error message $error_idx");
   $error_idx++;
 }
diff --git a/tp/t/test_protect_hashchar_at_line_beginning.t 
b/tp/t/test_protect_hashchar_at_line_beginning.t
index 6bb039b8c3..f5cc2cbb5f 100644
--- a/tp/t/test_protect_hashchar_at_line_beginning.t
+++ b/tp/t/test_protect_hashchar_at_line_beginning.t
@@ -5,7 +5,7 @@ use Texinfo::ModulePath (undef, undef, 'updirs' => 2);
 
 use Test::More;
 
-BEGIN { plan tests => 6; }
+BEGIN { plan tests => 7; }
 
 use Texinfo::Parser;
 use Texinfo::Transformations;
@@ -37,7 +37,8 @@ sub run_test($$$;$)
 
   if (defined($error_message)) {
     my ($errors, $errors_count) = $registrar->errors();
-    if (!$error_message) {
+    my ($error_line_nr_reference, $error_line_reference) = @$error_message;
+    if (!$error_line_reference) {
       if ($errors and scalar(@$errors)) {
         print STDERR " --error-> $errors->[0]->{'error_line'}";
       } else {
@@ -45,7 +46,10 @@ sub run_test($$$;$)
       }
     } else {
       if ($errors and scalar(@$errors)) {
-        is($error_message, $errors->[0]->{'error_line'}, "error message: 
$name");
+        is($error_line_nr_reference, $errors->[0]->{'line_nr'},
+          "error line: $name");
+        is($error_line_reference, $errors->[0]->{'error_line'},
+          "error message: $name");
       } else {
         ok(0, "error message: $name");
       }
@@ -135,8 +139,8 @@ run_test('
 @macro mymacro {}
 # line 20 "ff"
 @end macro
-', 'in raw command', 'warning: could not protect hash character in @macro
-');
+', 'in raw command', [2, 'warning: could not protect hash character in @macro
+']);
 
 
 #{
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index dff933f3d4..c803d79561 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -650,7 +650,7 @@ sub handle_errors($$$)
         }
         $s .= "$file:";
       }
-      if ($error_message->{'line_nr'}) {
+      if (defined($error_message->{'line_nr'})) {
         $s .= $error_message->{'line_nr'} . ': ';
       }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]