@@ -7,7 +7,7 @@ normalize_newlines(s::AbstractString) = replace(s, "\r\n" => "\n")
77
88@testset " walkdocs" begin
99 let fileinfos = DocumenterTools. FileInfo[]
10- rs = DocumenterTools. walkdocs (joinpath (FIXTURES, " pre" )) do fileinfo
10+ rs = DocumenterTools. walkdocs (joinpath (FIXTURES, " simple. pre" )) do fileinfo
1111 push! (fileinfos, fileinfo)
1212 @test isabspath (fileinfo. root)
1313 @test isabspath (fileinfo. fullpath)
@@ -20,7 +20,7 @@ normalize_newlines(s::AbstractString) = replace(s, "\r\n" => "\n")
2020
2121 let fileinfos = []
2222 rs = DocumenterTools. walkdocs (
23- joinpath (FIXTURES, " pre" ),
23+ joinpath (FIXTURES, " simple. pre" ),
2424 DocumenterTools. isdochtml,
2525 ) do fileinfo
2626 push! (fileinfos, fileinfo)
@@ -33,7 +33,10 @@ normalize_newlines(s::AbstractString) = replace(s, "\r\n" => "\n")
3333 @test length (fileinfos) == 6
3434 end
3535
36- let rs = DocumenterTools. walkdocs (joinpath (FIXTURES, " pre" ), collect = true ) do fileinfo
36+ let rs = DocumenterTools. walkdocs (
37+ joinpath (FIXTURES, " simple.pre" ),
38+ collect = true ,
39+ ) do fileinfo
3740 fileinfo. root
3841 end
3942 @test length (rs) == 9
@@ -115,16 +118,16 @@ end
115118 end
116119 end
117120
118- @testset " update_canonical_links" begin
121+ @testset " update_canonical_links: simple " begin
119122 out = tempname ()
120- cp (joinpath (FIXTURES, " pre" ), out)
123+ cp (joinpath (FIXTURES, " simple. pre" ), out)
121124 @test DocumenterTools. canonical_directory_from_redirect_index_html (out) ==
122125 [" stable" ]
123126 DocumenterTools. update_canonical_links (
124127 out;
125128 canonical = " https://example.org/this-is-test" ,
126129 )
127- DocumenterTools. walkdocs (joinpath (FIXTURES, " post" )) do fileinfo
130+ DocumenterTools. walkdocs (joinpath (FIXTURES, " simple. post" )) do fileinfo
128131 post = normalize_newlines (read (fileinfo. fullpath, String))
129132 changed = normalize_newlines (read (joinpath (out, fileinfo. relpath), String))
130133 if changed != post
137140 # directory, remove index.html and instead use versions.js to determine the stable link
138141 # For that we also need to make sure that stable/ is a symlink
139142 out = tempname ()
140- cp (joinpath (FIXTURES, " pre" ), out)
143+ cp (joinpath (FIXTURES, " simple. pre" ), out)
141144 rm (joinpath (out, " index.html" ))
142145 rm (joinpath (out, " stable" ), recursive = true )
143146 symlink (joinpath (out, " v0.5.0" ), joinpath (out, " stable" ))
158161 out;
159162 canonical = " https://example.org/this-is-test" ,
160163 )
161- DocumenterTools. walkdocs (joinpath (FIXTURES, " post" )) do fileinfo
164+ DocumenterTools. walkdocs (joinpath (FIXTURES, " simple. post" )) do fileinfo
162165 # We removed the root /index.html redirect file, so we skip testing it
163166 (fileinfo. relpath == " index.html" ) && return
164167 # We also don't check the stable/ symlink.
173176 @test changed == post
174177 end
175178 end
179+
180+ # Testing the case where index.html does not have a meta redirect
181+ @testset " update_canonical_links: nometa" begin
182+ out = tempname ()
183+ cp (joinpath (FIXTURES, " nometa.pre" ), out)
184+ @test DocumenterTools. canonical_directory_from_redirect_index_html (out) === nothing
185+ if ! Sys. iswindows ()
186+ # These two tests depend on symlinks, so they do not work on Windows
187+ @test DocumenterTools. canonical_version_from_versions_js (out) == " stable"
188+ # Just tests that the function runs
189+ @test DocumenterTools. update_canonical_links (
190+ out;
191+ canonical = " https://example.org/this-is-test" ,
192+ ) === nothing
193+ end
194+ end
176195end
0 commit comments