texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sun, 7 Apr 2024 19:17:08 -0400 (EDT)

branch: master
commit 1076329c9c36e658443f890c8f533f6f2a9d4177
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Apr 8 01:16:50 2024 +0200

    * tp/t/test_utils.pl (test): set main_configuration as in the main
    program, by setting up defaults, calling
    Texinfo::Config::GNUT_initialize_config before loading init files,
    calling Texinfo::MainConfig::new without arguments, and calling
    Texinfo::Config::GNUT_set_from_cmdline for options from test
    specification (+DEBUG).
---
 ChangeLog                                          |  9 ++++
 tp/Texinfo/Config.pm                               |  2 +
 tp/t/init/special_element_customization.pm         |  1 -
 tp/t/init_files_tests.t                            |  2 -
 .../init_files_tests/customize_special_element.pl  | 60 ++++------------------
 .../customize_special_element/res_html/index.html  |  1 -
 tp/t/test_utils.pl                                 | 44 ++++++++++------
 7 files changed, 48 insertions(+), 71 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 98741df6d4..0a1d80f478 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-04-07  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/t/test_utils.pl (test): set main_configuration as in the main
+       program, by setting up defaults, calling
+       Texinfo::Config::GNUT_initialize_config before loading init files,
+       calling Texinfo::MainConfig::new without arguments, and calling
+       Texinfo::Config::GNUT_set_from_cmdline for options from test
+       specification (+DEBUG).
+
 2024-04-07  Patrice Dumas  <pertusus@free.fr>
 
        * tp/t/test_utils.pl (test): separate better parser options and main
diff --git a/tp/Texinfo/Config.pm b/tp/Texinfo/Config.pm
index 336e46c261..bdd8e64c76 100644
--- a/tp/Texinfo/Config.pm
+++ b/tp/Texinfo/Config.pm
@@ -82,6 +82,8 @@ sub GNUT_initialize_config($$$) {
     }
     $options_as_lists{$cmdline_option} = 1;
   }
+  #print STDERR "main_program_default_options: "
+  #            .join('|',keys(%$main_program_default_options))."\n";
   #print STDERR "cmdline_options: ".join('|',keys(%$cmdline_options))."\n";
   return $init_files_options;
 }
diff --git a/tp/t/init/special_element_customization.pm 
b/tp/t/init/special_element_customization.pm
index 5e100136d2..d9c870f51a 100644
--- a/tp/t/init/special_element_customization.pm
+++ b/tp/t/init/special_element_customization.pm
@@ -11,7 +11,6 @@ texinfo_register_special_unit_info('heading', 'contents',
                                           'The @emph{Table of Contents}');
 texinfo_register_special_unit_info('heading', 'footnotes',
                                               'The @emph{Footnotes}');
