diff --git a/src/server.jl b/src/server.jl index 8bd16c6..6599933 100644 --- a/src/server.jl +++ b/src/server.jl @@ -522,14 +522,16 @@ function evaluate_raw_cells!(f::File, chunks::Vector, options::Dict; showprogres if isnothing(remote.error) for display_result in remote.display_results processed_display = process_results(display_result) - push!( - outputs, - (; - output_type = "display_data", - processed_display.data, - processed_display.metadata, - ), - ) + if !isempty(processed_display.data) + push!( + outputs, + (; + output_type = "display_data", + processed_display.data, + processed_display.metadata, + ), + ) + end if !isempty(processed_display.errors) append!(outputs, processed_display.errors) if !allow_error_cell @@ -542,15 +544,17 @@ function evaluate_raw_cells!(f::File, chunks::Vector, options::Dict; showprogres end end end - push!( - outputs, - (; - output_type = "execute_result", - execution_count = 1, - processed.data, - processed.metadata, - ), - ) + if !isempty(processed.data) + push!( + outputs, + (; + output_type = "execute_result", + execution_count = 1, + processed.data, + processed.metadata, + ), + ) + end else # These are errors arising from evaluation of the contents # of a code cell, not from the `show` output of the values, diff --git a/test/testsets/const_redefinition.jl b/test/testsets/const_redefinition.jl index 896f778..4d4bb00 100644 --- a/test/testsets/const_redefinition.jl +++ b/test/testsets/const_redefinition.jl @@ -39,12 +39,7 @@ include("../utilities/prelude.jl") cells = json["cells"] cell = cells[2] - @test only(cell["outputs"]) == Dict( - "output_type" => "execute_result", - "execution_count" => 1, - "data" => Dict(), - "metadata" => Dict(), - ) + @test isempty(cell["outputs"]) cell = cells[4] @test only(cell["outputs"]) == Dict( @@ -84,12 +79,7 @@ include("../utilities/prelude.jl") cells = json["cells"] cell = cells[2] - @test only(cell["outputs"]) == Dict( - "output_type" => "execute_result", - "execution_count" => 1, - "data" => Dict(), - "metadata" => Dict(), - ) + @test isempty(cell["outputs"]) cell = cells[4] @test only(cell["outputs"]) == Dict( diff --git a/test/testsets/display.jl b/test/testsets/display.jl index cf9ea46..abab194 100644 --- a/test/testsets/display.jl +++ b/test/testsets/display.jl @@ -6,7 +6,7 @@ test_example(joinpath(@__DIR__, "../examples/display.qmd")) do json cell = cells[4] outputs = cell["outputs"] - @test length(outputs) == 3 + @test length(outputs) == 2 @test outputs[1]["output_type"] == "display_data" @test haskey(outputs[1]["data"], "image/png") diff --git a/test/testsets/errors.jl b/test/testsets/errors.jl index 89dc723..b741e81 100644 --- a/test/testsets/errors.jl +++ b/test/testsets/errors.jl @@ -48,29 +48,27 @@ test_example(joinpath(@__DIR__, "../examples/errors.qmd")) do json cell = cells[18] outputs = cell["outputs"] - @test length(outputs) == 5 - @test outputs[1]["output_type"] == "execute_result" - @test isempty(outputs[1]["data"]) + @test length(outputs) == 4 - output = outputs[2] + output = outputs[1] @test output["output_type"] == "error" @test output["ename"] == "text/plain showerror" @test length(output["traceback"]) == 11 @test contains(output["traceback"][end], "multimedia.jl") - output = outputs[3] + output = outputs[2] @test output["output_type"] == "error" @test output["ename"] == "text/html showerror" @test length(output["traceback"]) == 9 @test contains(output["traceback"][end], "multimedia.jl") - output = outputs[4] + output = outputs[3] @test output["output_type"] == "error" @test output["ename"] == "text/latex showerror" @test length(output["traceback"]) == 9 @test contains(output["traceback"][end], "multimedia.jl") - output = outputs[5] + output = outputs[4] @test output["output_type"] == "error" @test output["ename"] == "image/svg+xml showerror" @test length(output["traceback"]) == 9 diff --git a/test/testsets/project.jl b/test/testsets/project.jl index 8d99558..7d58e25 100644 --- a/test/testsets/project.jl +++ b/test/testsets/project.jl @@ -24,8 +24,7 @@ test_example(joinpath(@__DIR__, "../examples/project.qmd")) do json cell = json["cells"][10] @test cell["cell_type"] == "code" - @test cell["outputs"][1]["output_type"] == "execute_result" - @test isempty(cell["outputs"][1]["data"]) + @test isempty(cell["outputs"]) cell = json["cells"][12] @test cell["cell_type"] == "code" diff --git a/test/testsets/project_exeflags.jl b/test/testsets/project_exeflags.jl index 4e6c42b..8aeb0db 100644 --- a/test/testsets/project_exeflags.jl +++ b/test/testsets/project_exeflags.jl @@ -21,8 +21,7 @@ test_example(joinpath(@__DIR__, "../examples/project_exeflags.qmd")) do json cell = cells[8] @test cell["cell_type"] == "code" - @test cell["outputs"][1]["output_type"] == "execute_result" - @test isempty(cell["outputs"][1]["data"]) + @test isempty(cell["outputs"]) cell = cells[10] @test cell["cell_type"] == "code" diff --git a/test/testsets/semicolons.jl b/test/testsets/semicolons.jl index 1939049..1e79499 100644 --- a/test/testsets/semicolons.jl +++ b/test/testsets/semicolons.jl @@ -22,7 +22,7 @@ include("../utilities/prelude.jl") json = run!(server, path; showprogress = false) cell = json.cells[2] - @test isempty(cell.outputs[1].data) + @test isempty(cell.outputs) cell = json.cells[4] @test cell.outputs[1].data["text/plain"] == "1" diff --git a/test/testsets/stdout.jl b/test/testsets/stdout.jl index 238b5e4..36608f3 100644 --- a/test/testsets/stdout.jl +++ b/test/testsets/stdout.jl @@ -10,11 +10,10 @@ test_example(joinpath(@__DIR__, "../examples/stdout.qmd")) do json cell = json["cells"][2] @test cell["cell_type"] == "code" @test cell["execution_count"] == 1 + @test length(cell["outputs"]) == 1 @test cell["outputs"][1]["output_type"] == "stream" @test cell["outputs"][1]["name"] == "stdout" @test contains(cell["outputs"][1]["text"], "1") - @test cell["outputs"][2]["output_type"] == "execute_result" - @test isempty(cell["outputs"][2]["data"]) cell = json["cells"][3] @test cell["cell_type"] == "markdown"