From 692b15811cd7361c9a887fb8e3bcce964bc7f99c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 13 Sep 2024 23:21:40 +0200 Subject: [PATCH] documentation/doxygen: normalize hashes before comparing files. Each Doxygen version differs slightly in those and I just have no patience for it. The actual on-disk files keep the originals so anchors and everything works, but they're replaced when comparing. --- documentation/test_doxygen/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/documentation/test_doxygen/__init__.py b/documentation/test_doxygen/__init__.py index ec046ea8..2a5b620c 100644 --- a/documentation/test_doxygen/__init__.py +++ b/documentation/test_doxygen/__init__.py @@ -36,6 +36,12 @@ from doxygen import State, parse_doxyfile, run, default_templates, default_wildc # https://stackoverflow.com/a/12867228 _camelcase_to_snakecase = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))') +# As Doxygen randomly changes the MD5 hashes, it's a lot less work to just +# replace them all with a static string when comparing. The actual file is not +# changed in order to make it possible to follow the links, it's only for the +# comparison. +_normalize_hashes = re.compile('[0-9a-f]{33}') + def doxygen_version(): return subprocess.check_output(['doxygen', '-v']).decode('utf-8').strip().split(' ')[0] @@ -79,11 +85,12 @@ class BaseTestCase(unittest.TestCase): def actual_expected_contents(self, actual, expected = None): if not expected: expected = actual - with open(os.path.join(self.path, expected)) as f: expected_contents = f.read().strip() with open(os.path.join(self.path, 'html', actual)) as f: actual_contents = f.read().strip() + actual_contents = _normalize_hashes.sub('g'*33, actual_contents) + expected_contents = _normalize_hashes.sub('g'*33, expected_contents) return actual_contents, expected_contents class IntegrationTestCase(BaseTestCase): -- 2.30.2