|
132 | 132 | end
|
133 | 133 | @test changed == post
|
134 | 134 | end
|
| 135 | + |
| 136 | + # We take the fixtures/pre directory, but copy it over into a temporary |
| 137 | + # directory, remove index.html and instead use versions.js to determine the stable link |
| 138 | + # For that we also need to make sure that stable/ is a symlink |
| 139 | + out = tempname() |
| 140 | + cp(joinpath(FIXTURES, "pre"), out) |
| 141 | + rm(joinpath(out, "index.html")) |
| 142 | + rm(joinpath(out, "stable"), recursive = true) |
| 143 | + symlink(joinpath(out, "v0.5.0"), joinpath(out, "stable")) |
| 144 | + open(joinpath(out, "versions.js"), write = true) do io |
| 145 | + versions_js = """ |
| 146 | + var DOC_VERSIONS = [ |
| 147 | + "stable", |
| 148 | + "v0.5.0", |
| 149 | + ]; |
| 150 | + var DOCUMENTER_NEWEST = "v0.5.0"; |
| 151 | + var DOCUMENTER_STABLE = "stable"; |
| 152 | + """ |
| 153 | + write(io, versions_js) |
| 154 | + end |
| 155 | + @test DocumenterTools.canonical_directory_from_redirect_index_html(out) === nothing |
| 156 | + @test DocumenterTools.canonical_version_from_versions_js(out) == "stable" |
| 157 | + DocumenterTools.update_canonical_links( |
| 158 | + out; |
| 159 | + canonical = "https://example.org/this-is-test", |
| 160 | + ) |
| 161 | + DocumenterTools.walkdocs(joinpath(FIXTURES, "post")) do fileinfo |
| 162 | + # We removed the root /index.html redirect file, so we skip testing it |
| 163 | + (fileinfo.relpath == "index.html") && return |
| 164 | + # We also don't check the stable/ symlink. |
| 165 | + # Note: the regex is necessary to handle Windows path separators. |
| 166 | + startswith(fileinfo.relpath, r"stable[\\/]") && return |
| 167 | + # Compare the file contents for the rest of the files: |
| 168 | + post = normalize_newlines(read(fileinfo.fullpath, String)) |
| 169 | + changed = normalize_newlines(read(joinpath(out, fileinfo.relpath), String)) |
| 170 | + if changed != post |
| 171 | + @error "update_canonical_links: change and post not matching" out fileinfo |
| 172 | + end |
| 173 | + @test changed == post |
| 174 | + end |
135 | 175 | end
|
136 | 176 | end
|
0 commit comments