-
Notifications
You must be signed in to change notification settings - Fork 5
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
test: fix line endings in tests on Windows #68
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
03039d3
test: fix lineendings in tests on Windows
mortenpi ec641b0
improve some symlink checks
mortenpi c7354d8
Merge remote-tracking branch 'origin/main' into mp/fix-windows-ci
mortenpi 3fa1bc4
add some windows handling
mortenpi b9dedb5
formatting
mortenpi b1d9953
fix test
mortenpi 7f8380a
fix another test
mortenpi 2edfed6
...
mortenpi 8ca1b5c
wip
mortenpi 22c9921
fix formatting
mortenpi bb7a01e
disable MultiDocumenter on Windows
mortenpi 5ae751a
fix test
mortenpi 4c99bca
test that build errors on windows
mortenpi 2b53b59
add comment, readme notes
mortenpi b8d4ed2
expand readme note
mortenpi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,7 +140,26 @@ function make( | |
canonical_domain::Union{AbstractString,Nothing} = nothing, | ||
sitemap::Bool = false, | ||
sitemap_filename::AbstractString = "sitemap.xml", | ||
# This keyword is for internal test use only: | ||
_override_windows_isinteractive_check::Bool = false, | ||
) | ||
if Sys.iswindows() && !isinteractive() | ||
if _override_windows_isinteractive_check || isinteractive() | ||
@warn """ | ||
Running a MultiDocumenter build interactively in Windows. | ||
This should only be used for development and testing, as it will lead to partial | ||
and broken builds. See https://github.com/JuliaComputing/MultiDocumenter.jl/issues/70 | ||
""" | ||
else | ||
msg = """ | ||
MultiDocumenter deployments are disabled on Windows due to difficulties | ||
with handling symlinks in documentation sources. | ||
You _can_ test this build locally by running it interactively (i.e. in the REPL). | ||
See also: https://github.com/JuliaComputing/MultiDocumenter.jl/issues/70 | ||
""" | ||
error(msg) | ||
end | ||
end | ||
if isnothing(canonical_domain) | ||
(sitemap === true) && | ||
throw(ArgumentError("When sitemap=true, canonical_domain must also be set")) | ||
|
@@ -249,7 +268,8 @@ function maybe_clone(docs::Vector{MultiDocRef}) | |
`$(git()) clone --depth 1 $(doc.giturl) --branch $(doc.branch) --single-branch --no-tags $(doc.upstream)`, | ||
) | ||
else | ||
git_dir, git_worktree = abspath(joinpath(doc.upstream, ".git")), abspath(doc.upstream) | ||
git_dir, git_worktree = | ||
abspath(joinpath(doc.upstream, ".git")), abspath(doc.upstream) | ||
if !isdir(git_dir) | ||
@warn "Unable to update existing clone at $(doc.upstream): .git/ directory missing" | ||
continue | ||
|
@@ -266,7 +286,8 @@ function maybe_clone(docs::Vector{MultiDocRef}) | |
catch e | ||
# We're only interested in catching `git` errors here | ||
isa(e, ProcessFailedException) || rethrow() | ||
@error "Unable to update existing clone at $(doc.upstream)" exception = (e, catch_backtrace()) | ||
@error "Unable to update existing clone at $(doc.upstream)" exception = | ||
(e, catch_backtrace()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated formatting fixes from #61. |
||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,30 @@ docs = [ | |
# giturl = "[email protected]:JuliaComputing/DataSets.jl.git", | ||
), | ||
] | ||
|
||
# We do not support deploying docs on Windows at the moment, and MultiDocumenter | ||
# should throw an error if it's being run on Windows (in a non-interactive session). | ||
# See also: https://github.com/JuliaComputing/MultiDocumenter.jl/issues/70 | ||
if Sys.iswindows() && !isinteractive() | ||
@test_throws ErrorException MultiDocumenter.make( | ||
outpath, | ||
docs; | ||
search_engine = MultiDocumenter.SearchConfig( | ||
index_versions = ["stable", "dev"], | ||
engine = MultiDocumenter.FlexSearch, | ||
), | ||
custom_scripts = [ | ||
"foo/bar.js", | ||
"https://foo.com/bar.js", | ||
Docs.HTML("const foo = 'bar';"), | ||
], | ||
rootpath = rootpath, | ||
canonical_domain = "https://example.org/", | ||
sitemap = true, | ||
sitemap_filename = "sitemap-mydocs.xml", | ||
) | ||
end | ||
|
||
MultiDocumenter.make( | ||
outpath, | ||
docs; | ||
|
@@ -100,15 +124,25 @@ MultiDocumenter.make( | |
canonical_domain = "https://example.org/", | ||
sitemap = true, | ||
sitemap_filename = "sitemap-mydocs.xml", | ||
# The following keyword is not standard: | ||
_override_windows_isinteractive_check = Sys.iswindows(), | ||
) | ||
|
||
@testset "MultiDocumenter.jl" begin | ||
|
||
@testset "structure" begin | ||
@test isdir(outpath, "inf") | ||
@test !isdir(outpath, "inf", "previews") | ||
@test isdir(outpath, "inf", "stable") | ||
@test isfile(outpath, "inf", "stable", "index.html") | ||
if Sys.iswindows() | ||
# On Windows, symlinks are either kept as simple files, or are in fact | ||
# symlinks, but then you would run into permission errors with isdir(). | ||
# So we need to have platform-specific test logic here. | ||
path = joinpath(outpath, "inf", "stable") | ||
@test islink(path) || isfile(path) | ||
else | ||
@test isdir(outpath, "inf", "stable") | ||
@test isfile(outpath, "inf", "stable", "index.html") | ||
end | ||
|
||
@test read(joinpath(outpath, "inf", "index.html"), String) == """ | ||
<!--This file is automatically generated by Documenter.jl--> | ||
|
@@ -122,8 +156,7 @@ MultiDocumenter.make( | |
|
||
|
||
@testset "custom scripts" begin | ||
index = read(joinpath(outpath, "inf", "stable", "index.html"), String) | ||
|
||
index = read(joinpath(outpath, "inf", "v1.6.4", "index.html"), String) | ||
@test occursin( | ||
"""<script charset="utf-8" type="text/javascript">window.MULTIDOCUMENTER_ROOT_PATH = '$rootpath'</script>""", | ||
index, | ||
|
@@ -140,12 +173,36 @@ MultiDocumenter.make( | |
"""<script charset="utf-8" type="text/javascript">const foo = 'bar';</script>""", | ||
index, | ||
) | ||
|
||
if !Sys.iswindows() | ||
# Going through symlinks does not work on Windows | ||
index = read(joinpath(outpath, "inf", "stable", "index.html"), String) | ||
@test occursin( | ||
"""<script charset="utf-8" type="text/javascript">window.MULTIDOCUMENTER_ROOT_PATH = '$rootpath'</script>""", | ||
index, | ||
) | ||
@test occursin( | ||
"""<script charset="utf-8" src="../../foo/bar.js" type="text/javascript"></script>""", | ||
index, | ||
) | ||
@test occursin( | ||
"""<script charset="utf-8" src="https://foo.com/bar.js" type="text/javascript"></script>""", | ||
index, | ||
) | ||
@test occursin( | ||
"""<script charset="utf-8" type="text/javascript">const foo = 'bar';</script>""", | ||
index, | ||
) | ||
end | ||
end | ||
|
||
@testset "canonical URLs" begin | ||
index = read(joinpath(outpath, "inf", "stable", "index.html"), String) | ||
canonical_href = "<link href=\"https://example.org/MultiDocumenter.jl/inf/stable/\" rel=\"canonical\"/>" | ||
@test occursin(canonical_href, index) | ||
# We can't traverse symlinks on Windows, so we ignore this case | ||
if !Sys.iswindows() | ||
index = read(joinpath(outpath, "inf", "stable", "index.html"), String) | ||
canonical_href = "<link href=\"https://example.org/MultiDocumenter.jl/inf/stable/\" rel=\"canonical\"/>" | ||
@test occursin(canonical_href, index) | ||
end | ||
|
||
index = read(joinpath(outpath, "inf", "v1.6.0", "index.html"), String) | ||
canonical_href = "<link href=\"https://example.org/MultiDocumenter.jl/inf/stable/\" rel=\"canonical\"/>" | ||
|
@@ -158,9 +215,17 @@ MultiDocumenter.make( | |
@test !isempty(store_content) | ||
@test occursin("Infiltrator.jl", store_content) | ||
@test occursin("@infiltrate", store_content) | ||
@test occursin("$(rootpath)inf/stable/", store_content) | ||
@test occursin("$(rootpath)inf/stable/", store_content) | ||
@test !occursin("/inf/dev/", store_content) | ||
# We can't traverse symlinks on Windows, so stable/ things do not get | ||
# written into the search index. Instead, it looks like we write dev/ | ||
if Sys.iswindows() | ||
@test !occursin("$(rootpath)inf/stable/", store_content) | ||
@test !occursin("$(rootpath)inf/stable/", store_content) | ||
@test occursin("/inf/dev/", store_content) | ||
else | ||
@test occursin("$(rootpath)inf/stable/", store_content) | ||
@test occursin("$(rootpath)inf/stable/", store_content) | ||
@test !occursin("/inf/dev/", store_content) | ||
end | ||
end | ||
|
||
@testset "sitemap" begin | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pfitzseb So initially I thought we could check if we run into problematic symlinks, and only then error. But I don't think that works, because by default Git on Windows will not create symlinks as far as I can tell. So the "symlinks" are just normal files, and so we can't really distinguish them easily. So instead I added the
isinteractive()
checks here at the very top ofmake.jl
.One consequence here is that we fully "break" running MultiDocumenter on Windows. So we may want to bump this to the next 0.x minor?