aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy/servo_tidy_tests
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-12-08 17:39:44 -0800
committerGitHub <noreply@github.com>2016-12-08 17:39:44 -0800
commit21ad1c210997daba82ec49e1572c7b0634b6f337 (patch)
tree08fc167bffaa57878cb2ff99c76ea24bfa30b796 /python/tidy/servo_tidy_tests
parent5b389a228c39f0598d5f1d265bff5c013deaabb4 (diff)
parentaceb60ec1d33d3ce1fb49fb6fab74af3e3a1f0ac (diff)
downloadservo-21ad1c210997daba82ec49e1572c7b0634b6f337.tar.gz
servo-21ad1c210997daba82ec49e1572c7b0634b6f337.zip
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 -->
Diffstat (limited to 'python/tidy/servo_tidy_tests')
-rw-r--r--python/tidy/servo_tidy_tests/duplicate_keys_buildbot_steps.yml7
-rw-r--r--python/tidy/servo_tidy_tests/non_list_mapping_buildbot_steps.yml2
-rw-r--r--python/tidy/servo_tidy_tests/non_string_list_buildbot_steps.yml7
-rw-r--r--python/tidy/servo_tidy_tests/test_tidy.py15
4 files changed, 31 insertions, 0 deletions
diff --git a/python/tidy/servo_tidy_tests/duplicate_keys_buildbot_steps.yml b/python/tidy/servo_tidy_tests/duplicate_keys_buildbot_steps.yml
new file mode 100644
index 00000000000..ed5d046095f
--- /dev/null
+++ b/python/tidy/servo_tidy_tests/duplicate_keys_buildbot_steps.yml
@@ -0,0 +1,7 @@
+---
+duplicate_yaml_key:
+ - value1
+other_key:
+ - value2
+duplicate_yaml_key:
+ - value3
diff --git a/python/tidy/servo_tidy_tests/non_list_mapping_buildbot_steps.yml b/python/tidy/servo_tidy_tests/non_list_mapping_buildbot_steps.yml
new file mode 100644
index 00000000000..2581aa21d88
--- /dev/null
+++ b/python/tidy/servo_tidy_tests/non_list_mapping_buildbot_steps.yml
@@ -0,0 +1,2 @@
+---
+non-list-key: "string string"
diff --git a/python/tidy/servo_tidy_tests/non_string_list_buildbot_steps.yml b/python/tidy/servo_tidy_tests/non_string_list_buildbot_steps.yml
new file mode 100644
index 00000000000..d9255e7cfe5
--- /dev/null
+++ b/python/tidy/servo_tidy_tests/non_string_list_buildbot_steps.yml
@@ -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
diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py
index a6a618d1608..c6fe8bd83fa 100644
--- a/python/tidy/servo_tidy_tests/test_tidy.py
+++ b/python/tidy/servo_tidy_tests/test_tidy.py
@@ -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"