mirror of
https://github.com/servo/servo.git
synced 2025-07-28 09:40:33 +01:00
Test for check_spec function, for tidy.py #9152
This commit is contained in:
parent
e8e354d5d3
commit
13847a1131
3 changed files with 18 additions and 3 deletions
|
@ -69,6 +69,8 @@ ignored_dirs = [
|
||||||
os.path.join(".", "."),
|
os.path.join(".", "."),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
spec_base_path = "components/script/dom/"
|
||||||
|
|
||||||
|
|
||||||
def is_iter_empty(iterator):
|
def is_iter_empty(iterator):
|
||||||
try:
|
try:
|
||||||
|
@ -525,10 +527,9 @@ def check_json(filename, contents):
|
||||||
|
|
||||||
|
|
||||||
def check_spec(file_name, lines):
|
def check_spec(file_name, lines):
|
||||||
base_path = "components/script/dom/"
|
if spec_base_path not in file_name:
|
||||||
if base_path not in file_name:
|
|
||||||
raise StopIteration
|
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*\/\/.+")
|
patt = re.compile("^\s*\/\/.+")
|
||||||
|
|
||||||
# Pattern representing a line with a macro
|
# Pattern representing a line with a macro
|
||||||
|
|
9
python/tidy_self_test/speclink.rs
Normal file
9
python/tidy_self_test/speclink.rs
Normal file
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
|
@ -59,6 +59,11 @@ class CheckTidiness(unittest.TestCase):
|
||||||
self.assertEqual('use &[T] instead of &Vec<T>', errors.next()[2])
|
self.assertEqual('use &[T] instead of &Vec<T>', errors.next()[2])
|
||||||
self.assertEqual('use &str instead of &String', 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):
|
def test_webidl(self):
|
||||||
errors = tidy.collect_errors_for_files(iterFile('spec.webidl'), [tidy.check_webidl_spec], [])
|
errors = tidy.collect_errors_for_files(iterFile('spec.webidl'), [tidy.check_webidl_spec], [])
|
||||||
self.assertEqual('No specification link found.', errors.next()[2])
|
self.assertEqual('No specification link found.', errors.next()[2])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue