texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sat, 23 Mar 2024 12:28:05 -0400 (EDT)

branch: master
commit c808a0bc4520445b175ba21bc77f7faa21ba312d
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Mar 23 17:24:30 2024 +0100

    * tp/t/test_utils.pl (test): remove symbols added in init files
    at the end of a test.
---
 ChangeLog          |  5 +++++
 tp/t/test_utils.pl | 16 ++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 6863276a08..3a2dffbe93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-03-23  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/t/test_utils.pl (test): remove symbols added in init files
+       at the end of a test.
+
 2024-03-23  Patrice Dumas  <pertusus@free.fr>
 
        * doc/texi2any_api.texi: corrections, add examples, move nodes.
diff --git a/tp/t/test_utils.pl b/tp/t/test_utils.pl
index a22d1794a7..de26a822e0 100644
--- a/tp/t/test_utils.pl
+++ b/tp/t/test_utils.pl
@@ -973,6 +973,10 @@ sub test($$)
     delete $parser_options->{'test_formats'};
   }
 
+  # 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 = {};
@@ -982,6 +986,10 @@ sub test($$)
   # be used.
   # FIXME what if srcdir is non ascii (srcdir is truly a binary string).
   if ($parser_options and $parser_options->{'init_files'}) {
+    $symbols_before_init_file = {};
+    foreach my $symbol (keys(%Texinfo::Config::)) {
+      $symbols_before_init_file->{$symbol} = 1;
+    }
     my $conf = {};
     if (defined($locale_encoding)) {
       $conf->{'COMMAND_LINE_ENCODING'} = $locale_encoding;
@@ -1408,6 +1416,14 @@ sub test($$)
     $split_result = $tree;
   }
 
+  if ($symbols_before_init_file) {
+    foreach my $symbol (keys(%Texinfo::Config::)) {
+      if (!$symbols_before_init_file->{$symbol}) {
+        delete $Texinfo::Config::{$symbol};
+      }
+    }
+  }
+
   {
     local $Data::Dumper::Purity = 1;
     local $Data::Dumper::Indent = 1;



reply via email to

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