From 7246bd50c2d2bc90cf0301e207a08e7c55ec585e Mon Sep 17 00:00:00 2001 From: Oliver Beckstein Date: Thu, 29 Jun 2023 13:55:10 -0700 Subject: [PATCH] adapt FEP tests to not trigger GROMACS exclusion/rlist limitation - close #175 - use better error handling in runMD_or_exit to check if we triggered the non-bonded interactions beyond cutoff issue and if so, pass with xfail --- mdpow/tests/test_fep_script.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/mdpow/tests/test_fep_script.py b/mdpow/tests/test_fep_script.py index 2ebed629..a8e9ebdd 100644 --- a/mdpow/tests/test_fep_script.py +++ b/mdpow/tests/test_fep_script.py @@ -1,8 +1,9 @@ -from . import tempdir as td - import os +import pytest import pybol +from . import tempdir as td + import gromacs import mdpow @@ -43,14 +44,26 @@ def _run_fep(self, solvent, dirname): gromacs.cbook.edit_mdp(mdp, new_mdp=os.path.join(os.getcwd(), fep_mdp_name), cutoff_scheme="group") - self.S = fep_simulation(cfg, solvent, dirname=dirname) + self.savefilename = fep_simulation(cfg, solvent, dirname=dirname, exit_on_error=False) - def test_default_run(self): + def test_default_run(self, capsys): with gromacs.utilities.in_dir(self.tmpdir.name, create=False): try: self._run_fep('water', 'benzene/') except Exception as err: - raise AssertionError('FEP simulations failed with exception:\n{0}'.format(str(err))) + # check if log file contains + # 'There are 2 perturbed non-bonded pair interactions beyond the pair-list cutoff' + # This error can happen and still counts as passing. (It is stochastic and is due + # to a poorly designed test system together with GROMACS having become better at detecting + # internal problems.) + captured = capsys.readouterr() + for line in captured: + if "perturbed non-bonded pair interactions beyond the pair-list cutoff'" in line: + pytest.xfail("Stochastic test failure (perturbed non-bonded beyond cutoff). " + "Still works as expected, see #175.") + break + else: + raise AssertionError('FEP simulations failed with exception:\n{0}'.format(str(err))) assert os.path.exists(os.path.join(self.tmpdir.name, 'benzene', 'FEP', 'water', 'VDW', '0000', 'md.edr'))