-# does not work in the test suite
 texinfo_set_from_init_file('footnotestyle', 'separate');
 
 my %translations = (
diff --git a/tp/t/init_files_tests.t b/tp/t/init_files_tests.t
index 8ef79addf9..2faec60131 100644
--- a/tp/t/init_files_tests.t
+++ b/tp/t/init_files_tests.t
@@ -150,8 +150,6 @@ my @file_tests = (
 }, {'VERBOSE' => 1}],
 ['customize_special_element',
 '
-@footnotestyle separate
-
 @contents
 @shortcontents
 
diff --git a/tp/t/results/init_files_tests/customize_special_element.pl 
b/tp/t/results/init_files_tests/customize_special_element.pl
index b2373671e5..fc29d0d7e8 100644
--- a/tp/t/results/init_files_tests/customize_special_element.pl
+++ b/tp/t/results/init_files_tests/customize_special_element.pl
@@ -21,43 +21,6 @@ $result_trees{'customize_special_element'} = {
         },
         {
           'contents' => [
-            {
-              'args' => [
-                {
-                  'contents' => [
-                    {
-                      'text' => 'separate'
-                    }
-                  ],
-                  'info' => {
-                    'spaces_after_argument' => {
-                      'text' => '
-'
-                    }
-                  },
-                  'type' => 'line_arg'
-                }
-              ],
-              'cmdname' => 'footnotestyle',
-              'extra' => {
-                'misc_args' => [
-                  'separate'
-                ]
-              },
-              'info' => {
-                'spaces_before_argument' => {
-                  'text' => ' '
-                }
-              },
-              'source_info' => {
-                'line_nr' => 2
-              }
-            },
-            {
-              'text' => '
-',
-              'type' => 'empty_line'
-            },
             {
               'args' => [
                 {
@@ -69,7 +32,7 @@ $result_trees{'customize_special_element'} = {
               'cmdname' => 'contents',
               'extra' => {},
               'source_info' => {
-                'line_nr' => 4
+                'line_nr' => 2
               }
             },
             {
@@ -83,7 +46,7 @@ $result_trees{'customize_special_element'} = {
               'cmdname' => 'shortcontents',
               'extra' => {},
               'source_info' => {
-                'line_nr' => 5
+                'line_nr' => 3
               }
             },
             {
@@ -125,7 +88,7 @@ $result_trees{'customize_special_element'} = {
         }
       },
       'source_info' => {
-        'line_nr' => 7
+        'line_nr' => 5
       }
     },
     {
@@ -160,7 +123,7 @@ $result_trees{'customize_special_element'} = {
         }
       },
       'source_info' => {
-        'line_nr' => 8
+        'line_nr' => 6
       }
     },
     {
@@ -191,7 +154,7 @@ $result_trees{'customize_special_element'} = {
         }
       },
       'source_info' => {
-        'line_nr' => 10
+        'line_nr' => 8
       }
     },
     {
@@ -245,7 +208,7 @@ $result_trees{'customize_special_element'} = {
             }
           },
           'source_info' => {
-            'line_nr' => 13
+            'line_nr' => 11
           }
         }
       ],
@@ -258,7 +221,7 @@ $result_trees{'customize_special_element'} = {
         }
       },
       'source_info' => {
-        'line_nr' => 11
+        'line_nr' => 9
       }
     },
     {
@@ -289,7 +252,7 @@ $result_trees{'customize_special_element'} = {
         }
       },
       'source_info' => {
-        'line_nr' => 14
+        'line_nr' => 12
       }
     },
     {
@@ -340,7 +303,7 @@ $result_trees{'customize_special_element'} = {
               'cmdname' => 'footnote',
               'extra' => {},
               'source_info' => {
-                'line_nr' => 17
+                'line_nr' => 15
               }
             },
             {
@@ -360,7 +323,7 @@ $result_trees{'customize_special_element'} = {
         }
       },
       'source_info' => {
-        'line_nr' => 15
+        'line_nr' => 13
       }
     }
   ],
@@ -368,8 +331,6 @@ $result_trees{'customize_special_element'} = {
 };
 
 $result_texis{'customize_special_element'} = '
-@footnotestyle separate
-
 @contents
 @shortcontents
 
@@ -388,7 +349,6 @@ Text@footnote{In footnote}.
 
 
 $result_texts{'customize_special_element'} = '
-
 top
 ***
 
diff --git 
a/tp/t/results/init_files_tests/customize_special_element/res_html/index.html 
b/tp/t/results/init_files_tests/customize_special_element/res_html/index.html
index 80a385d2cf..c7d463f28c 100644
--- 
a/tp/t/results/init_files_tests/customize_special_element/res_html/index.html
+++ 
b/tp/t/results/init_files_tests/customize_special_element/res_html/index.html
@@ -27,7 +27,6 @@ ul.toc-numbered-mark {list-style: none}
 
 <body lang="en">
 
-
 <div class="top-level-extent" id="Top">
 <div class="nav-panel">
 <p>
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index 1b83bb84ab..742dadf669 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -942,13 +942,25 @@ sub test($$)
     delete $parser_options->{'test_formats'};
   }
 
