-
Notifications
You must be signed in to change notification settings - Fork 484
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
Use at-testset for tests #294
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
585a9e8
Add a style note on module indentation
mortenpi 9b79f17
Move test/examples build code
mortenpi 172e1c7
Move examples/ tests to a separate file
mortenpi 051af35
Move missing docs tests to a separate file
mortenpi 9ed346d
Indent submodules of Tests in runtests.jl
mortenpi 6cbca40
Use testsets for examples/tests.jl
mortenpi eb524dd
Use testsets for navnode.jl
mortenpi 988f463
Move DOM tests to separate file and use testsets
mortenpi 5189bb7
Move DocSystem tests to a sep. file, use testsets
mortenpi f1b03df
Move Utilities tests to a sep. file, use testsets
mortenpi 0f31e39
Move output tests to separate files, use testsets
mortenpi 4da069b
Use testsets in runtests.jl
mortenpi ef5e3ec
Remove branch restrictions from appveyor.yml
mortenpi cdc1e14
Don't use joinpath in test includes
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
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
module DocSystemTests | ||
|
||
if VERSION >= v"0.5.0-dev+7720" | ||
using Base.Test | ||
else | ||
using BaseTestNext | ||
const Test = BaseTestNext | ||
end | ||
|
||
import Documenter: Documenter, DocSystem | ||
|
||
const alias_of_getdocs = DocSystem.getdocs # NOTE: won't get docstrings if in a @testset | ||
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. I had to move this here, since the test on line 66 started failing ( |
||
|
||
@testset "DocSystem" begin | ||
## Bindings. | ||
@test_throws ArgumentError DocSystem.binding(9000) | ||
let b = Docs.Binding(current_module(), :DocSystem) | ||
@test DocSystem.binding(b) == b | ||
end | ||
let b = DocSystem.binding(Documenter.Documents.Document) | ||
@test b.mod === Documenter.Documents | ||
@test b.var === :Document | ||
end | ||
let b = DocSystem.binding(Documenter) | ||
@test b.mod === Main | ||
@test b.var === :Documenter | ||
end | ||
let b = DocSystem.binding(:Main) | ||
# @test b.mod === Main | ||
@test b.var === :Main | ||
end | ||
let b = DocSystem.binding(DocSystem.binding) | ||
@test b.mod === DocSystem | ||
@test b.var === :binding | ||
end | ||
let b = DocSystem.binding(getfield(Core.Intrinsics, :ccall)) | ||
@test b.mod === Core.Intrinsics | ||
@test b.var === :ccall | ||
end | ||
let b = DocSystem.binding(Documenter, :Documenter) | ||
@test b.mod === Main | ||
@test b.var === :Documenter | ||
end | ||
|
||
## `MultiDoc` object. | ||
@test isdefined(DocSystem, :MultiDoc) | ||
@test fieldnames(DocSystem.MultiDoc) == [:order, :docs] | ||
|
||
## `DocStr` object. | ||
@test isdefined(DocSystem, :DocStr) | ||
@test fieldnames(DocSystem.DocStr) == [:text, :object, :data] | ||
|
||
## `getdocs`. | ||
let b = DocSystem.binding(DocSystem, :getdocs), | ||
d_0 = DocSystem.getdocs(b, Tuple{}), | ||
d_1 = DocSystem.getdocs(b), | ||
d_2 = DocSystem.getdocs(b, Union{Tuple{ANY}, Tuple{ANY, Type}}; compare = (==)), | ||
d_3 = DocSystem.getdocs(b; modules = Module[Main]), | ||
d_4 = DocSystem.getdocs(DocSystem.binding(current_module(), :alias_of_getdocs)), | ||
d_5 = DocSystem.getdocs(DocSystem.binding(current_module(), :alias_of_getdocs); aliases = false) | ||
|
||
@test length(d_0) == 0 | ||
@test length(d_1) == 2 | ||
@test length(d_2) == 1 | ||
@test length(d_3) == 0 | ||
@test length(d_4) == 2 | ||
@test length(d_5) == 0 | ||
|
||
@test d_1[1].data[:binding] == b | ||
@test d_1[2].data[:binding] == b | ||
@test d_1[1].data[:typesig] == Union{Tuple{Docs.Binding}, Tuple{Docs.Binding, Type}} | ||
@test d_1[2].data[:typesig] == Union{Tuple{ANY}, Tuple{ANY, Type}} | ||
@test d_1[1].data[:module] == DocSystem | ||
@test d_1[2].data[:module] == DocSystem | ||
|
||
@test d_2[1].data[:binding] == b | ||
@test d_2[1].data[:typesig] == Union{Tuple{ANY}, Tuple{ANY, Type}} | ||
@test d_2[1].data[:module] == DocSystem | ||
|
||
@test d_1 == d_4 | ||
@test d_1 != d_5 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
module DOMTests | ||
|
||
if VERSION >= v"0.5.0-dev+7720" | ||
using Base.Test | ||
else | ||
using BaseTestNext | ||
const Test = BaseTestNext | ||
end | ||
|
||
import Documenter.Utilities.DOM: DOM, @tags, HTMLDocument | ||
|
||
@tags div ul li p | ||
|
||
@testset "DOM" begin | ||
for tag in (:div, :ul, :li, :p) | ||
TAG = getfield(current_module(), tag) | ||
@test isdefined(tag) | ||
@test isa(TAG, DOM.Tag) | ||
@test TAG.name === tag | ||
end | ||
|
||
@test div().name === :div | ||
@test div().text == "" | ||
@test isempty(div().nodes) | ||
@test isempty(div().attributes) | ||
|
||
@test div("...").name === :div | ||
@test div("...").text == "" | ||
@test length(div("...").nodes) === 1 | ||
@test div("...").nodes[1].text == "..." | ||
@test div("...").nodes[1].name === Symbol("") | ||
@test isempty(div("...").attributes) | ||
|
||
@test div[".class"]("...").name === :div | ||
@test div[".class"]("...").text == "" | ||
@test length(div[".class"]("...").nodes) === 1 | ||
@test div[".class"]("...").nodes[1].text == "..." | ||
@test div[".class"]("...").nodes[1].name === Symbol("") | ||
@test length(div[".class"]("...").attributes) === 1 | ||
@test div[".class"]("...").attributes[1] == (:class => "class") | ||
@test div[:attribute].attributes[1] == (:attribute => "") | ||
@test div[:attribute => "value"].attributes[1] == (:attribute => "value") | ||
|
||
let d = div(ul(map(li, [string(n) for n = 1:10]))) | ||
@test d.name === :div | ||
@test d.text == "" | ||
@test isempty(d.attributes) | ||
@test length(d.nodes) === 1 | ||
let u = d.nodes[1] | ||
@test u.name === :ul | ||
@test u.text == "" | ||
@test isempty(u.attributes) | ||
@test length(u.nodes) === 10 | ||
for n = 1:10 | ||
let v = u.nodes[n] | ||
@test v.name === :li | ||
@test v.text == "" | ||
@test isempty(v.attributes) | ||
@test length(v.nodes) === 1 | ||
@test v.nodes[1].name === Symbol("") | ||
@test v.nodes[1].text == string(n) | ||
@test !isdefined(v.nodes[1], :attributes) | ||
@test !isdefined(v.nodes[1], :nodes) | ||
end | ||
end | ||
end | ||
end | ||
|
||
@tags script style img | ||
|
||
@test string(div(p("one"), p("two"))) == "<div><p>one</p><p>two</p></div>" | ||
@test string(div[:key => "value"]) == "<div key=\"value\"></div>" | ||
@test string(p(" < > & ' \" ")) == "<p> < > & ' " </p>" | ||
@test string(img[:src => "source"]) == "<img src=\"source\"/>" | ||
@test string(img[:none]) == "<img none/>" | ||
@test string(script(" < > & ' \" ")) == "<script> < > & ' \" </script>" | ||
@test string(style(" < > & ' \" ")) == "<style> < > & ' \" </style>" | ||
@test string(script) == "<script>" | ||
|
||
function locally_defined() | ||
@tags button | ||
@test try | ||
x = button | ||
true | ||
catch err | ||
false | ||
end | ||
end | ||
@test !isdefined(current_module(), :button) | ||
locally_defined() | ||
@test !isdefined(current_module(), :button) | ||
|
||
# HTMLDocument | ||
@test string(HTMLDocument(div())) == "<!DOCTYPE html>\n<div></div>\n" | ||
@test string(HTMLDocument("custom doctype", div())) == "<!DOCTYPE custom doctype>\n<div></div>\n" | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Defines the modules referred to in the example docs (under src/) and then builds them. | ||
# It can be called separately to build the examples/, or as part of the test suite. | ||
# | ||
# It defines a set of variables (`examples_*`) that can be used in the tests. | ||
# The `examples_root` should be used to check whether this file has already been included | ||
# or not and should be kept unique. | ||
isdefined(:examples_root) && error("examples_root is already defined\n$(@__FILE__) included multiple times?") | ||
|
||
# The `Mod` and `AutoDocs` modules are assumed to exists in the Main module. | ||
current_module() === Main || error("$(@__FILE__) must be included into Main.") | ||
|
||
# Modules `Mod` and `AutoDocs` | ||
module Mod | ||
""" | ||
func(x) | ||
|
||
[`T`](@ref) | ||
""" | ||
func(x) = x | ||
|
||
""" | ||
T | ||
|
||
[`func(x)`](@ref) | ||
""" | ||
type T end | ||
end | ||
|
||
"`AutoDocs` module." | ||
module AutoDocs | ||
module Pages | ||
include("pages/a.jl") | ||
include("pages/b.jl") | ||
include("pages/c.jl") | ||
include("pages/d.jl") | ||
include("pages/e.jl") | ||
end | ||
|
||
"Function `f`." | ||
f(x) = x | ||
|
||
"Constant `K`." | ||
const K = 1 | ||
|
||
"Type `T`." | ||
type T end | ||
|
||
"Macro `@m`." | ||
macro m() end | ||
|
||
"Module `A`." | ||
module A | ||
"Function `A.f`." | ||
f(x) = x | ||
|
||
"Constant `A.K`." | ||
const K = 1 | ||
|
||
"Type `B.T`." | ||
type T end | ||
|
||
"Macro `B.@m`." | ||
macro m() end | ||
end | ||
|
||
"Module `B`." | ||
module B | ||
"Function `B.f`." | ||
f(x) = x | ||
|
||
"Constant `B.K`." | ||
const K = 1 | ||
|
||
"Type `B.T`." | ||
type T end | ||
|
||
"Macro `B.@m`." | ||
macro m() end | ||
end | ||
end | ||
|
||
# Build example docs | ||
using Documenter | ||
|
||
const examples_root = dirname(@__FILE__) | ||
|
||
info("Building mock package docs: MarkdownWriter") | ||
examples_markdown_doc = makedocs( | ||
debug = true, | ||
root = examples_root, | ||
build = "builds/markdown", | ||
) | ||
|
||
info("Building mock package docs: HTMLWriter") | ||
examples_html_doc = makedocs( | ||
debug = true, | ||
root = examples_root, | ||
build = "builds/html", | ||
format = Documenter.Formats.HTML, | ||
sitename = "Documenter example", | ||
pages = Any[ | ||
"Home" => "index.md", | ||
"Manual" => [ | ||
"man/tutorial.md", | ||
], | ||
"Library" => [ | ||
"lib/functions.md", | ||
"lib/autodocs.md", | ||
] | ||
] | ||
) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.
Added a note here about the modules. Thoughts on the phrasing very welcome.
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.
Wording sounds good to me.