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

Extend Pod::POM::Web::indexer tests #20

Open
wants to merge 6 commits into
base: master
from

Conversation

Projects
None yet
1 participant
@paultcochrane
Contributor

paultcochrane commented Oct 3, 2017

These changes increase the code coverage of the Pod::POM::Web::Indexer tests 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 a SLOW_TESTS environment variable and then only when this is set will the slow tests be run.

Anyway, hope these changes help in some way!

paultcochrane added some commits Oct 3, 2017

Refactor indexer tests to allow for extension
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.
Add tests of uri_escape() function
So that its behaviour is specified as part of the test suite.
Add explicit constructor for Indexer objects
... this will allow us to move some of the global variables into the
object, thus making tests easier to control.
Move global $index_dir var into Indexer constructor
Now we can set this variable to e.g. a temporary directory in tests so
that we can start testing the indexing code.
Add very basic tests of index() function
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.
Add tests of the modlist() function
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment