Extend Pod::POM::Web::indexer tests#20
Open
paultcochrane wants to merge 6 commits intodamil:masterfrom
Open
Conversation
The way the indexer tests were skipping the tests if `Search::Indexer` wasn't available didn't allow further tests to be easily written. By putting the check for `Search::Indexer` into a `BEGIN` block, we can still skip all tests if `Search::Indexer` isn't available, however we can also more easily add tests to this test suite.
So that its behaviour is specified as part of the test suite.
... this will allow us to move some of the global variables into the object, thus making tests easier to control.
Now we can set this variable to e.g. a temporary directory in tests so that we can start testing the indexing code.
Although this causes the test suite to slow down a lot, it at least tests the code and hence gives some support for later refactoring efforts. The indexing operation takes roughly a minute on my box, so this should not be a problem for other dev machines. The comment about the indexing operation taking about half an hour seems as if it could be outdated.
This function requires the index to have been built, hence we build the index again in a new temporary directory to ensure a clean slate before starting the tests. This could be improved upon by not indexing an entire Perl installation as part of the tests, however the code needs to be refactored to allow that and these tests are a step to enabling such future refactorings.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
These changes increase the code coverage of the
Pod::POM::Web::Indexertests to roughly 70%. This figure is a bit misleading, since the tests themselves are very coarse-grained and require the index to be built at least twice; hence the tests take a minute or two to run. Although this sounds like a bad thing, the increased test coverage means one can be more confident in refactoring the codebase and hence the tests can become more focused over time and thus faster again. It might be a good idea to skip some of the tests using the indexing operations on slow hardware; if you want I could add something like aSLOW_TESTSenvironment variable and then only when this is set will the slow tests be run.Anyway, hope these changes help in some way!