From ace2b9eaadd6437de0b512f8337659bc84063e1a Mon Sep 17 00:00:00 2001 From: Jeroen van Straten Date: Mon, 2 Sep 2019 13:11:33 +0200 Subject: [PATCH] Save test case VHDL code when vhdeps launch fails --- tests/testbench/regfile.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/testbench/regfile.py b/tests/testbench/regfile.py index 470e1e0..a1480e9 100644 --- a/tests/testbench/regfile.py +++ b/tests/testbench/regfile.py @@ -2,6 +2,8 @@ import functools import tempfile +import os +import shutil from vhdmmio.config import RegisterFileConfig from vhdmmio.core import RegisterFile from vhdmmio.vhdl import VhdlEntityGenerator, VhdlPackageGenerator @@ -201,8 +203,14 @@ def __enter__(self): self._entity_generator.generate(self._tempdir.name) VhdlPackageGenerator().generate(self._tempdir.name) self._testbench.add_include(self._tempdir.name) - self._testbench.__enter__() - self._testbench.reset() + try: + self._testbench.__enter__() + self._testbench.reset() + except ValueError: + if os.path.isdir('/tmp/vhdmmio-parse-failed'): + shutil.rmtree('/tmp/vhdmmio-parse-failed') + shutil.copytree(self._tempdir.name, '/tmp/vhdmmio-parse-failed') + print('offending VHDL source tree was written to /tmp/vhdmmio-parse-failed') return AttributeDict(self._tb_obs) def __exit__(self, *args):