Skip to content

Commit

Permalink
Auto merge of servo#10563 - mskrzypkows:tidy_tests, r=mbrubeck
Browse files Browse the repository at this point in the history
Test for check_spec function, for tidy.py  servo#9152

Additional test for tidy.py

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10563)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Apr 13, 2016
2 parents d21ff2f + 13847a1 commit efd6723
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
os.path.join(".", "."),
]

spec_base_path = "components/script/dom/"


def is_iter_empty(iterator):
try:
Expand Down Expand Up @@ -525,10 +527,9 @@ def check_json(filename, contents):


def check_spec(file_name, lines):
base_path = "components/script/dom/"
if base_path not in file_name:
if spec_base_path not in file_name:
raise StopIteration
file_name = os.path.relpath(os.path.splitext(file_name)[0], base_path)
file_name = os.path.relpath(os.path.splitext(file_name)[0], spec_base_path)
patt = re.compile("^\s*\/\/.+")

# Pattern representing a line with a macro
Expand Down
9 changes: 9 additions & 0 deletions python/tidy_self_test/speclink.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

impl SpecLinkMethods for SpecLink {
fn Test(&self) -> f32 {
0
}
}
5 changes: 5 additions & 0 deletions python/tidy_self_test/tidy_self_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def test_rust(self):
self.assertEqual('use &[T] instead of &Vec<T>', errors.next()[2])
self.assertEqual('use &str instead of &String', errors.next()[2])

def test_spec_link(self):
tidy.spec_base_path = "python/tidy_self_test/"
errors = tidy.collect_errors_for_files(iterFile('speclink.rs'), [], [tidy.check_spec])
self.assertEqual('method declared in webidl is missing a comment with a specification link', errors.next()[2])

def test_webidl(self):
errors = tidy.collect_errors_for_files(iterFile('spec.webidl'), [tidy.check_webidl_spec], [])
self.assertEqual('No specification link found.', errors.next()[2])
Expand Down

0 comments on commit efd6723

Please sign in to comment.