[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 14 Jan 2024 09:30:48 -0500 (EST) |
branch: master
commit 3a3e36c4fa0354250510f79a334cfbc30830ac6a
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 14 15:28:01 2024 +0100
* tp/Texinfo/Transformations.pm (_new_node): if $XS_structuring, abort
as the output cannot be correct.
* tp/t/automatic_nodes.t ($XS_structuring): set $XS_structuring
instead of $with_XS and skip tests calling _new_node if
$XS_structuring is set. Update comment on _new_node.
---
ChangeLog | 9 +++++++++
tp/Texinfo/Transformations.pm | 30 ++++++++++++++++++------------
tp/t/automatic_nodes.t | 20 +++++++++++---------
3 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4152aa337c..fa651c84ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-01-14 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/Transformations.pm (_new_node): if $XS_structuring, abort
+ as the output cannot be correct.
+
+ * tp/t/automatic_nodes.t ($XS_structuring): set $XS_structuring
+ instead of $with_XS and skip tests calling _new_node if
+ $XS_structuring is set. Update comment on _new_node.
+
2024-01-14 Patrice Dumas <pertusus@free.fr>
* Texinfo/Convert/Converter.pm, Texinfo/Structuring.pm: add explicit
diff --git a/tp/Texinfo/Transformations.pm b/tp/Texinfo/Transformations.pm
index c0378fa782..31b8d0ec8e 100644
--- a/tp/Texinfo/Transformations.pm
+++ b/tp/Texinfo/Transformations.pm
@@ -291,18 +291,24 @@ sub _new_node($$;$$)
my $registrar = shift;
my $customization_information = shift;
- # If there is a tree_document_descriptor (normally could only happen
- # in tests on especially built trees), and changes are only done to
- # underlying XS tree, the changes by Texinfo::Common::protect_* will
- # be done on the underlying XS tree, but the perl tree will not change,
- # although it is the perl tree that is used to construct the node.
- # Also protect_first_parenthesis has no XS override, only
- # protect_first_parenthesis_in_targets.
- # FIXME we could also rebuild the tree, after adding an override
- # for protect_first_parenthesis?
- my $descriptor = $node_tree->{'tree_document_descriptor'};
- if ($descriptor) {
- delete $node_tree->{'tree_document_descriptor'};
+ if ($XS_structuring) {
+ # If there were XS overrides for all the transformations, they would
+ # necessarily fail, so treat as a bug even though it does not matter
+ # with missing overrides, as seen just below.
+ if (!$node_tree->{'tree_document_descriptor'}) {
+ print STDERR "BUG: new_node: with XS, no tree_document_descriptor\n";
+ }
+
+ # If changes are only done to underlying XS tree, the changes by
+ # Texinfo::Common::protect_* will be done on the underlying XS tree,
+ # but the perl tree will not change, although it is the perl tree
+ # that is used to construct the node.
+ # Also protect_first_parenthesis has no XS override, only
+ # protect_first_parenthesis_in_targets.
+ # FIXME we could also rebuild the tree, after adding an override
+ # for protect_first_parenthesis?
+ print STDERR "FATAL (BUG): _new_node: XS not supported\n";
+ exit (1);
}
# We protect for all the contexts, as the node name should be
diff --git a/tp/t/automatic_nodes.t b/tp/t/automatic_nodes.t
index c991a40fd5..9208119ecd 100644
--- a/tp/t/automatic_nodes.t
+++ b/tp/t/automatic_nodes.t
@@ -17,13 +17,15 @@ use Data::Dumper;
ok(1);
-my $with_XS = ((not defined($ENV{TEXINFO_XS})
- or $ENV{TEXINFO_XS} ne 'omit')
- and (!defined $ENV{TEXINFO_XS_PARSER}
- or $ENV{TEXINFO_XS_PARSER} eq '1'));
-
-# FIXME tests in test_new_node do not test the transformations XS codes,
-# see comment in the beginning of _new_node.
+my $XS_structuring = ((not defined($ENV{TEXINFO_XS})
+ or $ENV{TEXINFO_XS} ne 'omit')
+ and (not defined($ENV{TEXINFO_XS_PARSER})
+ or $ENV{TEXINFO_XS_PARSER} eq '1')
+ and (not defined($ENV{TEXINFO_XS_STRUCTURE})
+ or $ENV{TEXINFO_XS_STRUCTURE} ne '0'));
+
+# _new_node cannot be called with XS used for structuring.
+# See comment in the beginning of _new_node.
sub test_new_node($$$$)
{
my $in = shift;
@@ -62,7 +64,7 @@ sub test_new_node($$$$)
}
SKIP:
{
- skip "test perl not XS", 7 * 3 if ($with_XS);
+ skip "test perl not XS", 7 * 3 if ($XS_structuring);
test_new_node ('a node', 'a-node', '@node a node
', 'simple');
@@ -96,7 +98,7 @@ my $line_tree = Texinfo::Parser::parse_texi_line (undef, 'a
node');
SKIP:
{
- skip "test perl not XS", 1 if ($with_XS);
+ skip "test perl not XS", 1 if ($XS_structuring);
my $new_node = Texinfo::Transformations::_new_node($line_tree, $document);
is ('@node a node 1