servo: Merge #14051 - Adding linting checks for buildbot_steps.yml (from birryree:tidy-check-buildbot-steps); r=aneeshusa
This pull request adds some tidy checks around YAML files, and specifically `buildbot_steps.yml`. Tidy checks added: * YAML files are checked for well-formedness/parse-ability * Whether a YAML file has duplicate keys * Whether a `buildbot_steps.yml` file contains only mappings to list-of-strings. --- <!-- 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] These changes fix #13838 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> …ing checking for correct mappings and duplicate YAML keys. Added unit tests to test_tidy.py. Source-Repo: https://github.com/servo/servo Source-Revision: 21ad1c210997daba82ec49e1572c7b0634b6f337
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
duplicate_yaml_key:
|
||||
- value1
|
||||
other_key:
|
||||
- value2
|
||||
duplicate_yaml_key:
|
||||
- value3
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
non-list-key: "string string"
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
# This is a buildbot_steps.yml file that should break linting becasue it is not a
|
||||
# mapping to a list of strings
|
||||
mapping_key:
|
||||
- - list_of_list
|
||||
- sublist_item1
|
||||
- sublist_item2
|
||||
@@ -177,6 +177,21 @@ class CheckTidiness(unittest.TestCase):
|
||||
self.assertEqual('Unordered key (found b before a)', errors.next()[2])
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
def test_yaml_with_duplicate_key(self):
|
||||
errors = tidy.collect_errors_for_files(iterFile('duplicate_keys_buildbot_steps.yml'), [tidy.check_yaml], [], print_text=False)
|
||||
self.assertEqual('Duplicated Key (duplicate_yaml_key)', errors.next()[2])
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
def test_non_list_mapped_buildbot_steps(self):
|
||||
errors = tidy.collect_errors_for_files(iterFile('non_list_mapping_buildbot_steps.yml'), [tidy.check_yaml], [], print_text=False)
|
||||
self.assertEqual("Key 'non-list-key' maps to type 'str', but list expected", errors.next()[2])
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
def test_non_string_list_mapping_buildbot_steps(self):
|
||||
errors = tidy.collect_errors_for_files(iterFile('non_string_list_buildbot_steps.yml'), [tidy.check_yaml], [], print_text=False)
|
||||
self.assertEqual("List mapped to 'mapping_key' contains non-string element", 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"
|
||||
|
||||
Reference in New Issue
Block a user