本文整理汇总了Python中servo_tidy.tidy.collect_errors_for_files函数的典型用法代码示例。如果您正苦于以下问题:Python collect_errors_for_files函数的具体用法?Python collect_errors_for_files怎么用?Python collect_errors_for_files使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了collect_errors_for_files函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rust
def test_rust(self):
errors = tidy.collect_errors_for_files(iterFile('rust_tidy.rs'), [], [tidy.check_rust], print_text=False)
self.assertEqual('extra space after use', errors.next()[2])
self.assertEqual('extra space after {', errors.next()[2])
self.assertEqual('extra space before }', errors.next()[2])
self.assertEqual('use statement spans multiple lines', errors.next()[2])
self.assertEqual('missing space before }', errors.next()[2])
self.assertTrue('use statement is not in alphabetical order' in errors.next()[2])
self.assertEqual('use statement contains braces for single import', errors.next()[2])
self.assertTrue('use statement is not in alphabetical order' in errors.next()[2])
self.assertEqual('encountered whitespace following a use statement', errors.next()[2])
self.assertTrue('mod declaration is not in alphabetical order' in errors.next()[2])
self.assertEqual('mod declaration spans multiple lines', errors.next()[2])
self.assertTrue('extern crate declaration is not in alphabetical order' in errors.next()[2])
self.assertTrue('derivable traits list is not in alphabetical order' in errors.next()[2])
self.assertEqual('found an empty line following a {', errors.next()[2])
self.assertEqual('missing space before ->', errors.next()[2])
self.assertEqual('missing space after ->', errors.next()[2])
self.assertEqual('missing space after :', errors.next()[2])
self.assertEqual('missing space before {', errors.next()[2])
self.assertEqual('missing space before =', errors.next()[2])
self.assertEqual('missing space after =', errors.next()[2])
self.assertEqual('missing space before -', errors.next()[2])
self.assertEqual('missing space before *', errors.next()[2])
self.assertEqual('missing space after =>', errors.next()[2])
self.assertEqual('missing space after :', errors.next()[2])
self.assertEqual('missing space after :', errors.next()[2])
self.assertEqual('extra space before :', errors.next()[2])
self.assertEqual('extra space before :', 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 &T instead of &Root<T>', errors.next()[2])
self.assertEqual('encountered function signature with -> ()', errors.next()[2])
self.assertEqual('operators should go at the end of the first line', errors.next()[2])
self.assertEqual('else braces should be on the same line', errors.next()[2])
self.assertEqual('extra space after (', errors.next()[2])
self.assertEqual('extra space after (', errors.next()[2])
self.assertEqual('extra space after (', errors.next()[2])
self.assertEqual('extra space after test_fun', errors.next()[2])
self.assertEqual('no = in the beginning of line', errors.next()[2])
self.assertEqual('space before { is not a multiple of 4', errors.next()[2])
self.assertEqual('space before } is not a multiple of 4', errors.next()[2])
self.assertEqual('extra space after if', errors.next()[2])
self.assertNoMoreErrors(errors)
feature_errors = tidy.collect_errors_for_files(iterFile('lib.rs'), [], [tidy.check_rust], print_text=False)
self.assertTrue('feature attribute is not in alphabetical order' in feature_errors.next()[2])
self.assertTrue('feature attribute is not in alphabetical order' in feature_errors.next()[2])
self.assertTrue('feature attribute is not in alphabetical order' in feature_errors.next()[2])
self.assertTrue('feature attribute is not in alphabetical order' in feature_errors.next()[2])
self.assertNoMoreErrors(feature_errors)
ban_errors = tidy.collect_errors_for_files(iterFile('ban.rs'), [], [tidy.check_rust], print_text=False)
self.assertEqual('Banned type Cell<JSVal> detected. Use MutJS<JSVal> instead', ban_errors.next()[2])
self.assertNoMoreErrors(ban_errors)
ban_errors = tidy.collect_errors_for_files(iterFile('ban-domrefcell.rs'), [], [tidy.check_rust], print_text=False)
self.assertEqual('Banned type DOMRefCell<JS<T>> detected. Use MutJS<JS<T>> instead', ban_errors.next()[2])
self.assertNoMoreErrors(ban_errors)
示例2: test_rust
def test_rust(self):
errors = tidy.collect_errors_for_files(iterFile('rust_tidy.rs'), [], [tidy.check_rust], print_text=False)
self.assertEqual('use statement spans multiple lines', errors.next()[2])
self.assertEqual('missing space before }', errors.next()[2])
self.assertTrue('use statement is not in alphabetical order' in errors.next()[2])
self.assertEqual('use statement contains braces for single import', errors.next()[2])
self.assertEqual('encountered whitespace following a use statement', errors.next()[2])
self.assertTrue('mod declaration is not in alphabetical order' in errors.next()[2])
self.assertEqual('mod declaration spans multiple lines', errors.next()[2])
self.assertTrue('extern crate declaration is not in alphabetical order' in errors.next()[2])
self.assertEqual('found an empty line following a {', errors.next()[2])
self.assertEqual('missing space before ->', errors.next()[2])
self.assertEqual('missing space after ->', errors.next()[2])
self.assertEqual('missing space after :', errors.next()[2])
self.assertEqual('missing space before {', errors.next()[2])
self.assertEqual('missing space before =', errors.next()[2])
self.assertEqual('missing space after =', errors.next()[2])
self.assertEqual('missing space before -', errors.next()[2])
self.assertEqual('missing space before *', errors.next()[2])
self.assertEqual('missing space after =>', errors.next()[2])
self.assertEqual('missing space after :', errors.next()[2])
self.assertEqual('missing space after :', errors.next()[2])
self.assertEqual('extra space before :', errors.next()[2])
self.assertEqual('extra space before :', 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 &T instead of &Root<T>', errors.next()[2])
self.assertEqual('operators should go at the end of the first line', errors.next()[2])
self.assertEqual('else braces should be on the same line', errors.next()[2])
self.assertNoMoreErrors(errors)
示例3: test_modeline
def test_modeline(self):
errors = tidy.collect_errors_for_files(iterFile('modeline.txt'), [], [tidy.check_modeline])
self.assertEqual('vi modeline present', errors.next()[2])
self.assertEqual('vi modeline present', errors.next()[2])
self.assertEqual('vi modeline present', errors.next()[2])
self.assertEqual('emacs file variables present', errors.next()[2])
self.assertEqual('emacs file variables present', errors.next()[2])
示例4: test_rust
def test_rust(self):
errors = tidy.collect_errors_for_files(iterFile("rust_tidy.rs"), [], [tidy.check_rust], print_text=False)
self.assertEqual("use statement spans multiple lines", errors.next()[2])
self.assertEqual("missing space before }", errors.next()[2])
self.assertTrue("use statement is not in alphabetical order" in errors.next()[2])
self.assertEqual("use statement contains braces for single import", errors.next()[2])
self.assertEqual("encountered whitespace following a use statement", errors.next()[2])
self.assertTrue("mod declaration is not in alphabetical order" in errors.next()[2])
self.assertEqual("mod declaration spans multiple lines", errors.next()[2])
self.assertTrue("extern crate declaration is not in alphabetical order" in errors.next()[2])
self.assertEqual("found an empty line following a {", errors.next()[2])
self.assertEqual("missing space before ->", errors.next()[2])
self.assertEqual("missing space after ->", errors.next()[2])
self.assertEqual("missing space after :", errors.next()[2])
self.assertEqual("missing space before {", errors.next()[2])
self.assertEqual("missing space before =", errors.next()[2])
self.assertEqual("missing space after =", errors.next()[2])
self.assertEqual("missing space before -", errors.next()[2])
self.assertEqual("missing space before *", errors.next()[2])
self.assertEqual("missing space after =>", errors.next()[2])
self.assertEqual("missing space after :", errors.next()[2])
self.assertEqual("missing space after :", errors.next()[2])
self.assertEqual("extra space before :", errors.next()[2])
self.assertEqual("extra space before :", 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 &T instead of &Root<T>", errors.next()[2])
self.assertEqual("operators should go at the end of the first line", errors.next()[2])
self.assertNoMoreErrors(errors)
示例5: test_spaces_correctnes
def test_spaces_correctnes(self):
errors = tidy.collect_errors_for_files(iterFile('wrong_space.rs'), [], [tidy.check_by_line], print_text=False)
self.assertEqual('trailing whitespace', errors.next()[2])
self.assertEqual('no newline at EOF', errors.next()[2])
self.assertEqual('tab on line', errors.next()[2])
self.assertEqual('CR on line', errors.next()[2])
self.assertEqual('no newline at EOF', errors.next()[2])
self.assertNoMoreErrors(errors)
示例6: test_modeline
def test_modeline(self):
errors = tidy.collect_errors_for_files(iterFile("modeline.txt"), [], [tidy.check_modeline], print_text=False)
self.assertEqual("vi modeline present", errors.next()[2])
self.assertEqual("vi modeline present", errors.next()[2])
self.assertEqual("vi modeline present", errors.next()[2])
self.assertEqual("emacs file variables present", errors.next()[2])
self.assertEqual("emacs file variables present", errors.next()[2])
self.assertNoMoreErrors(errors)
示例7: test_shell
def test_shell(self):
errors = tidy.collect_errors_for_files(iterFile('shell_tidy.sh'), [], [tidy.check_shell], print_text=False)
self.assertEqual('script does not have shebang "#!/usr/bin/env bash"', errors.next()[2])
self.assertEqual('script is missing options "set -o errexit", "set -o pipefail"', errors.next()[2])
self.assertEqual('script should not use backticks for command substitution', errors.next()[2])
self.assertEqual('variable substitutions should use the full \"${VAR}\" form', errors.next()[2])
self.assertEqual('script should use `[[` instead of `[` for conditional testing', errors.next()[2])
self.assertEqual('script should use `[[` instead of `[` for conditional testing', errors.next()[2])
self.assertNoMoreErrors(errors)
示例8: test_lock
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"
t\033[93mfound dependency on version 0.4.9\033[0m
t\033[91mbut highest version is 0.5.1\033[0m
t\033[93mtry upgrading with\033[0m \033[96m./mach cargo-update -p test:0.4.9\033[0m
tThe following packages depend on version 0.4.9:
t\ttest2"""
self.assertEqual(msg, errors.next()[2])
self.assertNoMoreErrors(errors)
示例9: test_lock
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`
\x1b[93mThe following packages depend on version 0.4.9 from 'crates.io':\x1b[0m
\ttest2
\x1b[93mThe following packages depend on version 0.5.1 from 'crates.io':\x1b[0m"""
self.assertEqual(msg, errors.next()[2])
msg2 = """duplicate versions for package `test3`
\x1b[93mThe following packages depend on version 0.5.1 from 'crates.io':\x1b[0m
\ttest4
\x1b[93mThe following packages depend on version 0.5.1 from 'https://github.com/user/test3':\x1b[0m
\ttest5"""
self.assertEqual(msg2, errors.next()[2])
self.assertNoMoreErrors(errors)
示例10: test_lock_ignore_without_duplicates
def test_lock_ignore_without_duplicates(self):
tidy.config["ignore"]["packages"] = ["test", "test2", "test3", "test5"]
errors = tidy.collect_errors_for_files(iterFile('duplicated_package.lock'), [tidy.check_lock], [], print_text=False)
msg = (
"duplicates for `test2` are allowed, but only single version found"
"\n\t\x1b[93mThe following packages depend on version 0.1.0 from 'https://github.com/user/test2':\x1b[0m"
)
self.assertEqual(msg, errors.next()[2])
msg2 = (
"duplicates for `test5` are allowed, but only single version found"
"\n\t\x1b[93mThe following packages depend on version 0.1.0 from 'https://github.com/':\x1b[0m"
)
self.assertEqual(msg2, errors.next()[2])
self.assertNoMoreErrors(errors)
示例11: test_rust
def test_rust(self):
errors = tidy.collect_errors_for_files(iterFile('rust_tidy.rs'), [], [tidy.check_rust])
self.assertEqual('use statement spans multiple lines', errors.next()[2])
self.assertEqual('missing space before }', errors.next()[2])
self.assertTrue('use statement is not in alphabetical order' in errors.next()[2])
self.assertEqual('encountered whitespace following a use statement', errors.next()[2])
self.assertTrue('mod declaration is not in alphabetical order' in errors.next()[2])
self.assertEqual('mod declaration spans multiple lines', errors.next()[2])
self.assertTrue('extern crate declaration is not in alphabetical order' in errors.next()[2])
self.assertEqual('missing space before ->', errors.next()[2])
self.assertEqual('missing space after ->', errors.next()[2])
self.assertEqual('missing space after :', errors.next()[2])
self.assertEqual('missing space before {', errors.next()[2])
self.assertEqual('missing space before =', errors.next()[2])
self.assertEqual('missing space after =', errors.next()[2])
self.assertEqual('missing space before -', errors.next()[2])
self.assertEqual('missing space before *', errors.next()[2])
self.assertEqual('missing space after =>', errors.next()[2])
self.assertEqual('extra space before :', errors.next()[2])
self.assertEqual('extra space before :', errors.next()[2])
self.assertEqual('use &[T] instead of &Vec<T>', errors.next()[2])
self.assertEqual('use &str instead of &String', errors.next()[2])
示例12: test_spec_link
def test_spec_link(self):
tidy.SPEC_BASE_PATH = base_path
errors = tidy.collect_errors_for_files(iterFile('speclink.rs'), [], [tidy.check_spec], print_text=False)
self.assertEqual('method declared in webidl is missing a comment with a specification link', errors.next()[2])
self.assertNoMoreErrors(errors)
示例13: test_non_string_list_mapping_buildbot_steps
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)
示例14: test_non_list_mapped_buildbot_steps
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)
示例15: test_yaml_with_duplicate_key
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)