Skip to content

Commit

Permalink
Pretty formatted XML (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
omus authored May 21, 2024
1 parent 8250050 commit 16f8d25
Show file tree
Hide file tree
Showing 14 changed files with 347 additions and 44 deletions.
5 changes: 4 additions & 1 deletion src/runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function gen_runner_code(testfilename, logfilename, test_args)
using Test
using TestReports
using TestReports.EzXML: prettyprint
append!(empty!(ARGS), $(repr(test_args.exec)))
Expand All @@ -137,7 +138,9 @@ function gen_runner_code(testfilename, logfilename, test_args)
end
# Flatten before calling `report` to avoid a `deepcopy`.
write($(repr(logfilename)), report(TestReports.flatten_results!(ts)))
open($(repr(logfilename)), "w") do io
prettyprint(io, report(TestReports.flatten_results!(ts)))
end
any_problems(ts) && exit(TestReports.TESTS_FAILED)
"""
return runner_code
Expand Down
78 changes: 68 additions & 10 deletions test/references/complexexample.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="19" failures="6" errors="4"><testsuite name="Math" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="0"><testcase name="4 % 2 == 0" id="1" classname="Math" time="0.0"/><testcase name="sqrt(20) == 5" id="2" classname="Math" time="0.0"><failure message="4.47213595499958 == 5" type="test">Test Failed
<testsuites tests="19" failures="6" errors="4">
<testsuite name="Math" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="0">
<testcase name="4 % 2 == 0" id="1" classname="Math" time="0.0"/>
<testcase name="sqrt(20) == 5" id="2" classname="Math" time="0.0">
<failure message="4.47213595499958 == 5" type="test">Test Failed
Expression: sqrt(20) == 5
Evaluated: 4.47213595499958 == 5
</failure></testcase><testcase name="16 == 16" id="3" classname="Math" time="0.0"/></testsuite><testsuite name="Math/Multiplication" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="1"><testcase name="1 * 3 == 3" id="1" classname="Math/Multiplication" time="0.0"/><testcase name="1 * 2 == 5" id="2" classname="Math/Multiplication" time="0.0"><failure message="2 == 5" type="test">Test Failed
</failure>
</testcase>
<testcase name="16 == 16" id="3" classname="Math" time="0.0"/>
</testsuite>
<testsuite name="Math/Multiplication" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="1">
<testcase name="1 * 3 == 3" id="1" classname="Math/Multiplication" time="0.0"/>
<testcase name="1 * 2 == 5" id="2" classname="Math/Multiplication" time="0.0">
<failure message="2 == 5" type="test">Test Failed
Expression: 1 * 2 == 5
Evaluated: 2 == 5
</failure></testcase><testcase name="1 * 4 == 4" id="3" classname="Math/Multiplication" time="0.0"/></testsuite><testsuite name="Math/addition" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="2"><testcase name="1 + 1 == 2" id="1" classname="Math/addition" time="0.0"/><testcase name="1 + 2 == 5" id="2" classname="Math/addition" time="0.0"><failure message="3 == 5" type="test">Test Failed
</failure>
</testcase>
<testcase name="1 * 4 == 4" id="3" classname="Math/Multiplication" time="0.0"/>
</testsuite>
<testsuite name="Math/addition" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="2">
<testcase name="1 + 1 == 2" id="1" classname="Math/addition" time="0.0"/>
<testcase name="1 + 2 == 5" id="2" classname="Math/addition" time="0.0">
<failure message="3 == 5" type="test">Test Failed
Expression: 1 + 2 == 5
Evaluated: 3 == 5
</failure></testcase><testcase name="1 + 4 == 5" id="3" classname="Math/addition" time="0.0"/></testsuite><testsuite name="Math/addition/negative addition" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="3"><testcase name="1 + -1 == 0" id="1" classname="Math/addition/negative addition" time="0.0"/><testcase name="1 + -2 == 1" id="2" classname="Math/addition/negative addition" time="0.0"><failure message="-1 == 1" type="test">Test Failed
</failure>
</testcase>
<testcase name="1 + 4 == 5" id="3" classname="Math/addition" time="0.0"/>
</testsuite>
<testsuite name="Math/addition/negative addition" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="3">
<testcase name="1 + -1 == 0" id="1" classname="Math/addition/negative addition" time="0.0"/>
<testcase name="1 + -2 == 1" id="2" classname="Math/addition/negative addition" time="0.0">
<failure message="-1 == 1" type="test">Test Failed
Expression: 1 + -2 == 1
Evaluated: -1 == 1
</failure></testcase><testcase name="10 + -5 == 5" id="3" classname="Math/addition/negative addition" time="0.0"/></testsuite><testsuite name="Math/other" tests="4" failures="0" errors="3" time="0.0" timestamp="0" hostname="localhost" id="4"><testcase name="sqrt(-1)" id="1" classname="Math/other" time="0.0"><skip/></testcase><testcase name="1 / 0" id="2" classname="Math/other" time="0.0"><error message="Expression evaluated to non-Boolean" type="Expression evaluated to non-Boolean"></error></testcase><testcase name="1 == error(&quot;Nooo&quot;)" id="3" classname="Math/other" time="0.0"><error message="Nooo" type="ErrorException">Nooo
</error></testcase><testcase name="true" id="4" classname="Math/other" time="0.0"><error message="Got correct result, please change to @test if no longer broken." type="Unexpected Pass"></error></testcase></testsuite><testsuite name="Math/Error outside of tests" tests="0" failures="0" errors="1" time="0.0" timestamp="0" hostname="localhost" id="5"><testcase name="()" id="_testcase_id_" classname="Math/Error outside of tests" time="0.0"><error message="Got exception outside of a @test" type="ErrorException">Outside of tests
</error></testcase></testsuite><testsuite name="Math/Different failures" tests="2" failures="2" errors="0" time="0.0" timestamp="0" hostname="localhost" id="6"><testcase name="throw(ArgumentError(&quot;1&quot;))" id="1" classname="Math/Different failures" time="0.0"><failure message="Wrong exception type thrown" type="test_throws_wrong">Test Failed
</failure>
</testcase>
<testcase name="10 + -5 == 5" id="3" classname="Math/addition/negative addition" time="0.0"/>
</testsuite>
<testsuite name="Math/other" tests="4" failures="0" errors="3" time="0.0" timestamp="0" hostname="localhost" id="4">
<testcase name="sqrt(-1)" id="1" classname="Math/other" time="0.0">
<skip/>
</testcase>
<testcase name="1 / 0" id="2" classname="Math/other" time="0.0">
<error message="Expression evaluated to non-Boolean" type="Expression evaluated to non-Boolean"/>
</testcase>
<testcase name="1 == error(&quot;Nooo&quot;)" id="3" classname="Math/other" time="0.0">
<error message="Nooo" type="ErrorException">Nooo
</error>
</testcase>
<testcase name="true" id="4" classname="Math/other" time="0.0">
<error message="Got correct result, please change to @test if no longer broken." type="Unexpected Pass"/>
</testcase>
</testsuite>
<testsuite name="Math/Error outside of tests" tests="0" failures="0" errors="1" time="0.0" timestamp="0" hostname="localhost" id="5">
<testcase name="()" id="_testcase_id_" classname="Math/Error outside of tests" time="0.0">
<error message="Got exception outside of a @test" type="ErrorException">Outside of tests
</error>
</testcase>
</testsuite>
<testsuite name="Math/Different failures" tests="2" failures="2" errors="0" time="0.0" timestamp="0" hostname="localhost" id="6">
<testcase name="throw(ArgumentError(&quot;1&quot;))" id="1" classname="Math/Different failures" time="0.0">
<failure message="Wrong exception type thrown" type="test_throws_wrong">Test Failed
Expression: throw(ArgumentError("1"))
Expected: DimensionMismatch
Thrown: ArgumentError
</failure></testcase><testcase name="true" id="2" classname="Math/Different failures" time="0.0"><failure message="No exception thrown" type="test_throws_nothing">Test Failed
</failure>
</testcase>
<testcase name="true" id="2" classname="Math/Different failures" time="0.0">
<failure message="No exception thrown" type="test_throws_nothing">Test Failed
Expression: true
Expected: DimensionMismatch
No exception thrown
</failure></testcase></testsuite><testsuite name="Math/using function from a module" tests="1" failures="0" errors="0" time="0.0" timestamp="0" hostname="localhost" id="7"><testcase name="nthreads() &gt; 0" id="1" classname="Math/using function from a module" time="0.0"/></testsuite></testsuites>

</failure>
</testcase>
</testsuite>
<testsuite name="Math/using function from a module" tests="1" failures="0" errors="0" time="0.0" timestamp="0" hostname="localhost" id="7">
<testcase name="nthreads() &gt; 0" id="1" classname="Math/using function from a module" time="0.0"/>
</testsuite>
</testsuites>
78 changes: 68 additions & 10 deletions test/references/complexexample_pre_1_7.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="19" failures="6" errors="4"><testsuite name="Math" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="0"><testcase name="pass (info lost) (Test 1)" id="1" classname="Math" time="0.0"/><testcase name="sqrt(20) == 5" id="2" classname="Math" time="0.0"><failure message="4.47213595499958 == 5" type="test">Test Failed
<testsuites tests="19" failures="6" errors="4">
<testsuite name="Math" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="0">
<testcase name="pass (info lost) (Test 1)" id="1" classname="Math" time="0.0"/>
<testcase name="sqrt(20) == 5" id="2" classname="Math" time="0.0">
<failure message="4.47213595499958 == 5" type="test">Test Failed
Expression: sqrt(20) == 5
Evaluated: 4.47213595499958 == 5</failure></testcase><testcase name="pass (info lost) (Test 3)" id="3" classname="Math" time="0.0"/></testsuite><testsuite name="Math/Multiplication" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="1"><testcase name="pass (info lost) (Test 1)" id="1" classname="Math/Multiplication" time="0.0"/><testcase name="1 * 2 == 5" id="2" classname="Math/Multiplication" time="0.0"><failure message="2 == 5" type="test">Test Failed
Evaluated: 4.47213595499958 == 5</failure>
</testcase>
<testcase name="pass (info lost) (Test 3)" id="3" classname="Math" time="0.0"/>
</testsuite>
<testsuite name="Math/Multiplication" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="1">
<testcase name="pass (info lost) (Test 1)" id="1" classname="Math/Multiplication" time="0.0"/>
<testcase name="1 * 2 == 5" id="2" classname="Math/Multiplication" time="0.0">
<failure message="2 == 5" type="test">Test Failed
Expression: 1 * 2 == 5
Evaluated: 2 == 5</failure></testcase><testcase name="pass (info lost) (Test 3)" id="3" classname="Math/Multiplication" time="0.0"/></testsuite><testsuite name="Math/addition" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="2"><testcase name="pass (info lost) (Test 1)" id="1" classname="Math/addition" time="0.0"/><testcase name="1 + 2 == 5" id="2" classname="Math/addition" time="0.0"><failure message="3 == 5" type="test">Test Failed
Evaluated: 2 == 5</failure>
</testcase>
<testcase name="pass (info lost) (Test 3)" id="3" classname="Math/Multiplication" time="0.0"/>
</testsuite>
<testsuite name="Math/addition" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="2">
<testcase name="pass (info lost) (Test 1)" id="1" classname="Math/addition" time="0.0"/>
<testcase name="1 + 2 == 5" id="2" classname="Math/addition" time="0.0">
<failure message="3 == 5" type="test">Test Failed
Expression: 1 + 2 == 5
Evaluated: 3 == 5</failure></testcase><testcase name="pass (info lost) (Test 3)" id="3" classname="Math/addition" time="0.0"/></testsuite><testsuite name="Math/addition/negative addition" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="3"><testcase name="pass (info lost) (Test 1)" id="1" classname="Math/addition/negative addition" time="0.0"/><testcase name="1 + -2 == 1" id="2" classname="Math/addition/negative addition" time="0.0"><failure message="-1 == 1" type="test">Test Failed
Evaluated: 3 == 5</failure>
</testcase>
<testcase name="pass (info lost) (Test 3)" id="3" classname="Math/addition" time="0.0"/>
</testsuite>
<testsuite name="Math/addition/negative addition" tests="3" failures="1" errors="0" time="0.0" timestamp="0" hostname="localhost" id="3">
<testcase name="pass (info lost) (Test 1)" id="1" classname="Math/addition/negative addition" time="0.0"/>
<testcase name="1 + -2 == 1" id="2" classname="Math/addition/negative addition" time="0.0">
<failure message="-1 == 1" type="test">Test Failed
Expression: 1 + -2 == 1
Evaluated: -1 == 1</failure></testcase><testcase name="pass (info lost) (Test 3)" id="3" classname="Math/addition/negative addition" time="0.0"/></testsuite><testsuite name="Math/other" tests="4" failures="0" errors="3" time="0.0" timestamp="0" hostname="localhost" id="4"><testcase name="sqrt(-1)" id="1" classname="Math/other" time="0.0"><skip/></testcase><testcase name="1 / 0" id="2" classname="Math/other" time="0.0"><error message="Expression evaluated to non-Boolean" type="Expression evaluated to non-Boolean"></error></testcase><testcase name="1 == error(&quot;Nooo&quot;)" id="3" classname="Math/other" time="0.0"><error message="Nooo" type="ErrorException">Nooo
</error></testcase><testcase name="true" id="4" classname="Math/other" time="0.0"><error message="Got correct result, please change to @test if no longer broken." type="Unexpected Pass"></error></testcase></testsuite><testsuite name="Math/Error outside of tests" tests="0" failures="0" errors="1" time="0.0" timestamp="0" hostname="localhost" id="5"><testcase name="()" id="_testcase_id_" classname="Math/Error outside of tests" time="0.0"><error message="Got exception outside of a @test" type="ErrorException">Outside of tests
</error></testcase></testsuite><testsuite name="Math/Different failures" tests="2" failures="2" errors="0" time="0.0" timestamp="0" hostname="localhost" id="6"><testcase name="throw(ArgumentError(&quot;1&quot;))" id="1" classname="Math/Different failures" time="0.0"><failure message="Wrong exception type thrown" type="test_throws_wrong">Test Failed
Evaluated: -1 == 1</failure>
</testcase>
<testcase name="pass (info lost) (Test 3)" id="3" classname="Math/addition/negative addition" time="0.0"/>
</testsuite>
<testsuite name="Math/other" tests="4" failures="0" errors="3" time="0.0" timestamp="0" hostname="localhost" id="4">
<testcase name="sqrt(-1)" id="1" classname="Math/other" time="0.0">
<skip/>
</testcase>
<testcase name="1 / 0" id="2" classname="Math/other" time="0.0">
<error message="Expression evaluated to non-Boolean" type="Expression evaluated to non-Boolean"/>
</testcase>
<testcase name="1 == error(&quot;Nooo&quot;)" id="3" classname="Math/other" time="0.0">
<error message="Nooo" type="ErrorException">Nooo
</error>
</testcase>
<testcase name="true" id="4" classname="Math/other" time="0.0">
<error message="Got correct result, please change to @test if no longer broken." type="Unexpected Pass"/>
</testcase>
</testsuite>
<testsuite name="Math/Error outside of tests" tests="0" failures="0" errors="1" time="0.0" timestamp="0" hostname="localhost" id="5">
<testcase name="()" id="_testcase_id_" classname="Math/Error outside of tests" time="0.0">
<error message="Got exception outside of a @test" type="ErrorException">Outside of tests
</error>
</testcase>
</testsuite>
<testsuite name="Math/Different failures" tests="2" failures="2" errors="0" time="0.0" timestamp="0" hostname="localhost" id="6">
<testcase name="throw(ArgumentError(&quot;1&quot;))" id="1" classname="Math/Different failures" time="0.0">
<failure message="Wrong exception type thrown" type="test_throws_wrong">Test Failed
Expression: throw(ArgumentError("1"))
Expected: DimensionMismatch
Thrown: ArgumentError</failure></testcase><testcase name="true" id="2" classname="Math/Different failures" time="0.0"><failure message="No exception thrown" type="test_throws_nothing">Test Failed
Thrown: ArgumentError</failure>
</testcase>
<testcase name="true" id="2" classname="Math/Different failures" time="0.0">
<failure message="No exception thrown" type="test_throws_nothing">Test Failed
Expression: true
Expected: DimensionMismatch
No exception thrown</failure></testcase></testsuite><testsuite name="Math/using function from a module" tests="1" failures="0" errors="0" time="0.0" timestamp="0" hostname="localhost" id="7"><testcase name="pass (info lost) (Test 1)" id="1" classname="Math/using function from a module" time="0.0"/></testsuite></testsuites>

No exception thrown</failure>
</testcase>
</testsuite>
<testsuite name="Math/using function from a module" tests="1" failures="0" errors="0" time="0.0" timestamp="0" hostname="localhost" id="7">
<testcase name="pass (info lost) (Test 1)" id="1" classname="Math/using function from a module" time="0.0"/>
</testsuite>
</testsuites>
Loading

2 comments on commit 16f8d25

@oxinabox
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

cc @omus

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/107392

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.0 -m "<description of version>" 16f8d25fad0999d4aee4d5f34431550afb9fa2f7
git push origin v1.0.0

Please sign in to comment.