Skip to content

Commit

Permalink
Adjust JSON comparison in unparse driver
Browse files Browse the repository at this point in the history
Ensure order of keys in JSON objects is not relevant

eng/toolchain/gnatcoll-core#51
  • Loading branch information
Nikokrock committed May 8, 2024
1 parent 300bb9a commit d68e79e
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions testsuite/drivers/unparser_driver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import json
import os.path

from drivers.base_driver import BaseDriver
Expand Down Expand Up @@ -52,16 +53,25 @@ def read_file(filename: str) -> str:
return f.read()

document_baseline_filename = self.test_dir(
self.document_baseline_filename
self.document_baseline_filename)
document_baseline = json.dumps(
json.loads(read_file(document_baseline_filename)),
indent=2,
sort_keys=True,
)
document_actual = json.dumps(
json.loads(read_file(self.working_dir("doc.json"))),
indent=2,
sort_keys=True,
)

result.extend(
self.compute_diff(
baseline_file=document_baseline_filename,
baseline=document_baseline,
actual=document_actual,
failure_message="Prettier document mismatch",
)
)
document_baseline = read_file(document_baseline_filename)
document_actual = read_file(self.working_dir("doc.json"))

result.extend(self.compute_diff(
baseline_file=document_baseline_filename,
baseline=document_baseline,
actual=document_actual,
failure_message="Prettier document mismatch",
))

return result

0 comments on commit d68e79e

Please sign in to comment.