Improve FileNameOption error handling
authorTeemu Murtola <teemu.murtola@gmail.com>
Sun, 11 May 2014 18:28:45 +0000 (21:28 +0300)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Tue, 8 Jul 2014 15:05:10 +0000 (17:05 +0200)
commit00fde9b5049e9e927299ecded3f769fc6177e00b
tree6c6a19cfb1e1fc45a794f5b6bc811c6f46dc0349
parent1078df1d559c3ab87274b76c18903497167520de
Improve FileNameOption error handling

- Make FileNameOption check the presence of an input file for required
  input options, and give an informative error message if that is not
  the case.  This hopefully reduces confusion about the
  "File I/O error: topol.tpr" messages that are reported.
- Make FileNameOption check if the file name provided by the user for an
  input file exists, and if it does, only check that it is valid for
  fn2ftp() instead of overriding the user.  If the file name is not
  valid for the option, an informative error is given.
- Add a special mechanism for -multi and -multidir to avoid the check
  above, as well as all other file name completion (that was done
  earlier, but didn't really work as expected).  The same mechanism
  could also replace PCA_NOT_READ_NODE, if someone wants to make that
  work again.
- Move all logic that changes user input to something else or checks
  file system contents to FileNameOptionManager to make that more easily
  customizable.  FileNameOption without a manager now only checks that
  the file name has a recognized and valid type for the option.
- Expose the necessary functionality through FileNameOptionInfo to do
  the above.
- Split tests according to the above division of responsibilities, and
  add tests for most of the error paths.

There is very little code that remains the same in this change, so the
rewrite and move are combined.

The first bullet causes some changes in behavior if programs have
declared file name options with ffREAD, but don't actually use the input
always, but those are easy to fix when found.  This required changing
one existing test for pargs.cpp.

Change-Id: Iea2c60e5de35160cf1faf599afde99b9858e98c7
13 files changed:
src/gromacs/commandline/pargs.cpp
src/gromacs/commandline/pargs.h
src/gromacs/commandline/tests/pargs.cpp
src/gromacs/options/filenameoption.cpp
src/gromacs/options/filenameoption.h
src/gromacs/options/filenameoptionmanager.cpp
src/gromacs/options/filenameoptionmanager.h
src/gromacs/options/filenameoptionstorage.h
src/gromacs/options/tests/CMakeLists.txt
src/gromacs/options/tests/filenameoption.cpp
src/gromacs/options/tests/filenameoptionmanager.cpp [new file with mode: 0644]
src/gromacs/trajectoryanalysis/cmdlinerunner.cpp
src/programs/mdrun/mdrun.cpp