diff options
author | Martin Robinson <mrobinson@igalia.com> | 2023-06-15 12:34:27 +0200 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-06-15 13:10:06 +0200 |
commit | 81433a8684d078ae629ba24f30f877028e361136 (patch) | |
tree | c974ac6f5741138f4926e02ca6a3f35abfc46738 /python/tidy/servo_tidy_tests | |
parent | fa266abd29688833e1ffa5995230e5a6c30161f6 (diff) | |
download | servo-81433a8684d078ae629ba24f30f877028e361136.tar.gz servo-81433a8684d078ae629ba24f30f877028e361136.zip |
Convert tidy to a non-egg Python package
It seems that servo-tidy is only used by webrender in my GitHub
searches. WebRender could simply use `rustfmt` and the tidy on pypi
hasn't been updated since 2018. Converting tidy to a normal Python
package removes the maintenance burden of continually fixing the easy
install configuration.
Fixes #29094.
Fixes #29334.
Diffstat (limited to 'python/tidy/servo_tidy_tests')
42 files changed, 0 insertions, 722 deletions
diff --git a/python/tidy/servo_tidy_tests/Cargo.toml b/python/tidy/servo_tidy_tests/Cargo.toml deleted file mode 100644 index c664352e45f..00000000000 --- a/python/tidy/servo_tidy_tests/Cargo.toml +++ /dev/null @@ -1,11 +0,0 @@ -[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/servo_tidy_tests/__init__.py b/python/tidy/servo_tidy_tests/__init__.py deleted file mode 100644 index 6b6351ddd2b..00000000000 --- a/python/tidy/servo_tidy_tests/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# 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/servo_tidy_tests/apache2_license.rs b/python/tidy/servo_tidy_tests/apache2_license.rs deleted file mode 100644 index c9fed89cf73..00000000000 --- a/python/tidy/servo_tidy_tests/apache2_license.rs +++ /dev/null @@ -1,5 +0,0 @@ -// 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/servo_tidy_tests/ban-domrefcell.rs b/python/tidy/servo_tidy_tests/ban-domrefcell.rs deleted file mode 100644 index 9bfc9ba8938..00000000000 --- a/python/tidy/servo_tidy_tests/ban-domrefcell.rs +++ /dev/null @@ -1,19 +0,0 @@ -/* 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/servo_tidy_tests/ban.rs b/python/tidy/servo_tidy_tests/ban.rs deleted file mode 100644 index 9da46d2ee53..00000000000 --- a/python/tidy/servo_tidy_tests/ban.rs +++ /dev/null @@ -1,21 +0,0 @@ -/* 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/servo_tidy_tests/blocked_package.lock b/python/tidy/servo_tidy_tests/blocked_package.lock deleted file mode 100644 index 521fdfcfb74..00000000000 --- a/python/tidy/servo_tidy_tests/blocked_package.lock +++ /dev/null @@ -1,26 +0,0 @@ -[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/servo_tidy_tests/dir_check/only_webidl/test.webidl b/python/tidy/servo_tidy_tests/dir_check/only_webidl/test.webidl deleted file mode 100644 index e69de29bb2d..00000000000 --- a/python/tidy/servo_tidy_tests/dir_check/only_webidl/test.webidl +++ /dev/null diff --git a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.rs b/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.rs deleted file mode 100644 index e69de29bb2d..00000000000 --- a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.rs +++ /dev/null diff --git a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.test b/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.test deleted file mode 100644 index e69de29bb2d..00000000000 --- a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.test +++ /dev/null diff --git a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.webidl b/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.webidl deleted file mode 100644 index e69de29bb2d..00000000000 --- a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.webidl +++ /dev/null diff --git a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test2.rs b/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test2.rs deleted file mode 100644 index e69de29bb2d..00000000000 --- a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test2.rs +++ /dev/null diff --git a/python/tidy/servo_tidy_tests/duplicate_key.json b/python/tidy/servo_tidy_tests/duplicate_key.json deleted file mode 100644 index 6998c789ac9..00000000000 --- a/python/tidy/servo_tidy_tests/duplicate_key.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "key": "value", - "other_key": { - "the_duplicated_key": 1, - "the_duplicated_key": 2 - } -} diff --git a/python/tidy/servo_tidy_tests/duplicate_keys_buildbot_steps.yml b/python/tidy/servo_tidy_tests/duplicate_keys_buildbot_steps.yml deleted file mode 100644 index ed5d046095f..00000000000 --- a/python/tidy/servo_tidy_tests/duplicate_keys_buildbot_steps.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -duplicate_yaml_key: - - value1 -other_key: - - value2 -duplicate_yaml_key: - - value3 diff --git a/python/tidy/servo_tidy_tests/duplicated_package.lock b/python/tidy/servo_tidy_tests/duplicated_package.lock deleted file mode 100644 index 22acce4257c..00000000000 --- a/python/tidy/servo_tidy_tests/duplicated_package.lock +++ /dev/null @@ -1,50 +0,0 @@ -[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/servo_tidy_tests/empty_file.rs b/python/tidy/servo_tidy_tests/empty_file.rs deleted file mode 100644 index e69de29bb2d..00000000000 --- a/python/tidy/servo_tidy_tests/empty_file.rs +++ /dev/null diff --git a/python/tidy/servo_tidy_tests/incorrect_license.rs b/python/tidy/servo_tidy_tests/incorrect_license.rs deleted file mode 100644 index cf85f0e2623..00000000000 --- a/python/tidy/servo_tidy_tests/incorrect_license.rs +++ /dev/null @@ -1 +0,0 @@ -/* Incorrect license here */ diff --git a/python/tidy/servo_tidy_tests/lib.rs b/python/tidy/servo_tidy_tests/lib.rs deleted file mode 100644 index 5fea057b5c5..00000000000 --- a/python/tidy/servo_tidy_tests/lib.rs +++ /dev/null @@ -1,14 +0,0 @@ -/* 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/servo_tidy_tests/lints/invalid_error_tuple.py b/python/tidy/servo_tidy_tests/lints/invalid_error_tuple.py deleted file mode 100644 index 4851cdf402c..00000000000 --- a/python/tidy/servo_tidy_tests/lints/invalid_error_tuple.py +++ /dev/null @@ -1,5 +0,0 @@ -from servo_tidy.tidy import LintRunner - -class Lint(LintRunner): - def run(self): - yield None diff --git a/python/tidy/servo_tidy_tests/lints/no_lint.py b/python/tidy/servo_tidy_tests/lints/no_lint.py deleted file mode 100644 index e9f84aa9f3c..00000000000 --- a/python/tidy/servo_tidy_tests/lints/no_lint.py +++ /dev/null @@ -1,5 +0,0 @@ -from servo_tidy.tidy import LintRunner - -class Linter(LintRunner): - def run(self): - pass diff --git a/python/tidy/servo_tidy_tests/lints/no_run.py b/python/tidy/servo_tidy_tests/lints/no_run.py deleted file mode 100644 index 2acd5db1fee..00000000000 --- a/python/tidy/servo_tidy_tests/lints/no_run.py +++ /dev/null @@ -1,5 +0,0 @@ -from servo_tidy.tidy import LintRunner - -class Lint(LintRunner): - def some_method(self): - pass diff --git a/python/tidy/servo_tidy_tests/lints/not_inherited.py b/python/tidy/servo_tidy_tests/lints/not_inherited.py deleted file mode 100644 index fc38dff2c58..00000000000 --- a/python/tidy/servo_tidy_tests/lints/not_inherited.py +++ /dev/null @@ -1,2 +0,0 @@ -class Lint(object): - pass diff --git a/python/tidy/servo_tidy_tests/lints/not_script b/python/tidy/servo_tidy_tests/lints/not_script deleted file mode 100644 index e69de29bb2d..00000000000 --- a/python/tidy/servo_tidy_tests/lints/not_script +++ /dev/null diff --git a/python/tidy/servo_tidy_tests/lints/proper_file.py b/python/tidy/servo_tidy_tests/lints/proper_file.py deleted file mode 100644 index acecb82abd4..00000000000 --- a/python/tidy/servo_tidy_tests/lints/proper_file.py +++ /dev/null @@ -1,6 +0,0 @@ -from servo_tidy.tidy import LintRunner - -class Lint(LintRunner): - def run(self): - for _ in [None]: - yield ('path', 0, 'foobar') diff --git a/python/tidy/servo_tidy_tests/long_line.rs b/python/tidy/servo_tidy_tests/long_line.rs deleted file mode 100644 index 6427aa50878..00000000000 --- a/python/tidy/servo_tidy_tests/long_line.rs +++ /dev/null @@ -1,6 +0,0 @@ -/* 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/servo_tidy_tests/malformed_json.json b/python/tidy/servo_tidy_tests/malformed_json.json deleted file mode 100644 index 9b1cf7cbd88..00000000000 --- a/python/tidy/servo_tidy_tests/malformed_json.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "key": "value", - "other_key": "value_with_bad_quote' -} diff --git a/python/tidy/servo_tidy_tests/manifest-include.ini b/python/tidy/servo_tidy_tests/manifest-include.ini deleted file mode 100644 index ade00f2fa31..00000000000 --- a/python/tidy/servo_tidy_tests/manifest-include.ini +++ /dev/null @@ -1,5 +0,0 @@ -skip: true -[html] - skip: false -[never_going_to_exist] - skip: false diff --git a/python/tidy/servo_tidy_tests/modeline.txt b/python/tidy/servo_tidy_tests/modeline.txt deleted file mode 100644 index 2a3416953ce..00000000000 --- a/python/tidy/servo_tidy_tests/modeline.txt +++ /dev/null @@ -1,5 +0,0 @@ -# vim: set noexpandtab: -// vi: et: -/* ex: et: -anything -*-Lisp-*- - -*- mode: Lisp -*- diff --git a/python/tidy/servo_tidy_tests/multiline_string.rs b/python/tidy/servo_tidy_tests/multiline_string.rs deleted file mode 100644 index 0a4d2fa87ee..00000000000 --- a/python/tidy/servo_tidy_tests/multiline_string.rs +++ /dev/null @@ -1,28 +0,0 @@ -/* 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/servo_tidy_tests/non_list_mapping_buildbot_steps.yml b/python/tidy/servo_tidy_tests/non_list_mapping_buildbot_steps.yml deleted file mode 100644 index 2581aa21d88..00000000000 --- a/python/tidy/servo_tidy_tests/non_list_mapping_buildbot_steps.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -non-list-key: "string string" diff --git a/python/tidy/servo_tidy_tests/non_string_list_buildbot_steps.yml b/python/tidy/servo_tidy_tests/non_string_list_buildbot_steps.yml deleted file mode 100644 index d9255e7cfe5..00000000000 --- a/python/tidy/servo_tidy_tests/non_string_list_buildbot_steps.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -# 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/servo_tidy_tests/rust_tidy.rs b/python/tidy/servo_tidy_tests/rust_tidy.rs deleted file mode 100644 index abd533d5807..00000000000 --- a/python/tidy/servo_tidy_tests/rust_tidy.rs +++ /dev/null @@ -1,85 +0,0 @@ -/* 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/servo_tidy_tests/servo-tidy.toml b/python/tidy/servo_tidy_tests/servo-tidy.toml deleted file mode 100644 index 690098b0e44..00000000000 --- a/python/tidy/servo_tidy_tests/servo-tidy.toml +++ /dev/null @@ -1,19 +0,0 @@ -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/servo_tidy_tests/shebang_license.py b/python/tidy/servo_tidy_tests/shebang_license.py deleted file mode 100644 index f913d5ee1e4..00000000000 --- a/python/tidy/servo_tidy_tests/shebang_license.py +++ /dev/null @@ -1,4 +0,0 @@ -#!/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/servo_tidy_tests/shell_tidy.sh b/python/tidy/servo_tidy_tests/shell_tidy.sh deleted file mode 100644 index e38358fc3b6..00000000000 --- a/python/tidy/servo_tidy_tests/shell_tidy.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/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/servo_tidy_tests/spec.webidl b/python/tidy/servo_tidy_tests/spec.webidl deleted file mode 100644 index 83ce8f935c3..00000000000 --- a/python/tidy/servo_tidy_tests/spec.webidl +++ /dev/null @@ -1,10 +0,0 @@ -/* -*- 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/servo_tidy_tests/speclink.rs b/python/tidy/servo_tidy_tests/speclink.rs deleted file mode 100644 index 499953e7bda..00000000000 --- a/python/tidy/servo_tidy_tests/speclink.rs +++ /dev/null @@ -1,32 +0,0 @@ -/* 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/servo_tidy_tests/test_ignored/whee/foo/bar.rs b/python/tidy/servo_tidy_tests/test_ignored/whee/foo/bar.rs deleted file mode 100644 index e69de29bb2d..00000000000 --- a/python/tidy/servo_tidy_tests/test_ignored/whee/foo/bar.rs +++ /dev/null diff --git a/python/tidy/servo_tidy_tests/test_ignored/whee/test.rs b/python/tidy/servo_tidy_tests/test_ignored/whee/test.rs deleted file mode 100644 index e69de29bb2d..00000000000 --- a/python/tidy/servo_tidy_tests/test_ignored/whee/test.rs +++ /dev/null diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/servo_tidy_tests/test_tidy.py deleted file mode 100644 index 6138320cc35..00000000000 --- a/python/tidy/servo_tidy_tests/test_tidy.py +++ /dev/null @@ -1,289 +0,0 @@ -# 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. - -import os -import unittest - -from servo_tidy import tidy - -base_path = 'servo_tidy_tests/' if os.path.exists('servo_tidy_tests/') else 'python/tidy/servo_tidy_tests/' - - -def iterFile(name): - return iter([os.path.join(base_path, name)]) - - -class CheckTidiness(unittest.TestCase): - def assertNoMoreErrors(self, errors): - with self.assertRaises(StopIteration): - next(errors) - - def test_tidy_config(self): - errors = tidy.check_config_file(os.path.join(base_path, 'servo-tidy.toml'), print_text=False) - self.assertEqual("invalid config key 'key-outside'", next(errors)[2]) - self.assertEqual("invalid config key 'wrong-key'", next(errors)[2]) - self.assertEqual('invalid config table [wrong]', next(errors)[2]) - self.assertEqual("ignored file './fake/file.html' doesn't exist", next(errors)[2]) - self.assertEqual("ignored directory './fake/dir' doesn't exist", next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_non_existing_wpt_manifest_checks(self): - wrong_path = "/wrong/path.ini" - errors = tidy.check_manifest_dirs(wrong_path, print_text=False) - self.assertEqual("%s manifest file is required but was not found" % wrong_path, next(errors)[2]) - self.assertNoMoreErrors(errors) - errors = tidy.check_manifest_dirs(os.path.join(base_path, 'manifest-include.ini'), print_text=False) - self.assertTrue(next(errors)[2].endswith("never_going_to_exist")) - self.assertNoMoreErrors(errors) - - def test_directory_checks(self): - dirs = { - os.path.join(base_path, "dir_check/webidl_plus"): ['webidl', 'test'], - os.path.join(base_path, "dir_check/only_webidl"): ['webidl'] - } - errors = tidy.check_directory_files(dirs) - error_dir = os.path.join(base_path, "dir_check/webidl_plus") - self.assertEqual("Unexpected extension found for test.rs. We only expect files with webidl, test extensions in {0}".format(error_dir), next(errors)[2]) - self.assertEqual("Unexpected extension found for test2.rs. We only expect files with webidl, test extensions in {0}".format(error_dir), next(errors)[2]) - self.assertNoMoreErrors(errors) - - 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', next(errors)[2]) - self.assertEqual('no newline at EOF', next(errors)[2]) - self.assertEqual('tab on line', next(errors)[2]) - self.assertEqual('CR on line', next(errors)[2]) - self.assertEqual('no newline at EOF', next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_empty_file(self): - errors = tidy.collect_errors_for_files(iterFile('empty_file.rs'), [], [tidy.check_by_line], print_text=False) - self.assertEqual('file is empty', next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_long_line(self): - errors = tidy.collect_errors_for_files(iterFile('long_line.rs'), [], [tidy.check_by_line], print_text=False) - self.assertEqual('Line is longer than 120 characters', next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_whatwg_link(self): - errors = tidy.collect_errors_for_files(iterFile('whatwg_link.rs'), [], [tidy.check_by_line], print_text=False) - self.assertTrue('link to WHATWG may break in the future, use this format instead:' in next(errors)[2]) - self.assertTrue('links to WHATWG single-page url, change to multi page:' in next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_license(self): - errors = tidy.collect_errors_for_files(iterFile('incorrect_license.rs'), [], [tidy.check_license], print_text=False) - self.assertEqual('incorrect license', next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_shebang_license(self): - errors = tidy.collect_errors_for_files(iterFile('shebang_license.py'), [], [tidy.check_license], print_text=False) - self.assertEqual('missing blank line after shebang', next(errors)[2]) - self.assertNoMoreErrors(errors) - - 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"', next(errors)[2]) - self.assertEqual('script is missing options "set -o errexit", "set -o pipefail"', next(errors)[2]) - self.assertEqual('script should not use backticks for command substitution', next(errors)[2]) - self.assertEqual('variable substitutions should use the full \"${VAR}\" form', next(errors)[2]) - self.assertEqual('script should use `[[` instead of `[` for conditional testing', next(errors)[2]) - self.assertEqual('script should use `[[` instead of `[` for conditional testing', next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_apache2_incomplete(self): - errors = tidy.collect_errors_for_files(iterFile('apache2_license.rs'), [], [tidy.check_license]) - self.assertEqual('incorrect license', next(errors)[2]) - - def test_rust(self): - errors = tidy.collect_errors_for_files(iterFile('rust_tidy.rs'), [], [tidy.check_rust], print_text=False) - self.assertTrue('mod declaration is not in alphabetical order' in next(errors)[2]) - self.assertEqual('mod declaration spans multiple lines', next(errors)[2]) - self.assertTrue('extern crate declaration is not in alphabetical order' in next(errors)[2]) - self.assertTrue('derivable traits list is not in alphabetical order' in next(errors)[2]) - self.assertEqual('found an empty line following a {', next(errors)[2]) - self.assertEqual('use &[T] instead of &Vec<T>', next(errors)[2]) - self.assertEqual('use &str instead of &String', next(errors)[2]) - self.assertEqual('use &T instead of &Root<T>', next(errors)[2]) - self.assertEqual('use &T instead of &DomRoot<T>', next(errors)[2]) - self.assertEqual('encountered function signature with -> ()', next(errors)[2]) - self.assertEqual('operators should go at the end of the first line', next(errors)[2]) - self.assertEqual('unwrap() or panic!() found in code which should not panic.', next(errors)[2]) - self.assertEqual('unwrap() or panic!() found in code which should not panic.', next(errors)[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 next(feature_errors)[2]) - self.assertTrue('feature attribute is not in alphabetical order' in next(feature_errors)[2]) - self.assertTrue('feature attribute is not in alphabetical order' in next(feature_errors)[2]) - self.assertTrue('feature attribute is not in alphabetical order' in next(feature_errors)[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 MutDom<JSVal> instead', next(ban_errors)[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<Dom<T>> detected. Use MutDom<T> instead', next(ban_errors)[2]) - self.assertNoMoreErrors(ban_errors) - - 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', next(errors)[2]) - self.assertEqual('method declared in webidl is missing a comment with a specification link', next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_webidl(self): - errors = tidy.collect_errors_for_files(iterFile('spec.webidl'), [tidy.check_webidl_spec], [], print_text=False) - self.assertEqual('No specification link found.', next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_toml(self): - errors = tidy.collect_errors_for_files(iterFile('Cargo.toml'), [], [tidy.check_toml], print_text=False) - self.assertEqual('found asterisk instead of minimum version number', next(errors)[2]) - self.assertEqual('.toml file should contain a valid license.', next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_modeline(self): - errors = tidy.collect_errors_for_files(iterFile('modeline.txt'), [], [tidy.check_modeline], print_text=False) - self.assertEqual('vi modeline present', next(errors)[2]) - self.assertEqual('vi modeline present', next(errors)[2]) - self.assertEqual('vi modeline present', next(errors)[2]) - self.assertEqual('emacs file variables present', next(errors)[2]) - self.assertEqual('emacs file variables present', next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_malformed_json(self): - errors = tidy.collect_errors_for_files(iterFile('malformed_json.json'), [tidy.check_json], [], print_text=False) - self.assertEqual('Invalid control character at: line 3 column 40 (char 61)', next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_json_with_duplicate_key(self): - errors = tidy.collect_errors_for_files(iterFile('duplicate_key.json'), [tidy.check_json], [], print_text=False) - self.assertEqual('Duplicated Key (the_duplicated_key)', next(errors)[2]) - self.assertNoMoreErrors(errors) - - def test_json_with_unordered_keys(self): - tidy.config["check-ordered-json-keys"].append('python/tidy/servo_tidy_tests/unordered_key.json') - errors = tidy.collect_errors_for_files(iterFile('unordered_key.json'), [tidy.check_json], [], print_text=False) - self.assertEqual('Unordered key (found b before a)', next(errors)[2]) - self.assertNoMoreErrors(errors) - - 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)', next(errors)[2]) - self.assertNoMoreErrors(errors) - - 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("expected a list for dictionary value @ data['non-list-key']", next(errors)[2]) - self.assertNoMoreErrors(errors) - - 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("expected str @ data['mapping_key'][0]", next(errors)[2]) - self.assertNoMoreErrors(errors) - - 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\x1b[93mThe following packages depend on version 0.4.9 from 'crates.io':\x1b[0m -\t\ttest2 0.1.0 -\t\x1b[93mThe following packages depend on version 0.5.1 from 'crates.io':\x1b[0m -\t\ttest3 0.5.1""" - self.assertEqual(msg, next(errors)[2]) - msg2 = """duplicate versions for package `test3` -\t\x1b[93mThe following packages depend on version 0.5.1 from 'crates.io':\x1b[0m -\t\ttest4 0.1.0 -\t\x1b[93mThe following packages depend on version 0.5.1 from 'https://github.com/user/test3':\x1b[0m -\t\ttest5 0.1.0""" - self.assertEqual(msg2, next(errors)[2]) - self.assertNoMoreErrors(errors) - - 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, next(errors)[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, next(errors)[2]) - - self.assertNoMoreErrors(errors) - - def test_lock_exceptions(self): - tidy.config["blocked-packages"]["rand"] = ["test_exception", "test_unneeded_exception"] - errors = tidy.collect_errors_for_files(iterFile('blocked_package.lock'), [tidy.check_lock], [], print_text=False) - - msg = ( - "Package test_blocked 0.0.2 depends on blocked package rand." - ) - - msg2 = ( - "Package test_unneeded_exception is not required to be an exception of blocked package rand." - ) - - self.assertEqual(msg, next(errors)[2]) - self.assertEqual(msg2, next(errors)[2]) - self.assertNoMoreErrors(errors) - - # needed to not raise errors in other test cases - tidy.config["blocked-packages"]["rand"] = [] - - def test_lint_runner(self): - test_path = base_path + 'lints/' - runner = tidy.LintRunner(only_changed_files=False, progress=False) - runner.path = test_path + 'some-fictional-file' - self.assertEqual([(runner.path, 0, "file does not exist")], list(runner.check())) - runner.path = test_path + 'not_script' - self.assertEqual([(runner.path, 0, "lint should be a python script")], - list(runner.check())) - runner.path = test_path + 'not_inherited.py' - self.assertEqual([(runner.path, 1, "class 'Lint' should inherit from 'LintRunner'")], - list(runner.check())) - runner.path = test_path + 'no_lint.py' - self.assertEqual([(runner.path, 1, "script should contain a class named 'Lint'")], - list(runner.check())) - runner.path = test_path + 'no_run.py' - self.assertEqual([(runner.path, 0, "class 'Lint' should implement 'run' method")], - list(runner.check())) - runner.path = test_path + 'invalid_error_tuple.py' - self.assertEqual([(runner.path, 1, "errors should be a tuple of (path, line, reason)")], - list(runner.check())) - runner.path = test_path + 'proper_file.py' - self.assertEqual([('path', 0, "foobar")], list(runner.check())) - - def test_file_list(self): - base_path='./python/tidy/servo_tidy_tests/test_ignored' - file_list = tidy.FileList(base_path, only_changed_files=False, exclude_dirs=[]) - lst = list(file_list) - self.assertEqual([os.path.join(base_path, 'whee', 'test.rs'), os.path.join(base_path, 'whee', 'foo', 'bar.rs')], lst) - file_list = tidy.FileList(base_path, only_changed_files=False, - exclude_dirs=[os.path.join(base_path, 'whee', 'foo')]) - lst = list(file_list) - self.assertEqual([os.path.join(base_path, 'whee', 'test.rs')], lst) - - def test_multiline_string(self): - errors = tidy.collect_errors_for_files(iterFile('multiline_string.rs'), [], [tidy.check_rust], print_text=True) - self.assertNoMoreErrors(errors) - - -def do_tests(): - suite = unittest.TestLoader().loadTestsFromTestCase(CheckTidiness) - return 0 if unittest.TextTestRunner(verbosity=2).run(suite).wasSuccessful() else 1 diff --git a/python/tidy/servo_tidy_tests/unordered_key.json b/python/tidy/servo_tidy_tests/unordered_key.json deleted file mode 100644 index 36f0a13f9c2..00000000000 --- a/python/tidy/servo_tidy_tests/unordered_key.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "key": "value", - "other_key": { - "b": 1, - "a": 2 - } -} diff --git a/python/tidy/servo_tidy_tests/whatwg_link.rs b/python/tidy/servo_tidy_tests/whatwg_link.rs deleted file mode 100644 index d6ed712450a..00000000000 --- a/python/tidy/servo_tidy_tests/whatwg_link.rs +++ /dev/null @@ -1,6 +0,0 @@ -/* 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/servo_tidy_tests/wrong_space.rs b/python/tidy/servo_tidy_tests/wrong_space.rs deleted file mode 100644 index be735e2d463..00000000000 --- a/python/tidy/servo_tidy_tests/wrong_space.rs +++ /dev/null @@ -1,7 +0,0 @@ -/* 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 |