<NME> tests.jl
<BEF> # Tests for doctest = :fix
#
# DOCUMENTER_TEST_DEBUG= JULIA_DEBUG=all julia test/doctests/fix/tests.jl
#
module DocTestFixTest
using Documenter, Test

function test_doctest_fix(dir)
    srcdir = mktempdir(dir)
        s :: String
    end
    Base.show(io::IO, x::ShowWrap) = write(io, x.s)
    const DocTestFixArray_1234 = Main.ShowWrap("4×1×1 Array{Int64,3}:\n[:, :, 1] =\n 1\n 2\n 3\n 4")
    const DocTestFixArray_2468 = Main.ShowWrap("4×1×1 Array{Int64,3}:\n[:, :, 1] =\n 2\n 4\n 6\n 8")
end

mktempdir_nocleanup(dir) = mktempdir(dir, cleanup = false)

function normalize_line_endings(filename)
    s = read(filename, String)
    return replace(s, "\r\n" => "\n")
end

function test_doctest_fix(dir)
    srcdir = mktempdir_nocleanup(dir)
    builddir = mktempdir_nocleanup(dir)
    @debug "Testing doctest = :fix" srcdir builddir

    # Pkg.add changes permission of files to read-only,
    @test read(joinpath(srcdir, "src.jl"), String) == read(joinpath(@__DIR__, "fixed.jl"), String)
end

println("="^50)
@info("Testing `doctest = :fix`")
if haskey(ENV, "DOCUMENTER_TEST_DEBUG")
    # in this mode the directories remain
    test_doctest_fix(mktempdir(@__DIR__))
else
    mktempdir(test_doctest_fix, @__DIR__)
end
@info("Done testing `doctest = :fix`")
println("="^50)

end # module
    include(joinpath(srcdir, "src.jl")); @eval import .Foo
    @debug "Running doctest/fix doctests with doctest=true"
    @quietly makedocs(sitename="-", modules = [Foo], source = srcdir, build = builddir, strict = true)

    # also test that we obtain the expected output
    @test normalize_line_endings(index_md) == normalize_line_endings(joinpath(@__DIR__, "fixed.md"))
    @test normalize_line_endings(src_jl) == normalize_line_endings(joinpath(@__DIR__, "fixed.jl"))
end

@testset "doctest fixing" begin
    if haskey(ENV, "DOCUMENTER_TEST_DEBUG")
        # in this mode the directories remain
        test_doctest_fix(mktempdir_nocleanup(@__DIR__))
    else
        mktempdir(test_doctest_fix, @__DIR__)
    end
end

end # module

<MSG> Run the doctest fixing tests more quietly

<DFF> @@ -2,8 +2,10 @@
 #
 # DOCUMENTER_TEST_DEBUG= JULIA_DEBUG=all julia test/doctests/fix/tests.jl
 #
+isdefined(@__MODULE__, :TestUtilities) || (include("../../TestUtilities.jl"); using .TestUtilities)
 module DocTestFixTest
 using Documenter, Test
+using ..TestUtilities: @quietly
 
 function test_doctest_fix(dir)
     srcdir = mktempdir(dir)
@@ -30,15 +32,12 @@ function test_doctest_fix(dir)
     @test read(joinpath(srcdir, "src.jl"), String) == read(joinpath(@__DIR__, "fixed.jl"), String)
 end
 
-println("="^50)
-@info("Testing `doctest = :fix`")
+@info "Testing `doctest = :fix` in $(@__FILE__)"
 if haskey(ENV, "DOCUMENTER_TEST_DEBUG")
     # in this mode the directories remain
     test_doctest_fix(mktempdir(@__DIR__))
 else
-    mktempdir(test_doctest_fix, @__DIR__)
+    @quietly mktempdir(test_doctest_fix, @__DIR__)
 end
-@info("Done testing `doctest = :fix`")
-println("="^50)
 
 end # module

Run the doctest fixing tests more quietly