diff options
Diffstat (limited to 'python/tidy/tests')
41 files changed, 433 insertions, 0 deletions
diff --git a/python/tidy/tests/Cargo.toml b/python/tidy/tests/Cargo.toml new file mode 100644 index 00000000000..c664352e45f --- /dev/null +++ b/python/tidy/tests/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "test" +version = "0.0.1" +authors = ["The Servo Project Developers"] +publish = false + +[dependencies] +test-package = { version = "*" } + +[lib] +path = "lib.rs"
\ No newline at end of file diff --git a/python/tidy/tests/__init__.py b/python/tidy/tests/__init__.py new file mode 100644 index 00000000000..6b6351ddd2b --- /dev/null +++ b/python/tidy/tests/__init__.py @@ -0,0 +1,8 @@ +# Copyright 2013 The Servo Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution. +# +# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. diff --git a/python/tidy/tests/apache2_license.rs b/python/tidy/tests/apache2_license.rs new file mode 100644 index 00000000000..c9fed89cf73 --- /dev/null +++ b/python/tidy/tests/apache2_license.rs @@ -0,0 +1,5 @@ +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/python/tidy/tests/ban-domrefcell.rs b/python/tidy/tests/ban-domrefcell.rs new file mode 100644 index 00000000000..9bfc9ba8938 --- /dev/null +++ b/python/tidy/tests/ban-domrefcell.rs @@ -0,0 +1,19 @@ +/* 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 https://mozilla.org/MPL/2.0/. */ + +#![feature(plugin)] +#![plugin(script_plugins)] + +extern crate script; + +use script::test::Dom; +use script::test::DomRefCell; +use script::test::Node; + +struct Foo { + bar: DomRefCell<Dom<Node>> + //~^ ERROR Banned type DomRefCell<Dom<T>> detected. Use MutDom<T> instead +} + +fn main() {} diff --git a/python/tidy/tests/ban.rs b/python/tidy/tests/ban.rs new file mode 100644 index 00000000000..9da46d2ee53 --- /dev/null +++ b/python/tidy/tests/ban.rs @@ -0,0 +1,21 @@ +/* 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 https://mozilla.org/MPL/2.0/. */ + +#![feature(plugin)] +#![plugin(script_plugins)] + +extern crate js; + +use js::jsval::JSVal; +use std::cell::Cell; +use std::cell::UnsafeCell; + +struct Foo { + bar: Cell<JSVal>, + //~^ ERROR Banned type Cell<JSVal> detected. Use MutDom<JSVal> instead + foo: UnsafeCell<JSVal> + //~^ NOT AN ERROR +} + +fn main() {} diff --git a/python/tidy/tests/blocked_package.lock b/python/tidy/tests/blocked_package.lock new file mode 100644 index 00000000000..521fdfcfb74 --- /dev/null +++ b/python/tidy/tests/blocked_package.lock @@ -0,0 +1,26 @@ +[root] +name = "servo" +version = "0.0.1" + +[[package]] +name = "test_blocked" +version = "0.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "test_exception" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "test_unneeded_exception" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ +] diff --git a/python/tidy/tests/dir_check/only_webidl/test.webidl b/python/tidy/tests/dir_check/only_webidl/test.webidl new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/python/tidy/tests/dir_check/only_webidl/test.webidl diff --git a/python/tidy/tests/dir_check/webidl_plus/test.rs b/python/tidy/tests/dir_check/webidl_plus/test.rs new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/python/tidy/tests/dir_check/webidl_plus/test.rs diff --git a/python/tidy/tests/dir_check/webidl_plus/test.test b/python/tidy/tests/dir_check/webidl_plus/test.test new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/python/tidy/tests/dir_check/webidl_plus/test.test diff --git a/python/tidy/tests/dir_check/webidl_plus/test.webidl b/python/tidy/tests/dir_check/webidl_plus/test.webidl new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/python/tidy/tests/dir_check/webidl_plus/test.webidl diff --git a/python/tidy/tests/dir_check/webidl_plus/test2.rs b/python/tidy/tests/dir_check/webidl_plus/test2.rs new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/python/tidy/tests/dir_check/webidl_plus/test2.rs diff --git a/python/tidy/tests/duplicate_key.json b/python/tidy/tests/duplicate_key.json new file mode 100644 index 00000000000..6998c789ac9 --- /dev/null +++ b/python/tidy/tests/duplicate_key.json @@ -0,0 +1,7 @@ +{ + "key": "value", + "other_key": { + "the_duplicated_key": 1, + "the_duplicated_key": 2 + } +} diff --git a/python/tidy/tests/duplicate_keys_buildbot_steps.yml b/python/tidy/tests/duplicate_keys_buildbot_steps.yml new file mode 100644 index 00000000000..ed5d046095f --- /dev/null +++ b/python/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/tests/duplicated_package.lock b/python/tidy/tests/duplicated_package.lock new file mode 100644 index 00000000000..22acce4257c --- /dev/null +++ b/python/tidy/tests/duplicated_package.lock @@ -0,0 +1,50 @@ +[root] +name = "servo" +version = "0.0.1" + +[[package]] +name = "test" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "test" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "test2" +version = "0.1.0" +source = "git+https://github.com/user/test2#c54edsf" +dependencies = [ + "test 0.4.9", +] + +[[package]] +name = "test3" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "test 0.5.1", +] + +[[package]] +name = "test3" +version = "0.5.1" +source = "git+https://github.com/user/test3#c54edsf" + +[[package]] +name = "test4" +version = "0.1.0" +source = "git+https://github.com/user/test4#c54edsf" +dependencies = [ + "test3 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "test5" +version = "0.1.0" +source = "git+https://github.com/" +dependencies = [ + "test3 0.5.1 (git+https://github.com/user/test3)", +] diff --git a/python/tidy/tests/empty_file.rs b/python/tidy/tests/empty_file.rs new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/python/tidy/tests/empty_file.rs diff --git a/python/tidy/tests/incorrect_license.rs b/python/tidy/tests/incorrect_license.rs new file mode 100644 index 00000000000..cf85f0e2623 --- /dev/null +++ b/python/tidy/tests/incorrect_license.rs @@ -0,0 +1 @@ +/* Incorrect license here */ diff --git a/python/tidy/tests/lib.rs b/python/tidy/tests/lib.rs new file mode 100644 index 00000000000..5fea057b5c5 --- /dev/null +++ b/python/tidy/tests/lib.rs @@ -0,0 +1,14 @@ +/* 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 https://mozilla.org/MPL/2.0/. */ + +#![feature(def)] +#![feature(abc)] + +#![feature(abc, def, ghi)] +#![feature(aaa)] + +#![feature(def, ghi, abc)] + +#![feature(ghi)] +#![feature(abd, hef)] diff --git a/python/tidy/tests/lints/invalid_error_tuple.py b/python/tidy/tests/lints/invalid_error_tuple.py new file mode 100644 index 00000000000..4851cdf402c --- /dev/null +++ b/python/tidy/tests/lints/invalid_error_tuple.py @@ -0,0 +1,5 @@ +from servo_tidy.tidy import LintRunner + +class Lint(LintRunner): + def run(self): + yield None diff --git a/python/tidy/tests/lints/no_lint.py b/python/tidy/tests/lints/no_lint.py new file mode 100644 index 00000000000..e9f84aa9f3c --- /dev/null +++ b/python/tidy/tests/lints/no_lint.py @@ -0,0 +1,5 @@ +from servo_tidy.tidy import LintRunner + +class Linter(LintRunner): + def run(self): + pass diff --git a/python/tidy/tests/lints/no_run.py b/python/tidy/tests/lints/no_run.py new file mode 100644 index 00000000000..2acd5db1fee --- /dev/null +++ b/python/tidy/tests/lints/no_run.py @@ -0,0 +1,5 @@ +from servo_tidy.tidy import LintRunner + +class Lint(LintRunner): + def some_method(self): + pass diff --git a/python/tidy/tests/lints/not_inherited.py b/python/tidy/tests/lints/not_inherited.py new file mode 100644 index 00000000000..fc38dff2c58 --- /dev/null +++ b/python/tidy/tests/lints/not_inherited.py @@ -0,0 +1,2 @@ +class Lint(object): + pass diff --git a/python/tidy/tests/lints/not_script b/python/tidy/tests/lints/not_script new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/python/tidy/tests/lints/not_script diff --git a/python/tidy/tests/lints/proper_file.py b/python/tidy/tests/lints/proper_file.py new file mode 100644 index 00000000000..acecb82abd4 --- /dev/null +++ b/python/tidy/tests/lints/proper_file.py @@ -0,0 +1,6 @@ +from servo_tidy.tidy import LintRunner + +class Lint(LintRunner): + def run(self): + for _ in [None]: + yield ('path', 0, 'foobar') diff --git a/python/tidy/tests/long_line.rs b/python/tidy/tests/long_line.rs new file mode 100644 index 00000000000..6427aa50878 --- /dev/null +++ b/python/tidy/tests/long_line.rs @@ -0,0 +1,6 @@ +/* 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 https://mozilla.org/MPL/2.0/. */ + +println!("really really loooooooooooooooooooooooooooooooooooooooooooong lineeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"); +let url = "http://www.should.skip/really-looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong-url-strings"; diff --git a/python/tidy/tests/malformed_json.json b/python/tidy/tests/malformed_json.json new file mode 100644 index 00000000000..9b1cf7cbd88 --- /dev/null +++ b/python/tidy/tests/malformed_json.json @@ -0,0 +1,4 @@ +{ + "key": "value", + "other_key": "value_with_bad_quote' +} diff --git a/python/tidy/tests/manifest-include.ini b/python/tidy/tests/manifest-include.ini new file mode 100644 index 00000000000..ade00f2fa31 --- /dev/null +++ b/python/tidy/tests/manifest-include.ini @@ -0,0 +1,5 @@ +skip: true +[html] + skip: false +[never_going_to_exist] + skip: false diff --git a/python/tidy/tests/modeline.txt b/python/tidy/tests/modeline.txt new file mode 100644 index 00000000000..2a3416953ce --- /dev/null +++ b/python/tidy/tests/modeline.txt @@ -0,0 +1,5 @@ +# vim: set noexpandtab: +// vi: et: +/* ex: et: +anything -*-Lisp-*- + -*- mode: Lisp -*- diff --git a/python/tidy/tests/multiline_string.rs b/python/tidy/tests/multiline_string.rs new file mode 100644 index 00000000000..0a4d2fa87ee --- /dev/null +++ b/python/tidy/tests/multiline_string.rs @@ -0,0 +1,28 @@ +/* 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 https://mozilla.org/MPL/2.0/. */ + + +// This puts a "multi-line string +// inside of a comment" and then subsequently has a hyphenated-phrase + + +const FOO: &'static str = "Do not confuse 'apostrophes', + They can be 'lifetimes' or 'characters'"; + + +fn main() { + assert!(foo("test + foo-bar")); + + assert!(foo("test + test2 \" + foo-bar")); + + assert!(foo("test + test2 \ + foo-bar")); + + println!("This is a multiline string with a URL, which kinda, \ + sorta looks like a comment https://github.com/servo/servo/"); +} diff --git a/python/tidy/tests/non_list_mapping_buildbot_steps.yml b/python/tidy/tests/non_list_mapping_buildbot_steps.yml new file mode 100644 index 00000000000..2581aa21d88 --- /dev/null +++ b/python/tidy/tests/non_list_mapping_buildbot_steps.yml @@ -0,0 +1,2 @@ +--- +non-list-key: "string string" diff --git a/python/tidy/tests/non_string_list_buildbot_steps.yml b/python/tidy/tests/non_string_list_buildbot_steps.yml new file mode 100644 index 00000000000..d9255e7cfe5 --- /dev/null +++ b/python/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/tests/rust_tidy.rs b/python/tidy/tests/rust_tidy.rs new file mode 100644 index 00000000000..abd533d5807 --- /dev/null +++ b/python/tidy/tests/rust_tidy.rs @@ -0,0 +1,85 @@ +/* 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 https://mozilla.org/MPL/2.0/. */ + +use app_units::Au; +use raqote::{GradientStop, Source, SolidSource}; +use raqote::{Source, SolidSource}, +ColorPattern, CompositionOp}; +use euclid::Size2D; +use raqote::Gradient; +use raqote::{Gradient}; + + +mod paint_context; +pub mod display_list; +mod test::{ +}; + +extern crate webrender_api; +extern crate style_traits; + +#[foo = "bar,baz"] +#[derive(Copy,Debug, ComputeSquaredDistance)] +impl test { + + fn test_fun(y:f32)->f32{ + let x=5; + x = x-1; + x = x*x; + let z = match y { + 1 =>2, + 2 => 1, + }; + let z = &Vec<T>; + struct Member { + member_name:"Foo" + member_id:5 + } + } + + fn test_fun2(y : &String, z : &Vec<f32>, r: &Root<isize>, s: &DomRoot<isize>) -> () { + let x = true; + x + && x; + if x { + ; + } + else { + ; + } + } + + type Text_Fun3 = fn( i32) -> i32; + + fn test_fun3<Text_Fun3>( y: Text_Fun3) { + let (x, y) = (1, 2) // Should not trigger + test_fun( x); + test_fun (y); + } + + // Should not be triggered + macro_rules! test_macro ( ( $( $fun:ident = $flag:ident ; )* ) => ()); + + let var + = "val"; + + fn test_fun4() + { + } + let var = if true { + "true" + } else { // Should not trigger + "false" + } // Should not trigger + + if true { // Double space after keyword + 42 + } else { + let xif = 42 in { xif } // Should not trigger + } + + let option = Some(3); + println!("{}", option.unwrap()); + panic!("What a way to end."); +} diff --git a/python/tidy/tests/servo-tidy.toml b/python/tidy/tests/servo-tidy.toml new file mode 100644 index 00000000000..690098b0e44 --- /dev/null +++ b/python/tidy/tests/servo-tidy.toml @@ -0,0 +1,19 @@ +key-outside = "" + +[configs] +skip-check-length = false +skip-check-licenses = false +wrong-key = false + +[blocked-packages] + +[wrong] +wrong-key = true + +[ignore] +files = [ + "./fake/file.html", +] +directories = [ + "./fake/dir", +] diff --git a/python/tidy/tests/shebang_license.py b/python/tidy/tests/shebang_license.py new file mode 100644 index 00000000000..f913d5ee1e4 --- /dev/null +++ b/python/tidy/tests/shebang_license.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +# 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 https://mozilla.org/MPL/2.0/. diff --git a/python/tidy/tests/shell_tidy.sh b/python/tidy/tests/shell_tidy.sh new file mode 100644 index 00000000000..e38358fc3b6 --- /dev/null +++ b/python/tidy/tests/shell_tidy.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# +# Tests tidy for shell scripts. + +set -o nounset + +# Talking about some `concept in backticks` # shouldn't trigger +echo "hello world" +some_var=`echo "command substitution"` +another_var="$some_var" +if [ -z "${some_var}" ]; then + echo "should have used [[" +fi +[ -z "${another_var}" ] diff --git a/python/tidy/tests/spec.webidl b/python/tidy/tests/spec.webidl new file mode 100644 index 00000000000..83ce8f935c3 --- /dev/null +++ b/python/tidy/tests/spec.webidl @@ -0,0 +1,10 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* 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 https://mozilla.org/MPL/2.0/. */ + + +interface Test { + [SameObject ] + readonly attribute Node root; +}; diff --git a/python/tidy/tests/speclink.rs b/python/tidy/tests/speclink.rs new file mode 100644 index 00000000000..499953e7bda --- /dev/null +++ b/python/tidy/tests/speclink.rs @@ -0,0 +1,32 @@ +/* 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 https://mozilla.org/MPL/2.0/. */ + +impl SpecLinkMethods for SpecLink { + amacro!("Macros inside impls should trigger spec checks.") + + // Method declarations should trigger spec checks. + fn Test(&self) -> f32 { + amacro!("Macros inside function declarations should not trigger spec checks."); + if unsafe { false } { + } + amacro!("Even if there's weird brace counts."); + 0 + } + + // A spec link. + // https://example.com/ + fn Foo() {} + + /// A spec link. + /// <https://example.com/> + fn Foo() {} + + /// A spec link. + /// <https://example.com/> + /// Doc comments are OK + // Regular comments are OK + #[allow(attributes_too)] + fn Foo() {} +} + diff --git a/python/tidy/tests/test_ignored/whee/foo/bar.rs b/python/tidy/tests/test_ignored/whee/foo/bar.rs new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/python/tidy/tests/test_ignored/whee/foo/bar.rs diff --git a/python/tidy/tests/test_ignored/whee/test.rs b/python/tidy/tests/test_ignored/whee/test.rs new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/python/tidy/tests/test_ignored/whee/test.rs diff --git a/python/tidy/tests/unordered_key.json b/python/tidy/tests/unordered_key.json new file mode 100644 index 00000000000..36f0a13f9c2 --- /dev/null +++ b/python/tidy/tests/unordered_key.json @@ -0,0 +1,7 @@ +{ + "key": "value", + "other_key": { + "b": 1, + "a": 2 + } +} diff --git a/python/tidy/tests/whatwg_link.rs b/python/tidy/tests/whatwg_link.rs new file mode 100644 index 00000000000..d6ed712450a --- /dev/null +++ b/python/tidy/tests/whatwg_link.rs @@ -0,0 +1,6 @@ +/* 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 https://mozilla.org/MPL/2.0/. */ + +// https://html.spec.whatwg.org/multipage/scripting.html#dom-context-2d-putimagedata +// https://html.spec.whatwg.org/#typographic-conventions diff --git a/python/tidy/tests/wrong_space.rs b/python/tidy/tests/wrong_space.rs new file mode 100644 index 00000000000..be735e2d463 --- /dev/null +++ b/python/tidy/tests/wrong_space.rs @@ -0,0 +1,7 @@ +/* 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 https://mozilla.org/MPL/2.0/. */ + +pub struct TestStruct( + pub testMember1: usize, + pub testMember2: bool,
);
\ No newline at end of file |