servo: Merge #14092 - Sort check on JSON (from kivikakk:sort-check); r=Wafflespeanut
<!-- Please describe your changes on the following line: --> Check that JSON keys are ordered, and that there's no duplicates (for `resources/prefs.json` and `resources/package-prefs.json`). --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] 🆕 `./mach test-tidy --self-test` does not report any errors - [x] These changes fix #12283 <!-- Either: --> - [x] There are tests for these changes 🎉 <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 94d0c485e10138e0d5b2bd8b41b6a922a22a059f
This commit is contained in:
@@ -171,6 +171,12 @@ class CheckTidiness(unittest.TestCase):
|
||||
self.assertEqual('Duplicated Key (the_duplicated_key)', errors.next()[2])
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
def test_json_with_unordered_keys(self):
|
||||
tidy.config["check-ordered-json-keys"].append('python/tidy/servo_tidy_tests/unordered_key.json')
|
||||
errors = tidy.collect_errors_for_files(iterFile('unordered_key.json'), [tidy.check_json], [], print_text=False)
|
||||
self.assertEqual('Unordered key (found b before a)', errors.next()[2])
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
def test_lock(self):
|
||||
errors = tidy.collect_errors_for_files(iterFile('duplicated_package.lock'), [tidy.check_lock], [], print_text=False)
|
||||
msg = """duplicate versions for package "test"
|
||||
|
||||
7
servo/python/tidy/servo_tidy_tests/unordered_key.json
Normal file
7
servo/python/tidy/servo_tidy_tests/unordered_key.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"key": "value",
|
||||
"other_key": {
|
||||
"b": 1,
|
||||
"a": 2
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user