Found this way for runtests. A markdown cell marked with PkgTestCellForTest is turned in to a code cell
and a tmp version with this is executed for test...
using Test, Pluto,PlutoVista,Pkg
function testnotebook(name)
input=joinpath(@__DIR__,"..","examples",name*".jl")
notebook=Pluto.load_notebook_nobackup(input)
pkgcellfortest=findfirst(c->occursin("PkgCellForTest",c.code),notebook.cells)
@assert pkgcellfortest!=nothing
notebook.cells[pkgcellfortest].code=replace(notebook.cells[pkgcellfortest].code,"md"=>"","\"\"\""=>"")
@info "PkgCellForTest=$(pkgcellfortest)\n$(notebook.cells[pkgcellfortest].code)"
Pluto.save_notebook(notebook,"tmp.jl")
sleep(1)
session = Pluto.ServerSession();
notebook = Pluto.SessionActions.open(session, "tmp.jl"; run_async=false)
errored=false
for c in notebook.cells
if c.errored
errored=true
@error "Error in $(c.cell_id): $(c.output.body[:msg])\n $(c.code)"
end
end
!errored
end
notebooks=["plutovista"]
@testset "notebooks" begin
for notebook in notebooks
@test testnotebook(notebook)
end
end
Found this way for runtests. A markdown cell marked with PkgTestCellForTest is turned in to a code cell and a tmp version with this is executed for test...