From 5f0d9d4627fe7d5163ccdb596ee952abaafc40b5 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Sun, 14 Jun 2020 21:21:45 +0900 Subject: [PATCH] add simple end2end test --- test/end2end/test_end2end.jl | 11 +++++++++ test/end2end/test_simple.jl | 48 ++++++++++++++++++++++++++++++++++++ test/runtests.jl | 4 +++ 3 files changed, 63 insertions(+) create mode 100644 test/end2end/test_end2end.jl create mode 100644 test/end2end/test_simple.jl diff --git a/test/end2end/test_end2end.jl b/test/end2end/test_end2end.jl new file mode 100644 index 0000000..edd28c1 --- /dev/null +++ b/test/end2end/test_end2end.jl @@ -0,0 +1,11 @@ +# NOTE: +# This test file does end to end tests, while we don't want to check the details in the generated documents. +# Rather, we just assert we can `weave` all the supported formats without errors here. + +# TODO: +# - more complex example +# - integration with other libraries, like Plots + +@testset "end2end simple" begin + include("test_simple.jl") +end # @testset "end2end" diff --git a/test/end2end/test_simple.jl b/test/end2end/test_simple.jl new file mode 100644 index 0000000..e51543a --- /dev/null +++ b/test/end2end/test_simple.jl @@ -0,0 +1,48 @@ +using Weave.Dates + + +test_doctypes = filter(first.(Weave.list_out_formats())) do doctype + # don't test doctypes which need external programs + doctype ∉ ("pandoc2html", "pandoc2pdf", "md2pdf") +end + +function test_func(body) + @test !isempty(body) + date_str = string(Date(now())) + @test occursin(date_str, body) +end + +# julia markdown +julia_markdown_body = """ +# doc chunk + +this is text with `j :inline` code + +code chunk: +```julia +using Dates +Date(now()) +``` +""" + +for doctype in test_doctypes + test_mock_weave(test_func, julia_markdown_body; informat = "markdown", doctype = doctype) +end + +# TODO: test noweb format + +# julia script +julia_script_body = """ +#' # doc chunk +#' +#' this is text with `j :inline` code +#' +#' code chunk: +#+ + +using Dates +Date(now()) +""" +for doctype in test_doctypes + test_mock_weave(test_func, julia_script_body; informat = "script", doctype = doctype) +end diff --git a/test/runtests.jl b/test/runtests.jl index ab07f96..e35cb55 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -61,6 +61,10 @@ end include("test_display.jl") end + @testset "end2end" begin + include("end2end/test_end2end.jl") + end + @testset "legacy" begin include("markdown_test.jl") include("render_figures_test.jl")