Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cross-platform newline handling in doctests #1520

Merged
merged 21 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions .appveyor.yml

This file was deleted.

5 changes: 1 addition & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ jobs:
os:
- ubuntu-latest
- macos-latest
# We still run Windows tests on AppVeyor because the tests are not passing on
# the Windows image of GitHub Actions:
# https://github.com/JuliaDocs/Documenter.jl/pull/1496
#- windows-latest
- windows-latest
arch:
- x64
include:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

* ![Bugfix][badge-bugfix] When checking for authentication keys when deploying, Documenter now more appropriately checks if the environment variables are non-empty, rather than just whether they are defined. ([#1511][github-1511])

* ![Bugfix][badge-bugfix] Doctests now correctly handle the case when the repository has been checked out with `CRLF` line endings (which can happen on Windows with `core.autocrlf=true`). ([#1516][github-1516], [#1519][github-1519], [#1520][github-1520])

## Version `v0.26.1`

* ![Bugfix][badge-bugfix] HTML assets that are copied directly from Documenters source to the build output now has correct file permissions. ([#1497][github-1497])
Expand Down Expand Up @@ -737,6 +739,9 @@
[github-1503]: https://github.com/JuliaDocs/Documenter.jl/pull/1503
[github-1510]: https://github.com/JuliaDocs/Documenter.jl/pull/1510
[github-1511]: https://github.com/JuliaDocs/Documenter.jl/pull/1511
[github-1516]: https://github.com/JuliaDocs/Documenter.jl/issues/1516
[github-1519]: https://github.com/JuliaDocs/Documenter.jl/pull/1519
[github-1520]: https://github.com/JuliaDocs/Documenter.jl/pull/1520

[julia-38079]: https://github.com/JuliaLang/julia/issues/38079

Expand Down
6 changes: 6 additions & 0 deletions test/doctests/doctests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ function onormalize(s)
# platform / environment / time dependent parts, so that it would actually be possible
# to compare Documenter output to previously generated reference outputs.

# We need to make sure that, if we're running the tests on Windows, that we'll have consistent
# line breaks. So we'll normalize CRLF to LF.
if Sys.iswindows()
s = replace(s, "\r\n" => "\n")
end

# Remove filesystem paths in doctests failures
s = replace(s, r"(doctest failure in )(.*)$"m => s"\1{PATH}")
s = replace(s, r"(@ Documenter.DocTests )(.*)$"m => s"\1{PATH}")
Expand Down
15 changes: 11 additions & 4 deletions test/doctests/fix/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,22 @@ end
# The version check is necessary due to a behaviour change in https://github.com/JuliaLang/julia/pull/32851
mktempdir_nocleanup(dir) = VERSION >= v"1.3.0-alpha.112" ? mktempdir(dir, cleanup = false) : mktempdir(dir)

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,
# so instead of copying them we read + write.
write(joinpath(srcdir, "index.md"), read(joinpath(@__DIR__, "broken.md")))
write(joinpath(srcdir, "src.jl"), read(joinpath(@__DIR__, "broken.jl")))
src_jl = joinpath(srcdir, "src.jl")
index_md = joinpath(srcdir, "index.md")
write(index_md, normalize_line_endings(joinpath(@__DIR__, "broken.md")))
write(src_jl, normalize_line_endings(joinpath(@__DIR__, "broken.jl")))

# fix up
include(joinpath(srcdir, "src.jl")); @eval import .Foo
Expand All @@ -41,8 +48,8 @@ function test_doctest_fix(dir)
@quietly makedocs(sitename="-", modules = [Foo], source = srcdir, build = builddir, strict = true)

# also test that we obtain the expected output
@test read(joinpath(srcdir, "index.md"), String) == read(joinpath(@__DIR__, "fixed.md"), String)
@test read(joinpath(srcdir, "src.jl"), String) == read(joinpath(@__DIR__, "fixed.jl"), String)
@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
Expand Down