From 9268e7c3073ac04776da51272241bb113cdf7d49 Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Mon, 29 Apr 2024 09:52:47 -0500 Subject: [PATCH 1/2] Flattened testsets ordered by appearance --- src/testsets.jl | 2 +- test/recordproperty.jl | 19 ++++++++++----- test/references/complexexample.txt | 24 +++++++++---------- test/references/complexexample_pre_1_7.txt | 20 ++++++++-------- test/references/complexexample_pre_1_9.txt | 20 ++++++++-------- test/references/test_with_properties.txt | 2 +- .../test_with_properties_pre_1_7.txt | 2 +- test/testsets.jl | 6 ++--- 8 files changed, 51 insertions(+), 44 deletions(-) diff --git a/src/testsets.jl b/src/testsets.jl index 946e065..6d9aca3 100644 --- a/src/testsets.jl +++ b/src/testsets.jl @@ -261,7 +261,7 @@ function _flatten_results!(ts::AbstractTestSet)::Vector{<:AbstractTestSet} if !isempty(results) || has_new_properties # Use same ts to preserve description ts.results = results - push!(flattened_results, ts) + pushfirst!(flattened_results, ts) end return flattened_results end diff --git a/test/recordproperty.jl b/test/recordproperty.jl index abe28ae..a169965 100644 --- a/test/recordproperty.jl +++ b/test/recordproperty.jl @@ -44,15 +44,22 @@ properties_nodes = lastnode.(elements(root(rep))) # Child properties are first in report - @test elements(properties_nodes[1])[1]["name"] == "Prop" - @test elements(properties_nodes[1])[1]["value"] == "Inner 1" - @test elements(properties_nodes[1])[2]["name"] == "ID" - @test elements(properties_nodes[1])[2]["value"] == "TopLevel" + @test length(elements(properties_nodes[1])) == 1 + @test elements(properties_nodes[1])[1]["name"] == "ID" + @test elements(properties_nodes[1])[1]["value"] == "TopLevel" + + @test length(elements(properties_nodes[2])) == 2 @test elements(properties_nodes[2])[1]["name"] == "Prop" - @test elements(properties_nodes[2])[1]["value"] == "Inner 2" + @test elements(properties_nodes[2])[1]["value"] == "Inner 1" @test elements(properties_nodes[2])[2]["name"] == "ID" @test elements(properties_nodes[2])[2]["value"] == "TopLevel" + @test length(elements(properties_nodes[3])) == 2 + @test elements(properties_nodes[3])[1]["name"] == "Prop" + @test elements(properties_nodes[3])[1]["value"] == "Inner 2" + @test elements(properties_nodes[3])[2]["name"] == "ID" + @test elements(properties_nodes[3])[2]["value"] == "TopLevel" + # Test full packaage pkg = "TestsWithProperties" temp_pkg_dir() do tmp @@ -88,7 +95,7 @@ # Force flattening as ts doesn't finish fully as it is not the top level testset overwrite_text = "Property ID in testest Outer overwritten by child testset Inner" @test_logs (:warn, overwrite_text) TestReports.flatten_results!(ts) - @test ts.results[1].properties["ID"] == "0" + @test ts.results[2].properties["ID"] == "0" # Test for parent testset properties not being applied to child due to different type ts = @testset ReportingTestSet "" begin diff --git a/test/references/complexexample.txt b/test/references/complexexample.txt index a6a16a8..bda0261 100644 --- a/test/references/complexexample.txt +++ b/test/references/complexexample.txt @@ -1,16 +1,19 @@ -Test Failed +Test Failed + Expression: sqrt(20) == 5 + Evaluated: 4.47213595499958 == 5 +Test Failed Expression: 1 * 2 == 5 Evaluated: 2 == 5 -Test Failed - Expression: 1 + -2 == 1 - Evaluated: -1 == 1 -Test Failed +Test Failed Expression: 1 + 2 == 5 Evaluated: 3 == 5 -Nooo -Outside of tests -Test Failed +Test Failed + Expression: 1 + -2 == 1 + Evaluated: -1 == 1 +Nooo +Outside of tests +Test Failed Expression: throw(ArgumentError("1")) Expected: DimensionMismatch Thrown: ArgumentError @@ -18,8 +21,5 @@ Expression: true Expected: DimensionMismatch No exception thrown -Test Failed - Expression: sqrt(20) == 5 - Evaluated: 4.47213595499958 == 5 - + diff --git a/test/references/complexexample_pre_1_7.txt b/test/references/complexexample_pre_1_7.txt index d0db83c..3b82bd6 100644 --- a/test/references/complexexample_pre_1_7.txt +++ b/test/references/complexexample_pre_1_7.txt @@ -1,19 +1,19 @@ -Test Failed +Test Failed + Expression: sqrt(20) == 5 + Evaluated: 4.47213595499958 == 5Test Failed Expression: 1 * 2 == 5 - Evaluated: 2 == 5Test Failed - Expression: 1 + -2 == 1 - Evaluated: -1 == 1Test Failed + Evaluated: 2 == 5Test Failed Expression: 1 + 2 == 5 - Evaluated: 3 == 5Nooo -Outside of tests -Test Failed + Evaluated: 3 == 5Test Failed + Expression: 1 + -2 == 1 + Evaluated: -1 == 1Nooo +Outside of tests +Test Failed Expression: throw(ArgumentError("1")) Expected: DimensionMismatch Thrown: ArgumentErrorTest Failed Expression: true Expected: DimensionMismatch - No exception thrownTest Failed - Expression: sqrt(20) == 5 - Evaluated: 4.47213595499958 == 5 + No exception thrown diff --git a/test/references/complexexample_pre_1_9.txt b/test/references/complexexample_pre_1_9.txt index 46cb481..0715bfa 100644 --- a/test/references/complexexample_pre_1_9.txt +++ b/test/references/complexexample_pre_1_9.txt @@ -1,19 +1,19 @@ -Test Failed +Test Failed + Expression: sqrt(20) == 5 + Evaluated: 4.47213595499958 == 5Test Failed Expression: 1 * 2 == 5 - Evaluated: 2 == 5Test Failed - Expression: 1 + -2 == 1 - Evaluated: -1 == 1Test Failed + Evaluated: 2 == 5Test Failed Expression: 1 + 2 == 5 - Evaluated: 3 == 5Nooo -Outside of tests -Test Failed + Evaluated: 3 == 5Test Failed + Expression: 1 + -2 == 1 + Evaluated: -1 == 1Nooo +Outside of tests +Test Failed Expression: throw(ArgumentError("1")) Expected: DimensionMismatch Thrown: ArgumentErrorTest Failed Expression: true Expected: DimensionMismatch - No exception thrownTest Failed - Expression: sqrt(20) == 5 - Evaluated: 4.47213595499958 == 5 + No exception thrown diff --git a/test/references/test_with_properties.txt b/test/references/test_with_properties.txt index b952e19..5d766ce 100644 --- a/test/references/test_with_properties.txt +++ b/test/references/test_with_properties.txt @@ -1,2 +1,2 @@ - + diff --git a/test/references/test_with_properties_pre_1_7.txt b/test/references/test_with_properties_pre_1_7.txt index c885668..d51c36d 100644 --- a/test/references/test_with_properties_pre_1_7.txt +++ b/test/references/test_with_properties_pre_1_7.txt @@ -1,2 +1,2 @@ - + diff --git a/test/testsets.jl b/test/testsets.jl index e11807b..0e446cc 100644 --- a/test/testsets.jl +++ b/test/testsets.jl @@ -73,8 +73,8 @@ end flattened_results = TestReports._flatten_results!(ts) @test length(flattened_results) == 2 @test all(isa.(flattened_results, AbstractTestSet)) - @test flattened_results[1].description == "Nested/1/2/3" - @test flattened_results[2].description == "Nested/1/2" + @test flattened_results[1].description == "Nested/1/2" + @test flattened_results[2].description == "Nested/1/2/3" end @testset "ReportingTestSet Display" begin @@ -211,4 +211,4 @@ end end end end -end \ No newline at end of file +end From f5bbbec78b1170df69ddf67cbfbdd589b36e1c9b Mon Sep 17 00:00:00 2001 From: Curtis Vogt Date: Tue, 30 Apr 2024 10:27:13 -0500 Subject: [PATCH 2/2] Update reference tests --- test/references/complexexample.txt | 9 ++++++--- test/references/complexexample_pre_1_7.txt | 8 +++++--- test/references/complexexample_pre_1_9.txt | 8 +++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/test/references/complexexample.txt b/test/references/complexexample.txt index 0a5de6b..7221463 100644 --- a/test/references/complexexample.txt +++ b/test/references/complexexample.txt @@ -8,9 +8,12 @@ Test Failed Expression: 1 + 2 == 5 Evaluated: 3 == 5 -Nooo -Outside of tests -Test Failed +Test Failed + Expression: 1 + -2 == 1 + Evaluated: -1 == 1 +Nooo +Outside of tests +Test Failed Expression: throw(ArgumentError("1")) Expected: DimensionMismatch Thrown: ArgumentError diff --git a/test/references/complexexample_pre_1_7.txt b/test/references/complexexample_pre_1_7.txt index 8807b04..c2dfd50 100644 --- a/test/references/complexexample_pre_1_7.txt +++ b/test/references/complexexample_pre_1_7.txt @@ -5,9 +5,11 @@ Expression: 1 * 2 == 5 Evaluated: 2 == 5Test Failed Expression: 1 + 2 == 5 - Evaluated: 3 == 5Nooo -Outside of tests -Test Failed + Evaluated: 3 == 5Test Failed + Expression: 1 + -2 == 1 + Evaluated: -1 == 1Nooo +Outside of tests +Test Failed Expression: throw(ArgumentError("1")) Expected: DimensionMismatch Thrown: ArgumentErrorTest Failed diff --git a/test/references/complexexample_pre_1_9.txt b/test/references/complexexample_pre_1_9.txt index 3a4fc3c..2efba2e 100644 --- a/test/references/complexexample_pre_1_9.txt +++ b/test/references/complexexample_pre_1_9.txt @@ -5,9 +5,11 @@ Expression: 1 * 2 == 5 Evaluated: 2 == 5Test Failed Expression: 1 + 2 == 5 - Evaluated: 3 == 5Nooo -Outside of tests -Test Failed + Evaluated: 3 == 5Test Failed + Expression: 1 + -2 == 1 + Evaluated: -1 == 1Nooo +Outside of tests +Test Failed Expression: throw(ArgumentError("1")) Expected: DimensionMismatch Thrown: ArgumentErrorTest Failed