Skip to content

Commit

Permalink
Test LaTeX backend on Travis
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenpi committed Oct 27, 2019
1 parent 8fe94d3 commit 885cb7c
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ after_success:

jobs:
include:
- stage: "Themes"
- stage: "Additional tests"
script:
- julia --project=test/themes -e 'using Pkg; Pkg.instantiate(); Pkg.develop(PackageSpec(path=pwd()))'
- julia --project=test/themes test/themes/themes.jl
name: "Themes"
- script:
- julia --project=test/examples -e 'using Pkg; Pkg.instantiate(); Pkg.develop(PackageSpec(path=pwd())); Pkg.add("DocumenterMarkdown")'
- julia --project=test/examples test/examples/tests_latex.jl
name: "PDF/LaTeX backend"
- stage: "Documentation"
script:
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
Expand Down
19 changes: 19 additions & 0 deletions test/TestUtilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ using Documenter.Utilities: withoutput

export @quietly

const QUIETLY_LOG = joinpath(@__DIR__, "quietly.log")

__init__() = isfile(QUIETLY_LOG) && rm(QUIETLY_LOG)

struct QuietlyException <: Exception
exception
backtrace
Expand All @@ -16,6 +20,21 @@ end

function _quietly(f, expr, source)
result, success, backtrace, output = withoutput(f)
haskey(ENV, "DOCUMENTER_TEST_QUIETLY") && open(QUIETLY_LOG; write=true, append=true) do io
println(io, "@quietly: success = $(success) / $(sizeof(output)) bytes of output captured")
println(io, "@quietly: $(source.file):$(source.line)")
println(io, "@quietly: typeof(result) = ", typeof(result))
println(io, "@quietly: STDOUT")
println(io, output)
println(io, "@quietly: end of STDOUT")
if success
println(io, "@quietly: result =")
println(io, result)
else
println(io, "@quietly: result (error) =")
showerror(io, result, backtrace)
end
end
if success
printstyled("@quietly: success, $(sizeof(output)) bytes of output hidden\n"; color=:magenta)
return result
Expand Down
35 changes: 35 additions & 0 deletions test/examples/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,38 @@ else
@info "Skipping build: Markdown" EXAMPLE_BUILDS get(ENV, "DOCUMENTER_TEST_EXAMPLES", nothing)
nothing
end

# PDF/LaTeX
examples_latex_simple_doc = if "latex_simple" in EXAMPLE_BUILDS
@info("Building mock package docs: LaTeXWriter/simple")
@quietly makedocs(
format = Documenter.Writers.LaTeXWriter.LaTeX(platform = "docker"),
sitename = "Documenter LaTeX Simple",
root = examples_root,
build = "builds/latex_simple",
source = "src.latex_simple",
pages = ["Main section" => ["index.md"]],
doctest = false,
debug = true,
)
else
@info "Skipping build: LaTeXWriter/simple" EXAMPLE_BUILDS get(ENV, "DOCUMENTER_TEST_EXAMPLES", nothing)
nothing
end

examples_latex_simple_nondocker_doc = if "latex_simple_nondocker" in EXAMPLE_BUILDS
@info("Building mock package docs: LaTeXWriter/latex_simple_nondocker")
@quietly makedocs(
format = Documenter.Writers.LaTeXWriter.LaTeX(),
sitename = "Documenter LaTeX Simple Non-Docker",
root = examples_root,
build = "builds/latex_simple_nondocker",
source = "src.latex_simple",
pages = ["Main section" => ["index.md"]],
doctest = false,
debug = true,
)
else
@info "Skipping build: LaTeXWriter/latex_simple_nondocker" EXAMPLE_BUILDS get(ENV, "DOCUMENTER_TEST_EXAMPLES", nothing)
nothing
end
4 changes: 4 additions & 0 deletions test/examples/src.latex_simple/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Simple LaTeX build

This build only contains a single paragraph of text to make sure that a
near-empty LaTeX builds passes.
27 changes: 27 additions & 0 deletions test/examples/tests_latex.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Test

# DOCUMENTER_TEST_EXAMPLES can be used to control which builds are performed in
# make.jl, and we need to set it to the relevant LaTeX builds.
ENV["DOCUMENTER_TEST_EXAMPLES"] = "latex_simple"

# When the file is run separately we need to include make.jl which actually builds
# the docs and defines a few modules that are referred to in the docs. The make.jl
# has to be expected in the context of the Main module.
if (@__MODULE__) === Main && !@isdefined examples_root
include("make.jl")
elseif (@__MODULE__) !== Main && isdefined(Main, :examples_root)
using Documenter
const examples_root = Main.examples_root
elseif (@__MODULE__) !== Main && !isdefined(Main, :examples_root)
error("examples/make.jl has not been loaded into Main.")
end

@testset "Examples/LaTeX" begin
@testset "PDF/LaTeX: simple" begin
doc = Main.examples_latex_simple_doc
@test isa(doc, Documenter.Documents.Document)
let build_dir = joinpath(examples_root, "builds", "latex_simple")
@test joinpath(build_dir, "DocumenterLaTeXSimple.pdf") |> isfile
end
end
end

0 comments on commit 885cb7c

Please sign in to comment.