Skip to content

Commit

Permalink
Avoid duplicate log printing (#50)
Browse files Browse the repository at this point in the history
* Avoid duplicate log printing

* Add a test
  • Loading branch information
Drvi authored May 9, 2023
1 parent 2c27888 commit fa468e6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/ReTestItems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,14 @@ function start_and_manage_worker(
# back up to the main coordinator task and throw to the user
rethrow()
end
println(DEFAULT_STDOUT[])
# Explicitly show captured logs or say there weren't any
_print_captured_logs(DEFAULT_STDOUT[], testitem, nretries + 1)

if !(e isa TestSetFailure)
println(DEFAULT_STDOUT[])
# Explicitly show captured logs or say there weren't any in case we're about
# to terminte the worker
_print_captured_logs(DEFAULT_STDOUT[], testitem, nretries + 1)
end

if e isa TimeoutException
@debugv 1 "Test item $(repr(testitem.name)) timed out. Terminating worker $worker"
terminate!(worker)
Expand Down
11 changes: 11 additions & 0 deletions test/integrationtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -657,4 +657,15 @@ end
end
end

# https://github.com/JuliaTesting/ReTestItems.jl/issues/49
@testset "Worker log capture on a failing test is not reported twice" begin
test_file_path = joinpath(TEST_FILES_DIR, "_failing_test.jl")

captured = IOCapture.capture(rethrow=Union{}) do
encased_testset(()->runtests(test_file_path, nworkers=1, logs=:issues))
end

@test count("No Captured Logs", captured.output) == 1
end

end # integrationtests.jl testset
2 changes: 1 addition & 1 deletion test/junit_xml.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function remove_variables(str)
r" time=\\\"[0-9]*.[0-9]*\\\"" => " time=\"0\"",
# Replace tag `value` in a <property> with "0"
# e.g. "<property name=\"dd_tags[perf.gctime]\" value=\"1.23e-6\"></property>"
r" value=\"[\d]*[.]?[\d]*?[e]?[-]?[\d]?\"(?=></property>)" => " value=\"0\"",
r" value=\"[-]?[\d]*[.]?[\d]*?[e]?[-]?[\d]?\"(?=></property>)" => " value=\"0\"",
# Omit stacktrace info between "Stacktrace" and the line containing "</error>".
# Stacktraces are version specific.
r" Stacktrace:[\s\S]*(?=\n\s*</error)" => " Stacktrace:\n [omitted]",
Expand Down
3 changes: 3 additions & 0 deletions test/testfiles/_failing_test.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@testitem "A single test item that fails" begin
@test false
end

2 comments on commit fa468e6

@nickrobinson251
Copy link
Collaborator

Choose a reason for hiding this comment

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

@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/83219

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.4.0 -m "<description of version>" fa468e66917b80803f048b673000641629d0b595
git push origin v1.4.0

Please sign in to comment.