fix: Compare generated repo map with expected map

This commit is contained in:
Paul Gauthier (aider) 2024-08-23 10:04:28 -07:00
parent 12e406e711
commit 9228a57b66

View file

@ -448,6 +448,30 @@ class TestRepoMapAllLanguages(unittest.TestCase):
# Generate the repo map # Generate the repo map
generated_map = repo_map.get_repo_map([], other_files) generated_map = repo_map.get_repo_map([], other_files)
# Read the expected map from the file
with open(expected_map_file, 'r') as f:
expected_map = f.read().strip()
# Convert the generated map to a string representation
generated_map_str = repo_map.map_to_string(generated_map).strip()
# Compare the generated map with the expected map
if generated_map_str != expected_map:
# If they differ, show the differences and fail the test
import difflib
diff = list(difflib.unified_diff(
expected_map.splitlines(),
generated_map_str.splitlines(),
fromfile='expected',
tofile='generated',
lineterm=''
))
diff_str = '\n'.join(diff)
self.fail(f"Generated map differs from expected map:\n{diff_str}")
# If we reach here, the maps are identical
self.assertEqual(generated_map_str, expected_map, "Generated map matches expected map")
if __name__ == "__main__": if __name__ == "__main__":