solvate does not check return status of gmx_file_rename
The update_top() function in solvate.cpp concludes with a call to
gmx_file_rename(temporary_filename, topinout); but does not handle failure. Instead, solvate quietly completes without error, but leaves a stray temporary file and/or missing topology file.
Failures in rename could occur due to failures in preceding commands, such as make_backup, or due to filesystem access restrictions.
Since the temporary file is created in the working directory, rather than in the directory where the target file is located, there are extra possible failure cases based on directory permissions or cross-filesystem moves. (Note there is an incorrect inline comment about the atomicity of
rename, which is only atomic when source and target are on the same filesystem.)
errno should also be checked.
This probably affects several versions, but could be affected by change history in futil.cpp, temporary file management, or working directory management.
Improve pytest fixtures for directory management.
- Add a pytest command line option to control whether to remove
temporary directories always, never, or conditionally upon test success.
- Encapsulate context managers and test fixtures for tempdir removal,
temporary changes of working directory, and access to the new pytest
command line argument.
- Use a context manager to use the temporary testing directories
for working directory, as well. Works around potential issues
with GROMACS creating temporary files in different directories
(or filesystems) from where they are relevant.
This change makes identical changes to 3 different conftest.py files.
Consolidation into the gmxapi.testsupport module is deferred to a