Skip to content

Commit efd6723

Browse files
author
bors-servo
committed
Auto merge of servo#10563 - mskrzypkows:tidy_tests, r=mbrubeck
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 -->
2 parents d21ff2f + 13847a1 commit efd6723

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

python/tidy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@
6969
os.path.join(".", "."),
7070
]
7171

72+
spec_base_path = "components/script/dom/"
73+
7274

7375
def is_iter_empty(iterator):
7476
try:
@@ -525,10 +527,9 @@ def check_json(filename, contents):
525527

526528

527529
def check_spec(file_name, lines):
528-
base_path = "components/script/dom/"
529-
if base_path not in file_name:
530+
if spec_base_path not in file_name:
530531
raise StopIteration
531-
file_name = os.path.relpath(os.path.splitext(file_name)[0], base_path)
532+
file_name = os.path.relpath(os.path.splitext(file_name)[0], spec_base_path)
532533
patt = re.compile("^\s*\/\/.+")
533534

534535
# Pattern representing a line with a macro

python/tidy_self_test/speclink.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
impl SpecLinkMethods for SpecLink {
6+
fn Test(&self) -> f32 {
7+
0
8+
}
9+
}

python/tidy_self_test/tidy_self_test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ def test_rust(self):
5959
self.assertEqual('use &[T] instead of &Vec<T>', errors.next()[2])
6060
self.assertEqual('use &str instead of &String', errors.next()[2])
6161

62+
def test_spec_link(self):
63+
tidy.spec_base_path = "python/tidy_self_test/"
64+
errors = tidy.collect_errors_for_files(iterFile('speclink.rs'), [], [tidy.check_spec])
65+
self.assertEqual('method declared in webidl is missing a comment with a specification link', errors.next()[2])
66+
6267
def test_webidl(self):
6368
errors = tidy.collect_errors_for_files(iterFile('spec.webidl'), [tidy.check_webidl_spec], [])
6469
self.assertEqual('No specification link found.', errors.next()[2])

0 commit comments

Comments
 (0)