Skip to content

Commit

Permalink
wip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenpi committed Sep 8, 2023
1 parent c8e8d3a commit 04f39a8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 2 deletions.
Binary file added test/examples/images/big.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/examples/images/tiny.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions test/examples/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@ module AutoDocs
end
end

struct MIMEBytes{M <: MIME}
bytes :: Vector{UInt8}
MIMEBytes(mime::AbstractString, bytes::AbstractVector{UInt8}) = new{MIME{Symbol(mime)}}(bytes)
end
Base.show(io::IO, ::M, obj::MIMEBytes{M}) where {M <: MIME} = write(io, obj.bytes)

const BIGPNG = MIMEBytes("image/png", read(joinpath(@__DIR__, "images", "big.png")))
const TINYPNG = MIMEBytes("image/png", read(joinpath(@__DIR__, "images", "tiny.png")))

# Helper functions
function withassets(f, assets...)
src(asset) = joinpath(@__DIR__, asset)
Expand Down
9 changes: 9 additions & 0 deletions test/examples/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,12 @@ They do not get evaluated.
!!! ukw "Unknown admonition class"
Admonition with an unknown admonition class.
## Example outputs to file
```@example
Main.BIGPNG
```
```@example
Main.TINYPNG
```
4 changes: 2 additions & 2 deletions test/examples/src/man/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ SVG("""
Large inline SVG to exceed size threashold.

Check warning on line 279 in test/examples/src/man/tutorial.md

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"threashold" should be "threshold".

```@example inlinesvg
jlcolors = download(https://raw.githubusercontent.com/JuliaLang/julia-logo-graphics/master/images/julia-colors.svg)
open(io->read(io, String), jlcolors) |> SVG
# jlcolors = download(https://raw.githubusercontent.com/JuliaLang/julia-logo-graphics/master/images/julia-colors.svg)
# open(io->read(io, String), jlcolors) |> SVG
```

_Note: we can't define the `show` method in the `@example` block due to the world age
Expand Down
6 changes: 6 additions & 0 deletions test/examples/tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ end
@test haskey(siteinfo_json["documenter"], "julia_version")
@test haskey(siteinfo_json["documenter"], "generation_timestamp")
end

@testset "at-example outputs" begin
@show build_dir
@test isfile(joinpath(build_dir, "index-40245173.png"))
@test read(joinpath(build_dir, "index-40245173.png")) == read(joinpath(@__DIR__, "images", "big.png"))
end
end
end

Expand Down

0 comments on commit 04f39a8

Please sign in to comment.