copy-merging works afaict! -- some tests still broken: out-of-date
[bigint-presentation-code.git] / src / bigint_presentation_code / register_allocator_test_util.py
1 import unittest
2 import shutil
3
4 from nmutil.get_test_path import get_test_path
5 from bigint_presentation_code.type_util import final
6
7
8 @final
9 class GraphDumper:
10 def __init__(self, test_case):
11 # type: (unittest.TestCase) -> None
12 self.test_case = test_case
13 self.base_path = get_test_path(test_case, "dumped_graphs")
14 shutil.rmtree(self.base_path, ignore_errors=True)
15 self.base_path.mkdir(parents=True, exist_ok=True)
16
17 def __call__(self, name, dot):
18 # type: (str, str) -> None
19 path = self.base_path / name
20 dot_path = path.with_suffix(".dot")
21 dot_path.write_text(dot)