+  # Setup default customization options to be ready for init files options
+  # setting.
+
+  # TODO use the same as in texi2any.pl?:
+  #   %Texinfo::Common::default_main_program_customization_options
+  # The main difference would be that
+  # CHECK_NORMAL_MENU_STRUCTURE is set to 1.
+  my $main_configuration_defaults = {'FORMAT_MENU' => 'menu',
+                                   'CHECK_MISSING_MENU_ENTRY' => 1};
+
   # get symbols in Texinfo::Config namespace before calling the init files
   # such that the added symbols can be removed after running the tests to have
   # isolated tests and be able to load the same init file multiple times.
   my $symbols_before_init_file;
   # reset Texinfo::Config informations to have isolated tests
   Texinfo::Config::GNUT_reinitialize_init_files();
-  my $init_files_options = {};
+  my $init_files_options
+      = Texinfo::Config::GNUT_initialize_config('',
+                                   $main_configuration_defaults, {});
   my $init_file_directories = [$srcdir.'init/', $srcdir.'t/init/'];
   # the init file names should be binary strings.  Since they
   # are not encoded here, ascii file names should be used or they
@@ -958,13 +970,6 @@ sub test($$)
     foreach my $symbol (keys(%Texinfo::Config::)) {
       $symbols_before_init_file->{$symbol} = 1;
     }
-    my $conf = {};
-    if (defined($locale_encoding)) {
-      $conf->{'COMMAND_LINE_ENCODING'} = $locale_encoding;
-      $conf->{'MESSAGE_ENCODING'} = $locale_encoding;
-    }
-    $init_files_options
-      = Texinfo::Config::GNUT_initialize_config('', $conf, {});
     foreach my $filename (@{$parser_options->{'init_files'}}) {
       my $file = Texinfo::Common::locate_init_file($filename,
                                                $init_file_directories, 0);
@@ -977,15 +982,13 @@ sub test($$)
     delete $parser_options->{'init_files'};
   }
 
-  # Setup main_configuration_options at this point to remove
+  # Setup main configuration options defaults at this point to remove
   # structuring options from parser options.
-  # set FORMAT_MENU default to menu.  It is also the default for the parser.
-  # get the same warnings as texi2any for menus.
-  my $main_configuration_options = {'FORMAT_MENU' => 'menu',
-                                   'CHECK_MISSING_MENU_ENTRY' => 1};
-
+  my $main_configuration_options = {};
   # gather options for structuring.
   foreach my $structuring_option ('CHECK_NORMAL_MENU_STRUCTURE',
+                                  'CHECK_MISSING_MENU_ENTRY',
+       # Not structuring options, but used for index sorting strings tests
                                   'USE_UNICODE_COLLATION',
                                   'COLLATION_LANGUAGE') {
     if (defined($parser_options->{$structuring_option})) {
@@ -1055,8 +1058,15 @@ sub test($$)
         = $parser_options->{$parser_and_structuring_option};
     }
   }
-  my $main_configuration = Texinfo::MainConfig::new({
-                                    %$main_configuration_options });
+
+  # setup options from test specification (+DEBUG) as if they were
+  # command-line options, with high precedence.
+  foreach my $option (keys(%$main_configuration_options)) {
+    Texinfo::Config::GNUT_set_from_cmdline($option,
+                                 $main_configuration_options->{$option});
+  }
+
+  my $main_configuration = Texinfo::MainConfig::new();
 
   Texinfo::Common::set_output_encodings($main_configuration,
                                         $document);
@@ -1151,7 +1161,7 @@ sub test($$)
   my $merged_index_entries = $document->merged_indices();
 
   # only print indices information if it differs from the default
-  # indices
+  # indices.  Indices information here is everything but the entries.
   my $indices;
   my $trimmed_index_names = remove_keys($indices_information, 
['index_entries']);
   $indices = {'index_names' => $trimmed_index_names}



reply via email to

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