Skip to content

Commit

Permalink
Add test for XML deep trees
Browse files Browse the repository at this point in the history
  • Loading branch information
seberm committed Nov 22, 2024
1 parent 31f724a commit 517971a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
20 changes: 20 additions & 0 deletions tests/report/junit/data/custom-deep-tree.xml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" ?>

{#
Test that very deep trees are correctly handled by junit plugin.
Refs.:
- [PR#3365](https://github.com/teemtee/tmt/pull/3365)
- [`huge_tree` option](https://lxml.de/api/lxml.etree.XMLParser-class.html)
#}

{% set DEPTH = 257 %}
<root>
{% for i in range(1, DEPTH + 1) %}
{{ " " * i }}<tag{{ i }}>
{% endfor %}

{% for i in range(DEPTH, 0, -1) %}
{{ " " * i }}</tag{{ i }}>
{% endfor %}
</root>
8 changes: 7 additions & 1 deletion tests/report/junit/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ rlJournalStart
rlAssertGrep '<test name="/test/shell/escape&quot;&lt;speci&amp;l&gt;_chars" value="pass"/>' "custom-template-out.xml"
rlPhaseEnd

rlPhaseStartTest "[$method] Check the 'custom' flavor with very deep XML trees"
rlRun -s "tmt run --last -v --id $run_dir execute -h $method report -h junit --file custom-deep-tree-template-out.xml --template-path custom-deep-tree.xml.j2 --flavor custom --force 2>&1 >/dev/null" 2

rlAssertNotGrep 'Excessive depth in document' "$rlRun_LOG"
rlPhaseEnd

rlPhaseStartTest "[$method] The 'custom' flavor with a custom **non-XML** template must not work"
rlRun -s "tmt run --last -v execute -h $method report -h junit --file custom-template-out.xml --template-path non-xml-custom.j2 --flavor custom --force 2>&1 >/dev/null" 2

Expand Down Expand Up @@ -87,7 +93,7 @@ rlJournalStart
done

rlPhaseStartCleanup
rlRun "rm junit.xml custom-template-out.xml custom-subresults-template-out.xml"
rlRun "rm junit.xml custom-template-out.xml custom-deep-tree-template-out.xml custom-subresults-template-out.xml"
rlRun "popd"
rlRun "rm -rf $tmp"
rlPhaseEnd
Expand Down

0 comments on commit 517971a

Please sign in to comment.