Make some unit tests skip file system access
authorTeemu Murtola <teemu.murtola@gmail.com>
Wed, 24 Jun 2015 09:16:54 +0000 (12:16 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Mon, 29 Jun 2015 11:08:38 +0000 (13:08 +0200)
commit4edeca7a30af42f917d5941010e22e50777c7f41
treeea37e873c81485bc5fdfd6056e3565357ccbe794
parent0d9d2c84de9ba6ec585b0814182d683cb6568954
Make some unit tests skip file system access

Make unit tests for FileNameOptionManager not use the file system.
Introduce a FileInputRedirectorInterface to support mocking file
existence checks, and use a mock implementation in the tests.

These particular tests did quite a bit of file system access, and the
speedup is only a few ms, although significant percentually (something
like 80%).  But there can be tests where this has more effect, and this
approach provides a starting point for more work on eliminating
unnecessary file system access from the tests.

The main benefit is clearer and more robust test code, as it is no
longer necessary to construct actual files and ensure that they do not
conflict with other tests or cause issues if the test crashes or such.

Change-Id: Ib9a171331e988fa7e74b16078164f477f8296c6e
src/gromacs/options/filenameoptionmanager.cpp
src/gromacs/options/filenameoptionmanager.h
src/gromacs/options/tests/filenameoptionmanager.cpp
src/gromacs/utility/fileredirector.cpp
src/gromacs/utility/fileredirector.h
src/testutils/CMakeLists.txt
src/testutils/testfileredirector.cpp [new file with mode: 0644]
src/testutils/testfileredirector.h [new file with mode: 0644]
src/testutils/testutils-doc.h