mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Auto merge of #14051 - birryree:tidy-check-buildbot-steps, r=aneeshusa
Adding linting checks for buildbot_steps.yml 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. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14051) <!-- Reviewable:end -->
This commit is contained in:
commit
21ad1c2109
6 changed files with 92 additions and 4 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue