Skip to content
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 14 commits into from
Oct 6, 2016
Merged

Use at-testset for tests #294

merged 14 commits into from
Oct 6, 2016

Conversation

mortenpi
Copy link
Member

@mortenpi mortenpi commented Sep 28, 2016

A pretty big bunch of changes attempting to organize tests in a more readable manner. Addresses #154. I see that #288 doesn't have any tests yet, so I'm hopefully not conflicting with it. Motivation comes from #282 -- I wanted to make a few small changes to examples/ for it.

A summary of the changes:

  • Move to @testset.
  • Allow building examples/ separately (useful for testing changes to HTML writer etc.).
  • No toplevel stuff (modules, types) within a @testset macro, so we need to define modules/types outside it. Hence navnode.jl depends on faketypes.jl and examples/tests.jl (and due to an include, runtests.jl) depends on examples/make.jl.
  • Style change: indent module contents (except if it is the only thing in the file) for readability.
  • Consider pages/ to be part of the examples/ (but also use them + the modules Mod and AutoDocs, defined now in examples/make.jl, in runtests.jl for unit tests).

Things are quite interlinked here and so this ended up being this one big commit at the moment. I am considering splitting it up into several commits to make it easier to review (most importantly to make sure that we're not losing or making useless any of the existing tests). However a discussion on what the final result should look like would be useful before I get to that.

TODO:

  • Fix 0.4 tests.
  • A couple of tests failed due to the module structure changes (marked with TODOs).
  • Add more explanatory comments.

@MichaelHatherly
Copy link
Member

Thanks for doing this! I'll take a closer look once I've gotten the LaTeX stuff out of the way.

Copy link
Member

@MichaelHatherly MichaelHatherly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me. The indentation for inner modules is definitely a good idea, would be good to add a line to the style guide page mentioning it.

Copy link
Member Author

@mortenpi mortenpi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, it became quite a few commits. However, due to the nature of changes, i.e. copy-pasting blocks of code, I think it is a good idea to keep them as separate as possible.

I tried to avoid making any changes to the tests themselves. The few things I had to change I pointed out in the comments (and hopefully didn't forget any).

@@ -21,6 +21,7 @@ Follow the style of the surrounding text when making changes. When adding new fe
### Julia

* 4-space indentation;
* modules spanning entire files should not be indented, but modules that have surrounding code should;
Copy link
Member Author

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.

Copy link
Member

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.


import Documenter: Documenter, DocSystem

const alias_of_getdocs = DocSystem.getdocs # NOTE: won't get docstrings if in a @testset
Copy link
Member Author

Choose a reason for hiding this comment

The 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 (d_4 had 0 docstrings).

info("Building Documenter's docs with LaTeX.")
const Documenter_root = normpath(joinpath(dirname(@__FILE__), "..", "..", "docs"))
doc = makedocs(
debug = true,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a debug flag here.

a = Documenter.Utilities.filterdocs(doc, Set{Module}())
b = Documenter.Utilities.filterdocs(doc, Set{Module}([UnitTests]))
c = Documenter.Utilities.filterdocs(doc, Set{Module}([Base]))
d = Documenter.Utilities.filterdocs(doc, Set{Module}([UtilitiesTests]))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to change the module name here.

@mortenpi
Copy link
Member Author

mortenpi commented Oct 2, 2016

Appveyor failures due to path handling, I'll have to fix those. I was wondering why we have the joinpaths here and there 😆.

Best practice wise though -- should we construct all paths with joinpath or just when we actually use them to compare paths etc.? It doesn't seem necessary for includes, for example.

It is nice to see the testsets in action though:

Test Summary: | Pass  Fail  Error  Total
  Documenter  |  278     2      1    281
  Utilities   |   17                  17
  NavNode     |   19                  19
  DocSystem   |   34                  34
  DOM         |  132                 132
  MDFlatten   |   20                  20
  Examples    |   35     2      1     38
  Markdown    |   34     2      1     37
  HTML        |    1                   1
  Markdown    |   20                  20
  LaTeX       |    1                   1

@MichaelHatherly
Copy link
Member

Best practice wise though -- should we construct all paths with joinpath or just when we actually use them to compare paths etc.? It doesn't seem necessary for includes, for example.

I'd say just always use joinpath when creating paths.

It is nice to see the testsets in action though:

Awesome!

Move the code of setting up the modules and building the examples docs
under examples/ to test/examples/make.jl. This allows the examples/ to
be built without calling the whole runtests.jl file. The pages/* are
considered to be part of the examples/.

The Mod and AutoDocs modules are now indented to help with readability.

Also, the output from the examples/ builds will now be stored under
test/examples/builds/<format>, instead of test/examples/build-<format>.
Moves the tests of the examples/ build to examples/tests.jl. The tests
can be run separately as well.
Also properly indent the test code and add some logic to check if
make.jl has been loaded properly.
And otherwise reorganize the file a bit.

Fixes #154.
@mortenpi
Copy link
Member Author

mortenpi commented Oct 4, 2016

I fixed the paths in examples/tests.jl that were causing issues. So, other than the things below, it should be good to go.

However, I do feel that for includes (e.g. in runtests.jl) it should be sufficient to use the forward slash. Julia handles these paths correctly on Windows and it seems more readable:
include("examples/make.jl")
vs
include(joinpath(dirname(@__FILE__), "examples", "make.jl")).

runtests.jl is slightly inconsistent at the moment though -- the old ones use joinpath, but the new ones I added don't. I should probably make it consistent though, so I would like to drop the joinpaths.

I also took the liberty of dropping branch restrictions from appveyor.yml -- I couldn't build custom branches on my fork and I don't see a particular need for them. If we want to restrict the branches built in the JuliaDocs repo we could do that in the AppVeyor instead. However, if you think we should keep it there, I can drop the commit.

@MichaelHatherly
Copy link
Member

Yeah, paths in include can stay as is without joinpath. All changes look fine to me. I'm currently travelling so feel free to merge once you're happy with this.

Julia already handles cross-platform matters and always includes
files relative to the current file, so they're not necessary and
dropping them makes the code more readable.
@mortenpi
Copy link
Member Author

mortenpi commented Oct 5, 2016

Thanks for reviewing! I removed the few remaining include(joinpath(...)) cases for consistency. Will merge once the tests pass.

@mortenpi mortenpi merged commit f77cd32 into JuliaDocs:master Oct 6, 2016
@mortenpi mortenpi deleted the reorganize-tests branch October 6, 2016 07:27
@MichaelHatherly
Copy link
Member

Thanks for sorting this one out @mortenpi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants