aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/layout_2020/display_list/stacking_context.rs32
-rw-r--r--components/layout_2020/flow/float.rs117
-rw-r--r--components/layout_2020/flow/mod.rs7
-rw-r--r--components/script/dom/htmlmetaelement.rs2
-rw-r--r--components/script/stylesheet_loader.rs2
-rw-r--r--components/style/stylesheets/stylesheet.rs14
-rw-r--r--python/mach_bootstrap.py1
-rw-r--r--python/requirements.txt4
-rw-r--r--python/servo/lints/wpt_lint.py45
-rw-r--r--python/servo/package_commands.py48
-rw-r--r--python/servo/testing_commands.py6
-rw-r--r--python/tidy/HISTORY.rst31
-rw-r--r--python/tidy/Makefile25
-rw-r--r--python/tidy/README.rst26
-rw-r--r--python/tidy/__init__.py (renamed from python/tidy/servo_tidy_tests/__init__.py)3
-rw-r--r--python/tidy/licenseck.py (renamed from python/tidy/servo_tidy/licenseck.py)0
-rw-r--r--python/tidy/setup.py60
-rw-r--r--python/tidy/test.py (renamed from python/tidy/servo_tidy_tests/test_tidy.py)58
-rw-r--r--python/tidy/tests/Cargo.toml (renamed from python/tidy/servo_tidy_tests/Cargo.toml)0
-rw-r--r--python/tidy/tests/__init__.py (renamed from python/tidy/servo_tidy/__init__.py)0
-rw-r--r--python/tidy/tests/apache2_license.rs (renamed from python/tidy/servo_tidy_tests/apache2_license.rs)0
-rw-r--r--python/tidy/tests/ban-domrefcell.rs (renamed from python/tidy/servo_tidy_tests/ban-domrefcell.rs)0
-rw-r--r--python/tidy/tests/ban.rs (renamed from python/tidy/servo_tidy_tests/ban.rs)0
-rw-r--r--python/tidy/tests/blocked_package.lock (renamed from python/tidy/servo_tidy_tests/blocked_package.lock)0
-rw-r--r--python/tidy/tests/dir_check/only_webidl/test.webidl (renamed from python/tidy/servo_tidy_tests/dir_check/only_webidl/test.webidl)0
-rw-r--r--python/tidy/tests/dir_check/webidl_plus/test.rs (renamed from python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.rs)0
-rw-r--r--python/tidy/tests/dir_check/webidl_plus/test.test (renamed from python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.test)0
-rw-r--r--python/tidy/tests/dir_check/webidl_plus/test.webidl (renamed from python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.webidl)0
-rw-r--r--python/tidy/tests/dir_check/webidl_plus/test2.rs (renamed from python/tidy/servo_tidy_tests/dir_check/webidl_plus/test2.rs)0
-rw-r--r--python/tidy/tests/duplicate_key.json (renamed from python/tidy/servo_tidy_tests/duplicate_key.json)0
-rw-r--r--python/tidy/tests/duplicate_keys_buildbot_steps.yml (renamed from python/tidy/servo_tidy_tests/duplicate_keys_buildbot_steps.yml)0
-rw-r--r--python/tidy/tests/duplicated_package.lock (renamed from python/tidy/servo_tidy_tests/duplicated_package.lock)0
-rw-r--r--python/tidy/tests/empty_file.rs (renamed from python/tidy/servo_tidy_tests/empty_file.rs)0
-rw-r--r--python/tidy/tests/incorrect_license.rs (renamed from python/tidy/servo_tidy_tests/incorrect_license.rs)0
-rw-r--r--python/tidy/tests/lib.rs (renamed from python/tidy/servo_tidy_tests/lib.rs)0
-rw-r--r--python/tidy/tests/lints/invalid_error_tuple.py (renamed from python/tidy/servo_tidy_tests/lints/invalid_error_tuple.py)0
-rw-r--r--python/tidy/tests/lints/no_lint.py (renamed from python/tidy/servo_tidy_tests/lints/no_lint.py)0
-rw-r--r--python/tidy/tests/lints/no_run.py (renamed from python/tidy/servo_tidy_tests/lints/no_run.py)0
-rw-r--r--python/tidy/tests/lints/not_inherited.py (renamed from python/tidy/servo_tidy_tests/lints/not_inherited.py)0
-rw-r--r--python/tidy/tests/lints/not_script (renamed from python/tidy/servo_tidy_tests/lints/not_script)0
-rw-r--r--python/tidy/tests/lints/proper_file.py (renamed from python/tidy/servo_tidy_tests/lints/proper_file.py)0
-rw-r--r--python/tidy/tests/long_line.rs (renamed from python/tidy/servo_tidy_tests/long_line.rs)0
-rw-r--r--python/tidy/tests/malformed_json.json (renamed from python/tidy/servo_tidy_tests/malformed_json.json)0
-rw-r--r--python/tidy/tests/manifest-include.ini (renamed from python/tidy/servo_tidy_tests/manifest-include.ini)0
-rw-r--r--python/tidy/tests/modeline.txt (renamed from python/tidy/servo_tidy_tests/modeline.txt)0
-rw-r--r--python/tidy/tests/multiline_string.rs (renamed from python/tidy/servo_tidy_tests/multiline_string.rs)0
-rw-r--r--python/tidy/tests/non_list_mapping_buildbot_steps.yml (renamed from python/tidy/servo_tidy_tests/non_list_mapping_buildbot_steps.yml)0
-rw-r--r--python/tidy/tests/non_string_list_buildbot_steps.yml (renamed from python/tidy/servo_tidy_tests/non_string_list_buildbot_steps.yml)0
-rw-r--r--python/tidy/tests/rust_tidy.rs (renamed from python/tidy/servo_tidy_tests/rust_tidy.rs)0
-rw-r--r--python/tidy/tests/servo-tidy.toml (renamed from python/tidy/servo_tidy_tests/servo-tidy.toml)0
-rw-r--r--python/tidy/tests/shebang_license.py (renamed from python/tidy/servo_tidy_tests/shebang_license.py)0
-rw-r--r--python/tidy/tests/shell_tidy.sh (renamed from python/tidy/servo_tidy_tests/shell_tidy.sh)0
-rw-r--r--python/tidy/tests/spec.webidl (renamed from python/tidy/servo_tidy_tests/spec.webidl)0
-rw-r--r--python/tidy/tests/speclink.rs (renamed from python/tidy/servo_tidy_tests/speclink.rs)0
-rw-r--r--python/tidy/tests/test_ignored/whee/foo/bar.rs (renamed from python/tidy/servo_tidy_tests/test_ignored/whee/foo/bar.rs)0
-rw-r--r--python/tidy/tests/test_ignored/whee/test.rs (renamed from python/tidy/servo_tidy_tests/test_ignored/whee/test.rs)0
-rw-r--r--python/tidy/tests/unordered_key.json (renamed from python/tidy/servo_tidy_tests/unordered_key.json)0
-rw-r--r--python/tidy/tests/whatwg_link.rs (renamed from python/tidy/servo_tidy_tests/whatwg_link.rs)0
-rw-r--r--python/tidy/tests/wrong_space.rs (renamed from python/tidy/servo_tidy_tests/wrong_space.rs)0
-rw-r--r--python/tidy/tidy.py (renamed from python/tidy/servo_tidy/tidy.py)70
-rw-r--r--servo-tidy.toml5
-rw-r--r--tests/wpt/metadata-layout-2020/css/CSS2/css1/c414-flt-wrap-001.xht.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/CSS2/floats-clear/clear-clearance-calculation-003.xht.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-001.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-002.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-003.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-008.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-001.html.ini3
-rw-r--r--tests/wpt/metadata-layout-2020/css/CSS2/zindex/stack-floats-001.xht.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/CSS2/zindex/stack-floats-002.xht.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/CSS2/zindex/stack-floats-004.xht.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-center.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-end.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-space-around.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-space-between.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-start.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/css-flexbox/flexbox_flex-formatting-interop.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/css-position/position-absolute-dynamic-static-position-floats-004.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/css-position/static-position/inline-level-absolute-in-block-level-context-004.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/css-position/static-position/inline-level-absolute-in-block-level-context-009.html.ini2
-rw-r--r--tests/wpt/metadata-layout-2020/css/css-position/static-position/inline-level-absolute-in-block-level-context-010.html.ini2
81 files changed, 209 insertions, 388 deletions
diff --git a/components/layout_2020/display_list/stacking_context.rs b/components/layout_2020/display_list/stacking_context.rs
index 63fefd0c4f4..a231ab088a7 100644
--- a/components/layout_2020/display_list/stacking_context.rs
+++ b/components/layout_2020/display_list/stacking_context.rs
@@ -200,6 +200,11 @@ pub(crate) enum StackingContextType {
PseudoAtomicInline,
}
+/// A [StackingContext] represents either a stacking context or a stacking
+/// container according to the definitions outlined in
+/// <https://drafts.csswg.org/css-position-4/#painting-order>
+/// Stacking containers are sometimes called "pseudo-stacking contexts"
+/// in the Servo source.
pub struct StackingContext {
/// The spatial id of this fragment. This is used to properly handle
/// things like preserve-3d.
@@ -218,7 +223,19 @@ pub struct StackingContext {
/// of this stacking context.
stacking_contexts: Vec<StackingContext>,
- /// All float pseudo stacking context children of this stacking context.
+ /// All float stacking container children of this stacking context.
+ /// These are stored separately because they should not be passed up to
+ /// their real stacking context ancestors. From the definition of stacking
+ /// containers from <https://drafts.csswg.org/css-position-4#painting-order>:
+ ///
+ /// > To paint a stacking container, given a box root and a canvas canvas:
+ /// > 1. Paint a stacking context given root and canvas, treating root as
+ /// > if it created a new stacking context, but omitting any positioned
+ /// > descendants or descendants that actually create a stacking context
+ /// > (letting the parent stacking context paint them, instead).
+ ///
+ /// Note that all stacking containers / pseudo stacking contexts are passed up
+ /// to parent stacking contexts, except in the case of floats.
float_stacking_contexts: Vec<StackingContext>,
}
@@ -249,6 +266,15 @@ impl StackingContext {
}
}
+ /// Add a child stacking context to this stacking context.
+ fn add_stacking_context(&mut self, stacking_context: StackingContext) {
+ if stacking_context.context_type == StackingContextType::PseudoFloat {
+ self.float_stacking_contexts.push(stacking_context);
+ } else {
+ self.stacking_contexts.push(stacking_context);
+ }
+ }
+
fn z_index(&self) -> i32 {
self.initializing_fragment_style
.as_ref()
@@ -754,9 +780,7 @@ impl BoxFragment {
}
child_stacking_context.sort();
- parent_stacking_context
- .stacking_contexts
- .push(child_stacking_context);
+ parent_stacking_context.add_stacking_context(child_stacking_context);
parent_stacking_context
.stacking_contexts
.append(&mut stolen_children);
diff --git a/components/layout_2020/flow/float.rs b/components/layout_2020/flow/float.rs
index 0ac6529278a..9a52b50853d 100644
--- a/components/layout_2020/flow/float.rs
+++ b/components/layout_2020/flow/float.rs
@@ -320,7 +320,7 @@ impl ClearSide {
}
impl FloatBand {
- // Determines whether an object fits in a band.
+ /// Determines whether an object fits in a band. Returns true if the object fits.
fn object_fits(&self, object: &PlacementInfo, walls: &ContainingBlockPositionInfo) -> bool {
match object.side {
FloatSide::Left => {
@@ -549,8 +549,8 @@ impl FloatBandLink {
Some(this.band.clone())
}
- // Inserts a new band into the tree. If the band has the same level as a pre-existing one,
- // replaces the existing band with the new one.
+ /// Inserts a new band into the tree. If the band has the same level as a pre-existing one,
+ /// replaces the existing band with the new one.
fn insert(&self, band: FloatBand) -> FloatBandLink {
let mut this = match self.0 {
None => return FloatBandLink(Some(Arc::new(FloatBandNode::new(band)))),
@@ -570,13 +570,13 @@ impl FloatBandLink {
FloatBandLink(Some(Arc::new(this)))
}
- // Corrects tree balance:
- //
- // T L
- // / \ / \
- // L R → A T if level(T) = level(L)
- // / \ / \
- // A B B R
+ /// Corrects tree balance:
+ ///
+ /// T L
+ /// / \ / \
+ /// L R → A T if level(T) = level(L)
+ /// / \ / \
+ /// A B B R
fn skew(&self) -> FloatBandLink {
if let Some(ref this) = self.0 {
if let Some(ref left) = this.left.0 {
@@ -599,13 +599,13 @@ impl FloatBandLink {
(*self).clone()
}
- // Corrects tree balance:
- //
- // T R
- // / \ / \
- // A R → T X if level(T) = level(X)
- // / \ / \
- // B X A B
+ /// Corrects tree balance:
+ ///
+ /// T R
+ /// / \ / \
+ /// A R → T X if level(T) = level(X)
+ /// / \ / \
+ /// B X A B
fn split(&self) -> FloatBandLink {
if let Some(ref this) = self.0 {
if let Some(ref right) = this.right.0 {
@@ -637,8 +637,6 @@ impl Debug for FloatFragment {
}
}
-// Float boxes
-
impl FloatBox {
/// Creates a new float box.
pub fn construct<'dom>(
@@ -659,6 +657,9 @@ impl FloatBox {
}
}
+ /// Lay out this float box and its children. Note that the position will be relative to
+ /// the float containing block formatting context. A later step adjusts the position
+ /// to be relative to the containing block.
pub fn layout(
&mut self,
layout_context: &LayoutContext,
@@ -799,35 +800,33 @@ impl FloatBox {
}
}
-// Float fragment storage
-
-// Layout state that we maintain when doing sequential traversals of the box tree in document
-// order.
-//
-// This data is only needed for float placement and float interaction, and as such is only present
-// if the current block formatting context contains floats.
-//
-// All coordinates here are relative to the start of the nearest ancestor block formatting context.
-//
-// This structure is expected to be cheap to clone, in order to allow for "snapshots" that enable
-// restarting layout at any point in the tree.
+/// Layout state that we maintain when doing sequential traversals of the box tree in document
+/// order.
+///
+/// This data is only needed for float placement and float interaction, and as such is only present
+/// if the current block formatting context contains floats.
+///
+/// All coordinates here are relative to the start of the nearest ancestor block formatting context.
+///
+/// This structure is expected to be cheap to clone, in order to allow for "snapshots" that enable
+/// restarting layout at any point in the tree.
#[derive(Clone)]
pub(crate) struct SequentialLayoutState {
- // Holds all floats in this block formatting context.
+ /// Holds all floats in this block formatting context.
pub(crate) floats: FloatContext,
- // The (logically) bottom border edge or top padding edge of the last in-flow block. Floats
- // cannot be placed above this line.
- //
- // This is often, but not always, the same as the float ceiling. The float ceiling can be lower
- // than this value because this value is calculated based on in-flow boxes only, while
- // out-of-flow floats can affect the ceiling as well (see CSS 2.1 § 9.5.1 rule 6).
+ /// The (logically) bottom border edge or top padding edge of the last in-flow block. Floats
+ /// cannot be placed above this line.
+ ///
+ /// This is often, but not always, the same as the float ceiling. The float ceiling can be lower
+ /// than this value because this value is calculated based on in-flow boxes only, while
+ /// out-of-flow floats can affect the ceiling as well (see CSS 2.1 § 9.5.1 rule 6).
pub(crate) bfc_relative_block_position: Length,
- // Any collapsible margins that we've encountered after `bfc_relative_block_position`.
+ /// Any collapsible margins that we've encountered after `bfc_relative_block_position`.
pub(crate) current_margin: CollapsedMargin,
}
impl SequentialLayoutState {
- // Creates a new empty `SequentialLayoutState`.
+ /// Creates a new empty `SequentialLayoutState`.
pub(crate) fn new() -> SequentialLayoutState {
SequentialLayoutState {
floats: FloatContext::new(),
@@ -836,41 +835,45 @@ impl SequentialLayoutState {
}
}
- // Moves the current block position (logically) down by `block_distance`.
- //
- // Floats may not be placed higher than the current block position.
+ /// Moves the current block position (logically) down by `block_distance`.
+ ///
+ /// Floats may not be placed higher than the current block position.
pub(crate) fn advance_block_position(&mut self, block_distance: Length) {
self.bfc_relative_block_position += block_distance;
self.floats.lower_ceiling(self.bfc_relative_block_position);
}
- pub(crate) fn update_all_containing_block_offsets(
+ /// Replace the entire [ContainingBlockPositionInfo] data structure stored
+ /// by this [SequentialLayoutState]. Return the old data structure.
+ pub(crate) fn replace_containing_block_position_info(
&mut self,
- mut new_distance: ContainingBlockPositionInfo,
+ mut position_info: ContainingBlockPositionInfo,
) -> ContainingBlockPositionInfo {
- mem::swap(&mut new_distance, &mut self.floats.containing_block_info);
- new_distance
+ mem::swap(&mut position_info, &mut self.floats.containing_block_info);
+ position_info
}
+ /// Return the current block position in the float containing block formatting
+ /// context and any uncollapsed block margins.
pub(crate) fn current_block_position_including_margins(&self) -> Length {
self.bfc_relative_block_position + self.current_margin.solve()
}
- // Collapses margins, moving the block position down by the collapsed value of `current_margin`
- // and resetting `current_margin` to zero.
- //
- // Call this method before laying out children when it is known that the start margin of the
- // current fragment can't collapse with the margins of any of its children.
+ /// Collapses margins, moving the block position down by the collapsed value of `current_margin`
+ /// and resetting `current_margin` to zero.
+ ///
+ /// Call this method before laying out children when it is known that the start margin of the
+ /// current fragment can't collapse with the margins of any of its children.
pub(crate) fn collapse_margins(&mut self) {
self.advance_block_position(self.current_margin.solve());
self.current_margin = CollapsedMargin::zero();
}
- // Returns the amount of clearance that a block with the given `clear` value at the current
- // `bfc_relative_block_position` (with top margin included in `current_margin` if applicable)
- // needs to have.
- //
- // https://www.w3.org/TR/2011/REC-CSS2-20110607/visuren.html#flow-control
+ /// Returns the amount of clearance that a block with the given `clear` value at the current
+ /// `bfc_relative_block_position` (with top margin included in `current_margin` if applicable)
+ /// needs to have.
+ ///
+ /// https://www.w3.org/TR/2011/REC-CSS2-20110607/visuren.html#flow-control
pub(crate) fn calculate_clearance(&self, clear_side: ClearSide) -> Length {
if clear_side == ClearSide::None {
return Length::zero();
diff --git a/components/layout_2020/flow/mod.rs b/components/layout_2020/flow/mod.rs
index a7e3bc46708..5837e836d88 100644
--- a/components/layout_2020/flow/mod.rs
+++ b/components/layout_2020/flow/mod.rs
@@ -522,8 +522,9 @@ fn layout_in_flow_non_replaced_block_level(
inline_start,
inline_end: inline_start + inline_size,
};
- parent_containing_block_position_info =
- Some(sequential_layout_state.update_all_containing_block_offsets(new_cb_offsets));
+ parent_containing_block_position_info = Some(
+ sequential_layout_state.replace_containing_block_position_info(new_cb_offsets),
+ );
},
};
@@ -594,7 +595,7 @@ fn layout_in_flow_non_replaced_block_level(
// Now that we're done laying out our children, we can restore the
// parent's containing block position information.
sequential_layout_state
- .update_all_containing_block_offsets(parent_containing_block_position_info.unwrap());
+ .replace_containing_block_position_info(parent_containing_block_position_info.unwrap());
// Account for padding and border. We also might have to readjust the
// `bfc_relative_block_position` if it was different from the content size (i.e. was
diff --git a/components/script/dom/htmlmetaelement.rs b/components/script/dom/htmlmetaelement.rs
index a6be8e1747b..74a6400fdca 100644
--- a/components/script/dom/htmlmetaelement.rs
+++ b/components/script/dom/htmlmetaelement.rs
@@ -114,7 +114,7 @@ impl HTMLMetaElement {
let shared_lock = document.style_shared_lock();
let rule = CssRule::Viewport(Arc::new(shared_lock.wrap(translated_rule)));
let sheet = Arc::new(Stylesheet {
- contents: StylesheetContents::from_shared_data(
+ contents: StylesheetContents::from_data(
CssRules::new(vec![rule], shared_lock),
Origin::Author,
window_from_node(self).get_url(),
diff --git a/components/script/stylesheet_loader.rs b/components/script/stylesheet_loader.rs
index 9657227f91a..b7f47b1fcfd 100644
--- a/components/script/stylesheet_loader.rs
+++ b/components/script/stylesheet_loader.rs
@@ -361,7 +361,7 @@ impl<'a> StyleStylesheetLoader for StylesheetLoader<'a> {
layer: Option<ImportLayer>,
) -> Arc<Locked<ImportRule>> {
let sheet = Arc::new(Stylesheet {
- contents: StylesheetContents::from_shared_data(
+ contents: StylesheetContents::from_data(
CssRules::new(Vec::new(), lock),
context.stylesheet_origin,
context.url_data.clone(),
diff --git a/components/style/stylesheets/stylesheet.rs b/components/style/stylesheets/stylesheet.rs
index 9d3aaedeff5..aaf350b684d 100644
--- a/components/style/stylesheets/stylesheet.rs
+++ b/components/style/stylesheets/stylesheet.rs
@@ -125,13 +125,12 @@ impl StylesheetContents {
/// An empty namespace map should be fine, as it is only used for parsing,
/// not serialization of existing selectors. Since UA sheets are read only,
/// we should never need the namespace map.
- pub fn from_shared_data(
+ pub fn from_data(
rules: Arc<Locked<CssRules>>,
origin: Origin,
url_data: UrlExtraData,
quirks_mode: QuirksMode,
) -> Arc<Self> {
- debug_assert!(rules.is_static());
Arc::new(Self {
rules,
origin,
@@ -144,6 +143,17 @@ impl StylesheetContents {
})
}
+ /// Same as above, but ensuring that the rules are static.
+ pub fn from_shared_data(
+ rules: Arc<Locked<CssRules>>,
+ origin: Origin,
+ url_data: UrlExtraData,
+ quirks_mode: QuirksMode,
+ ) -> Arc<Self> {
+ debug_assert!(rules.is_static());
+ Self::from_data(rules, origin, url_data, quirks_mode)
+ }
+
/// Returns a reference to the list of rules.
#[inline]
pub fn rules<'a, 'b: 'a>(&'a self, guard: &'b SharedRwLockReadGuard) -> &'a [CssRule] {
diff --git a/python/mach_bootstrap.py b/python/mach_bootstrap.py
index 06d5377aa84..dec54260839 100644
--- a/python/mach_bootstrap.py
+++ b/python/mach_bootstrap.py
@@ -14,7 +14,6 @@ from subprocess import Popen
from tempfile import TemporaryFile
SEARCH_PATHS = [
- os.path.join("python", "tidy"),
os.path.join("python", "mach"),
]
diff --git a/python/requirements.txt b/python/requirements.txt
index bbf19513285..f172613fc1e 100644
--- a/python/requirements.txt
+++ b/python/requirements.txt
@@ -39,4 +39,6 @@ notify-py == 0.3.42
# For formatting C++ files.
clang-format ~= 16.0.0
--e python/tidy
+# A few more requirements for tidy.
+voluptuous == 0.12.1
+PyYAML == 5.4
diff --git a/python/servo/lints/wpt_lint.py b/python/servo/lints/wpt_lint.py
deleted file mode 100644
index ada03b65a99..00000000000
--- a/python/servo/lints/wpt_lint.py
+++ /dev/null
@@ -1,45 +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.
-
-from __future__ import print_function
-
-import os
-import sys
-
-from servo_tidy.tidy import LintRunner, filter_file
-
-WPT_PATH = os.path.join(".", "tests", "wpt")
-SUITES = ["web-platform-tests", os.path.join("mozilla", "tests")]
-
-
-class Lint(LintRunner):
- def _get_wpt_files(self, suite):
- working_dir = os.path.join(WPT_PATH, suite, '')
- file_iter = self.get_files(working_dir, exclude_dirs=[])
- print('\nRunning the WPT lint on %s...' % working_dir)
- for f in file_iter:
- if filter_file(f):
- yield f[len(working_dir):]
-
- def run(self):
- if self.stylo or self.no_wpt:
- return
-
- wpt_working_dir = os.path.abspath(os.path.join(WPT_PATH, "web-platform-tests"))
- for suite in SUITES:
- files = list(self._get_wpt_files(suite))
- if not files:
- continue
- sys.path.insert(0, wpt_working_dir)
- from tools.lint import lint
- file_dir = os.path.abspath(os.path.join(WPT_PATH, suite))
- returncode = lint.lint(file_dir, files, output_format="json")
- sys.path.remove(wpt_working_dir)
- if returncode:
- yield ("WPT Lint Tool", "", "lint error(s) in Web Platform Tests: exit status %s" % returncode)
diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py
index 13ef267f6c2..b8e22d42b72 100644
--- a/python/servo/package_commands.py
+++ b/python/servo/package_commands.py
@@ -41,7 +41,7 @@ from servo.command_base import (
)
from servo.build_commands import copy_dependencies, change_rpath_in_binary
from servo.gstreamer import macos_gst_root
-from servo.util import delete
+from servo.util import delete, get_target_dir
# Note: mako cannot be imported at the top level because it breaks mach bootstrap
sys.path.append(path.join(path.dirname(__file__), "..", "..",
@@ -49,42 +49,50 @@ sys.path.append(path.join(path.dirname(__file__), "..", "..",
PACKAGES = {
'android': [
- 'target/android/armv7-linux-androideabi/release/servoapp.apk',
- 'target/android/armv7-linux-androideabi/release/servoview.aar',
+ 'android/armv7-linux-androideabi/release/servoapp.apk',
+ 'android/armv7-linux-androideabi/release/servoview.aar',
],
'linux': [
- 'target/release/servo-tech-demo.tar.gz',
+ 'release/servo-tech-demo.tar.gz',
],
'linux-layout2020': [
- 'target/release/servo-tech-demo.tar.gz',
+ 'release/servo-tech-demo.tar.gz',
],
'mac': [
- 'target/release/servo-tech-demo.dmg',
+ 'release/servo-tech-demo.dmg',
],
'mac-layout2020': [
- 'target/release/servo-tech-demo.dmg',
+ 'release/servo-tech-demo.dmg',
],
'macbrew': [
- 'target/release/brew/servo.tar.gz',
+ 'release/brew/servo.tar.gz',
],
'maven': [
- 'target/android/gradle/servoview/maven/org/mozilla/servoview/servoview-armv7/',
- 'target/android/gradle/servoview/maven/org/mozilla/servoview/servoview-x86/',
+ 'android/gradle/servoview/maven/org/mozilla/servoview/servoview-armv7/',
+ 'android/gradle/servoview/maven/org/mozilla/servoview/servoview-x86/',
],
'windows-msvc': [
- r'target\release\msi\Servo.exe',
- r'target\release\msi\Servo.zip',
+ r'release\msi\Servo.exe',
+ r'release\msi\Servo.zip',
],
'windows-msvc-layout2020': [
- r'target\release\msi\Servo.exe',
- r'target\release\msi\Servo.zip',
- ],
- 'uwp': [
- r'support\hololens\AppPackages\ServoApp\FirefoxReality.zip',
+ r'release\msi\Servo.exe',
+ r'release\msi\Servo.zip',
],
}
+def packages_for_platform(platform):
+ target_dir = get_target_dir()
+
+ if platform == "uwp":
+ yield r'support\hololens\AppPackages\ServoApp\FirefoxReality.zip'
+ return
+
+ for package in PACKAGES[platform]:
+ yield path.join(target_dir, package)
+
+
def listfiles(directory):
return [f for f in os.listdir(directory)
if path.isfile(path.join(directory, f))]
@@ -652,7 +660,7 @@ class PackageCommands(CommandBase):
], stdout=DEVNULL, stderr=DEVNULL)
timestamp = datetime.utcnow().replace(microsecond=0)
- for package in PACKAGES[platform]:
+ for package in packages_for_platform(platform):
if path.isdir(package):
continue
if not path.isfile(package):
@@ -677,11 +685,11 @@ class PackageCommands(CommandBase):
upload_to_github_release(platform, package, package_hash)
if platform == 'maven':
- for package in PACKAGES[platform]:
+ for package in packages_for_platform(platform):
update_maven(package)
if platform == 'macbrew':
- packages = PACKAGES[platform]
+ packages = list(packages_for_platform(platform))
assert(len(packages) == 1)
update_brew(packages[0], timestamp)
diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py
index 6ed56465ecc..291a00b15c0 100644
--- a/python/servo/testing_commands.py
+++ b/python/servo/testing_commands.py
@@ -31,14 +31,12 @@ from mach.decorators import (
CommandProvider,
Command,
)
+import tidy
-from servo_tidy import tidy
from servo.command_base import (
CommandBase,
call, check_call, check_output,
)
-from servo_tidy_tests import test_tidy
-
from servo.util import delete
from distutils.dir_util import copy_tree
@@ -298,7 +296,7 @@ class MachCommands(CommandBase):
help="Only handle files in the stylo tree")
def test_tidy(self, all_files, no_progress, self_test, stylo, force_cpp=False, no_wpt=False):
if self_test:
- return test_tidy.do_tests()
+ return tidy.do_tests()
else:
if no_wpt:
manifest_dirty = False
diff --git a/python/tidy/HISTORY.rst b/python/tidy/HISTORY.rst
deleted file mode 100644
index e2330d8ad33..00000000000
--- a/python/tidy/HISTORY.rst
+++ /dev/null
@@ -1,31 +0,0 @@
-Release History
----------------
-
-0.3.0 (2017-02-24)
-++++++++++++++++++
-
-- Added checking for blocked packages
-- Added checking for alphabetical order for JSON keys and ``#![feature(...)]``
-- Improved duplicated packages checking
-- Improved ordering ``use`` statements
-- Allow tidy to run custom project-specific lints
-- And many other improvements
-
-0.2.0 (2016-08-09)
-++++++++++++++++++
-
-- Improve license checking to disregard comments and line breaks
-- License checking verifies that COPYRIGHT is specified when apache2 is used
-
-0.0.3 (2016-04-19)
-++++++++++++++++++
-
-- Add alternate wording of apache2 license
-
-0.0.2 (2016-04-17)
-++++++++++++++++++
-- Cleanup Tidy to work on external deps
-
-0.0.1 (2016-04-12)
-++++++++++++++++++
-- Package Tidy
diff --git a/python/tidy/Makefile b/python/tidy/Makefile
deleted file mode 100644
index 9637aa10d98..00000000000
--- a/python/tidy/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-PYTHON := python
-VENV := env-$(PYTHON)
-
-# for travis
-
-$(VENV)/bin/python:
- [ -d $(VENV) ] || $(PYTHON) -m virtualenv $(VENV) || virtualenv $(VENV)
- $(VENV)/bin/pip install --upgrade setuptools
- $(VENV)/bin/python setup.py develop
-
-
-.PHONY: dev-env
-dev-env: $(VENV)/bin/python
-
-
-# for testing
-.PHONY: test
-test: dev-env
- $(VENV)/bin/python -m unittest discover -s servo_tidy_tests -v
-
-
-.PHONY: clean
-clean:
- find . -name "*.pyc" -type f -delete
- rm -rf $(VENV)
diff --git a/python/tidy/README.rst b/python/tidy/README.rst
deleted file mode 100644
index 06c0bc71309..00000000000
--- a/python/tidy/README.rst
+++ /dev/null
@@ -1,26 +0,0 @@
-servo_tidy
-==========
-
-Servo's code and license checker.
-
-Installation
-++++++++++++
-
-Install from PyPI:
-
-::
-
- pip install servo-tidy
-
-or from git:
-
-::
-
- pip install -e git+https://github.com/servo/servo.git#egg=servo_tidy&subdirectory=python/tidy
-
-To run the tests
-++++++++++++++++
-
-::
-
- ./mach test-tidy --self-test
diff --git a/python/tidy/servo_tidy_tests/__init__.py b/python/tidy/__init__.py
index 6b6351ddd2b..74a15acad8f 100644
--- a/python/tidy/servo_tidy_tests/__init__.py
+++ b/python/tidy/__init__.py
@@ -6,3 +6,6 @@
# <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.
+
+from .tidy import scan # noqa
+from .test import do_tests # noqa
diff --git a/python/tidy/servo_tidy/licenseck.py b/python/tidy/licenseck.py
index deeaeb55333..deeaeb55333 100644
--- a/python/tidy/servo_tidy/licenseck.py
+++ b/python/tidy/licenseck.py
diff --git a/python/tidy/setup.py b/python/tidy/setup.py
deleted file mode 100644
index 17c6172acbc..00000000000
--- a/python/tidy/setup.py
+++ /dev/null
@@ -1,60 +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
-from setuptools import setup, find_packages
-
-
-VERSION = '0.3.0'
-
-install_requires = [
- "flake8==3.8.3",
- "toml==0.9.2",
- "colorama==0.3.7",
- "voluptuous==0.12.1",
- "PyYAML==5.4",
-]
-
-here = os.path.dirname(os.path.abspath(__file__))
-# get documentation from the README and HISTORY
-try:
- with open(os.path.join(here, 'README.rst')) as doc:
- readme = doc.read()
-except Exception:
- readme = ''
-
-try:
- with open(os.path.join(here, 'HISTORY.rst')) as doc:
- history = doc.read()
-except Exception:
- history = ''
-
-long_description = readme + '\n\n' + history
-
-if __name__ == '__main__':
- setup(
- name='servo_tidy',
- version=VERSION,
- description='The servo-tidy is used to check licenses, '
- 'line lengths, whitespace, flake8 on Python files, lock file versions, and more.',
- long_description=long_description,
- keywords='mozilla servo tidy ',
- author='The Servo Project Developers',
- author_email='dev-servo@lists.mozilla.org',
- url='https://github.com/servo/servo',
- packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
- package_data={},
- install_requires=install_requires,
- zip_safe=False,
- entry_points={
- 'console_scripts': [
- 'servo-tidy=servo_tidy.tidy:scan',
- ],
- },
- )
diff --git a/python/tidy/servo_tidy_tests/test_tidy.py b/python/tidy/test.py
index 6138320cc35..49c83579c93 100644
--- a/python/tidy/servo_tidy_tests/test_tidy.py
+++ b/python/tidy/test.py
@@ -10,13 +10,14 @@
import os
import unittest
-from servo_tidy import tidy
+from . import tidy
-base_path = 'servo_tidy_tests/' if os.path.exists('servo_tidy_tests/') else 'python/tidy/servo_tidy_tests/'
+
+BASE_PATH = 'python/tidy/tests/'
def iterFile(name):
- return iter([os.path.join(base_path, name)])
+ return iter([os.path.join(BASE_PATH, name)])
class CheckTidiness(unittest.TestCase):
@@ -25,7 +26,7 @@ class CheckTidiness(unittest.TestCase):
next(errors)
def test_tidy_config(self):
- errors = tidy.check_config_file(os.path.join(base_path, 'servo-tidy.toml'), print_text=False)
+ 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])
@@ -38,17 +39,17 @@ class CheckTidiness(unittest.TestCase):
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)
+ 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']
- }
+ 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")
+ 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)
@@ -136,7 +137,7 @@ class CheckTidiness(unittest.TestCase):
self.assertNoMoreErrors(ban_errors)
def test_spec_link(self):
- tidy.SPEC_BASE_PATH = base_path
+ 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])
@@ -173,7 +174,7 @@ class CheckTidiness(unittest.TestCase):
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')
+ tidy.config["check-ordered-json-keys"].append('python/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)
@@ -246,38 +247,15 @@ class CheckTidiness(unittest.TestCase):
# 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=[])
+ file_path = os.path.join(BASE_PATH, 'test_ignored')
+ file_list = tidy.FileList(file_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')])
+ self.assertEqual([os.path.join(file_path, 'whee', 'test.rs'), os.path.join(file_path, 'whee', 'foo', 'bar.rs')], lst)
+ file_list = tidy.FileList(file_path, only_changed_files=False,
+ exclude_dirs=[os.path.join(file_path, 'whee', 'foo')])
lst = list(file_list)
- self.assertEqual([os.path.join(base_path, 'whee', 'test.rs')], lst)
+ self.assertEqual([os.path.join(file_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)
diff --git a/python/tidy/servo_tidy_tests/Cargo.toml b/python/tidy/tests/Cargo.toml
index c664352e45f..c664352e45f 100644
--- a/python/tidy/servo_tidy_tests/Cargo.toml
+++ b/python/tidy/tests/Cargo.toml
diff --git a/python/tidy/servo_tidy/__init__.py b/python/tidy/tests/__init__.py
index 6b6351ddd2b..6b6351ddd2b 100644
--- a/python/tidy/servo_tidy/__init__.py
+++ b/python/tidy/tests/__init__.py
diff --git a/python/tidy/servo_tidy_tests/apache2_license.rs b/python/tidy/tests/apache2_license.rs
index c9fed89cf73..c9fed89cf73 100644
--- a/python/tidy/servo_tidy_tests/apache2_license.rs
+++ b/python/tidy/tests/apache2_license.rs
diff --git a/python/tidy/servo_tidy_tests/ban-domrefcell.rs b/python/tidy/tests/ban-domrefcell.rs
index 9bfc9ba8938..9bfc9ba8938 100644
--- a/python/tidy/servo_tidy_tests/ban-domrefcell.rs
+++ b/python/tidy/tests/ban-domrefcell.rs
diff --git a/python/tidy/servo_tidy_tests/ban.rs b/python/tidy/tests/ban.rs
index 9da46d2ee53..9da46d2ee53 100644
--- a/python/tidy/servo_tidy_tests/ban.rs
+++ b/python/tidy/tests/ban.rs
diff --git a/python/tidy/servo_tidy_tests/blocked_package.lock b/python/tidy/tests/blocked_package.lock
index 521fdfcfb74..521fdfcfb74 100644
--- a/python/tidy/servo_tidy_tests/blocked_package.lock
+++ b/python/tidy/tests/blocked_package.lock
diff --git a/python/tidy/servo_tidy_tests/dir_check/only_webidl/test.webidl b/python/tidy/tests/dir_check/only_webidl/test.webidl
index e69de29bb2d..e69de29bb2d 100644
--- a/python/tidy/servo_tidy_tests/dir_check/only_webidl/test.webidl
+++ b/python/tidy/tests/dir_check/only_webidl/test.webidl
diff --git a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.rs b/python/tidy/tests/dir_check/webidl_plus/test.rs
index e69de29bb2d..e69de29bb2d 100644
--- a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.rs
+++ b/python/tidy/tests/dir_check/webidl_plus/test.rs
diff --git a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.test b/python/tidy/tests/dir_check/webidl_plus/test.test
index e69de29bb2d..e69de29bb2d 100644
--- a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.test
+++ b/python/tidy/tests/dir_check/webidl_plus/test.test
diff --git a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.webidl b/python/tidy/tests/dir_check/webidl_plus/test.webidl
index e69de29bb2d..e69de29bb2d 100644
--- a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test.webidl
+++ b/python/tidy/tests/dir_check/webidl_plus/test.webidl
diff --git a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test2.rs b/python/tidy/tests/dir_check/webidl_plus/test2.rs
index e69de29bb2d..e69de29bb2d 100644
--- a/python/tidy/servo_tidy_tests/dir_check/webidl_plus/test2.rs
+++ b/python/tidy/tests/dir_check/webidl_plus/test2.rs
diff --git a/python/tidy/servo_tidy_tests/duplicate_key.json b/python/tidy/tests/duplicate_key.json
index 6998c789ac9..6998c789ac9 100644
--- a/python/tidy/servo_tidy_tests/duplicate_key.json
+++ b/python/tidy/tests/duplicate_key.json
diff --git a/python/tidy/servo_tidy_tests/duplicate_keys_buildbot_steps.yml b/python/tidy/tests/duplicate_keys_buildbot_steps.yml
index ed5d046095f..ed5d046095f 100644
--- a/python/tidy/servo_tidy_tests/duplicate_keys_buildbot_steps.yml
+++ b/python/tidy/tests/duplicate_keys_buildbot_steps.yml
diff --git a/python/tidy/servo_tidy_tests/duplicated_package.lock b/python/tidy/tests/duplicated_package.lock
index 22acce4257c..22acce4257c 100644
--- a/python/tidy/servo_tidy_tests/duplicated_package.lock
+++ b/python/tidy/tests/duplicated_package.lock
diff --git a/python/tidy/servo_tidy_tests/empty_file.rs b/python/tidy/tests/empty_file.rs
index e69de29bb2d..e69de29bb2d 100644
--- a/python/tidy/servo_tidy_tests/empty_file.rs
+++ b/python/tidy/tests/empty_file.rs
diff --git a/python/tidy/servo_tidy_tests/incorrect_license.rs b/python/tidy/tests/incorrect_license.rs
index cf85f0e2623..cf85f0e2623 100644
--- a/python/tidy/servo_tidy_tests/incorrect_license.rs
+++ b/python/tidy/tests/incorrect_license.rs
diff --git a/python/tidy/servo_tidy_tests/lib.rs b/python/tidy/tests/lib.rs
index 5fea057b5c5..5fea057b5c5 100644
--- a/python/tidy/servo_tidy_tests/lib.rs
+++ b/python/tidy/tests/lib.rs
diff --git a/python/tidy/servo_tidy_tests/lints/invalid_error_tuple.py b/python/tidy/tests/lints/invalid_error_tuple.py
index 4851cdf402c..4851cdf402c 100644
--- a/python/tidy/servo_tidy_tests/lints/invalid_error_tuple.py
+++ b/python/tidy/tests/lints/invalid_error_tuple.py
diff --git a/python/tidy/servo_tidy_tests/lints/no_lint.py b/python/tidy/tests/lints/no_lint.py
index e9f84aa9f3c..e9f84aa9f3c 100644
--- a/python/tidy/servo_tidy_tests/lints/no_lint.py
+++ b/python/tidy/tests/lints/no_lint.py
diff --git a/python/tidy/servo_tidy_tests/lints/no_run.py b/python/tidy/tests/lints/no_run.py
index 2acd5db1fee..2acd5db1fee 100644
--- a/python/tidy/servo_tidy_tests/lints/no_run.py
+++ b/python/tidy/tests/lints/no_run.py
diff --git a/python/tidy/servo_tidy_tests/lints/not_inherited.py b/python/tidy/tests/lints/not_inherited.py
index fc38dff2c58..fc38dff2c58 100644
--- a/python/tidy/servo_tidy_tests/lints/not_inherited.py
+++ b/python/tidy/tests/lints/not_inherited.py
diff --git a/python/tidy/servo_tidy_tests/lints/not_script b/python/tidy/tests/lints/not_script
index e69de29bb2d..e69de29bb2d 100644
--- a/python/tidy/servo_tidy_tests/lints/not_script
+++ b/python/tidy/tests/lints/not_script
diff --git a/python/tidy/servo_tidy_tests/lints/proper_file.py b/python/tidy/tests/lints/proper_file.py
index acecb82abd4..acecb82abd4 100644
--- a/python/tidy/servo_tidy_tests/lints/proper_file.py
+++ b/python/tidy/tests/lints/proper_file.py
diff --git a/python/tidy/servo_tidy_tests/long_line.rs b/python/tidy/tests/long_line.rs
index 6427aa50878..6427aa50878 100644
--- a/python/tidy/servo_tidy_tests/long_line.rs
+++ b/python/tidy/tests/long_line.rs
diff --git a/python/tidy/servo_tidy_tests/malformed_json.json b/python/tidy/tests/malformed_json.json
index 9b1cf7cbd88..9b1cf7cbd88 100644
--- a/python/tidy/servo_tidy_tests/malformed_json.json
+++ b/python/tidy/tests/malformed_json.json
diff --git a/python/tidy/servo_tidy_tests/manifest-include.ini b/python/tidy/tests/manifest-include.ini
index ade00f2fa31..ade00f2fa31 100644
--- a/python/tidy/servo_tidy_tests/manifest-include.ini
+++ b/python/tidy/tests/manifest-include.ini
diff --git a/python/tidy/servo_tidy_tests/modeline.txt b/python/tidy/tests/modeline.txt
index 2a3416953ce..2a3416953ce 100644
--- a/python/tidy/servo_tidy_tests/modeline.txt
+++ b/python/tidy/tests/modeline.txt
diff --git a/python/tidy/servo_tidy_tests/multiline_string.rs b/python/tidy/tests/multiline_string.rs
index 0a4d2fa87ee..0a4d2fa87ee 100644
--- a/python/tidy/servo_tidy_tests/multiline_string.rs
+++ b/python/tidy/tests/multiline_string.rs
diff --git a/python/tidy/servo_tidy_tests/non_list_mapping_buildbot_steps.yml b/python/tidy/tests/non_list_mapping_buildbot_steps.yml
index 2581aa21d88..2581aa21d88 100644
--- a/python/tidy/servo_tidy_tests/non_list_mapping_buildbot_steps.yml
+++ b/python/tidy/tests/non_list_mapping_buildbot_steps.yml
diff --git a/python/tidy/servo_tidy_tests/non_string_list_buildbot_steps.yml b/python/tidy/tests/non_string_list_buildbot_steps.yml
index d9255e7cfe5..d9255e7cfe5 100644
--- a/python/tidy/servo_tidy_tests/non_string_list_buildbot_steps.yml
+++ b/python/tidy/tests/non_string_list_buildbot_steps.yml
diff --git a/python/tidy/servo_tidy_tests/rust_tidy.rs b/python/tidy/tests/rust_tidy.rs
index abd533d5807..abd533d5807 100644
--- a/python/tidy/servo_tidy_tests/rust_tidy.rs
+++ b/python/tidy/tests/rust_tidy.rs
diff --git a/python/tidy/servo_tidy_tests/servo-tidy.toml b/python/tidy/tests/servo-tidy.toml
index 690098b0e44..690098b0e44 100644
--- a/python/tidy/servo_tidy_tests/servo-tidy.toml
+++ b/python/tidy/tests/servo-tidy.toml
diff --git a/python/tidy/servo_tidy_tests/shebang_license.py b/python/tidy/tests/shebang_license.py
index f913d5ee1e4..f913d5ee1e4 100644
--- a/python/tidy/servo_tidy_tests/shebang_license.py
+++ b/python/tidy/tests/shebang_license.py
diff --git a/python/tidy/servo_tidy_tests/shell_tidy.sh b/python/tidy/tests/shell_tidy.sh
index e38358fc3b6..e38358fc3b6 100644
--- a/python/tidy/servo_tidy_tests/shell_tidy.sh
+++ b/python/tidy/tests/shell_tidy.sh
diff --git a/python/tidy/servo_tidy_tests/spec.webidl b/python/tidy/tests/spec.webidl
index 83ce8f935c3..83ce8f935c3 100644
--- a/python/tidy/servo_tidy_tests/spec.webidl
+++ b/python/tidy/tests/spec.webidl
diff --git a/python/tidy/servo_tidy_tests/speclink.rs b/python/tidy/tests/speclink.rs
index 499953e7bda..499953e7bda 100644
--- a/python/tidy/servo_tidy_tests/speclink.rs
+++ b/python/tidy/tests/speclink.rs
diff --git a/python/tidy/servo_tidy_tests/test_ignored/whee/foo/bar.rs b/python/tidy/tests/test_ignored/whee/foo/bar.rs
index e69de29bb2d..e69de29bb2d 100644
--- a/python/tidy/servo_tidy_tests/test_ignored/whee/foo/bar.rs
+++ b/python/tidy/tests/test_ignored/whee/foo/bar.rs
diff --git a/python/tidy/servo_tidy_tests/test_ignored/whee/test.rs b/python/tidy/tests/test_ignored/whee/test.rs
index e69de29bb2d..e69de29bb2d 100644
--- a/python/tidy/servo_tidy_tests/test_ignored/whee/test.rs
+++ b/python/tidy/tests/test_ignored/whee/test.rs
diff --git a/python/tidy/servo_tidy_tests/unordered_key.json b/python/tidy/tests/unordered_key.json
index 36f0a13f9c2..36f0a13f9c2 100644
--- a/python/tidy/servo_tidy_tests/unordered_key.json
+++ b/python/tidy/tests/unordered_key.json
diff --git a/python/tidy/servo_tidy_tests/whatwg_link.rs b/python/tidy/tests/whatwg_link.rs
index d6ed712450a..d6ed712450a 100644
--- a/python/tidy/servo_tidy_tests/whatwg_link.rs
+++ b/python/tidy/tests/whatwg_link.rs
diff --git a/python/tidy/servo_tidy_tests/wrong_space.rs b/python/tidy/tests/wrong_space.rs
index be735e2d463..be735e2d463 100644
--- a/python/tidy/servo_tidy_tests/wrong_space.rs
+++ b/python/tidy/tests/wrong_space.rs
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/tidy.py
index 7c45bb63d93..1e5de4080c0 100644
--- a/python/tidy/servo_tidy/tidy.py
+++ b/python/tidy/tidy.py
@@ -7,11 +7,8 @@
# option. This file may not be copied, modified, or distributed
# except according to those terms.
-from __future__ import print_function
-
import fnmatch
import glob
-import imp
import itertools
import json
import os
@@ -23,13 +20,16 @@ import colorama
import toml
import voluptuous
import yaml
+
from .licenseck import OLD_MPL, MPL, APACHE, COPYRIGHT, licenses_toml, licenses_dep_toml
-topdir = os.path.abspath(os.path.dirname(sys.argv[0]))
-wpt = os.path.join(topdir, "tests", "wpt")
+
+TOPDIR = os.path.abspath(os.path.dirname(sys.argv[0]))
+WPT_PATH = os.path.join(".", "tests", "wpt")
+SUITES = ["web-platform-tests", os.path.join("mozilla", "tests")]
def wpt_path(*args):
- return os.path.join(wpt, *args)
+ return os.path.join(WPT_PATH, *args)
CONFIG_FILE_PATH = os.path.join(".", "servo-tidy.toml")
@@ -1084,27 +1084,10 @@ class LintRunner(object):
self.stylo = stylo
self.no_wpt = no_wpt
- def check(self):
- if not os.path.exists(self.path):
- yield (self.path, 0, "file does not exist")
- return
- if not self.path.endswith('.py'):
- yield (self.path, 0, "lint should be a python script")
- return
- dir_name, filename = os.path.split(self.path)
- sys.path.append(dir_name)
- module = imp.load_source(filename[:-3], self.path)
- sys.path.remove(dir_name)
- if not hasattr(module, 'Lint'):
- yield (self.path, 1, "script should contain a class named 'Lint'")
- return
-
- if not issubclass(module.Lint, LintRunner):
- yield (self.path, 1, "class 'Lint' should inherit from 'LintRunner'")
- return
-
- lint = module.Lint(self.path, self.only_changed_files,
- self.exclude_dirs, self.progress, stylo=self.stylo, no_wpt=self.no_wpt)
+ def check(self, lint_cls):
+ lint = lint_cls(self.path, self.only_changed_files,
+ self.exclude_dirs, self.progress,
+ stylo=self.stylo, no_wpt=self.no_wpt)
for error in lint.run():
if type(error) is not tuple or (type(error) is tuple and len(error) != 3):
yield (self.path, 1, "errors should be a tuple of (path, line, reason)")
@@ -1122,10 +1105,8 @@ class LintRunner(object):
def run_lint_scripts(only_changed_files=False, progress=True, stylo=False, no_wpt=False):
runner = LintRunner(only_changed_files=only_changed_files, progress=progress, stylo=stylo, no_wpt=no_wpt)
- for path in config['lint-scripts']:
- runner.path = path
- for error in runner.check():
- yield error
+ for error in runner.check(WPTLint):
+ yield error
def scan(only_changed_files=False, progress=True, stylo=False, no_wpt=False):
@@ -1162,3 +1143,30 @@ def scan(only_changed_files=False, progress=True, stylo=False, no_wpt=False):
print("\033[92mtidy reported no errors.\033[0m")
return int(error is not None)
+
+
+class WPTLint(LintRunner):
+ def _get_wpt_files(self, suite):
+ working_dir = os.path.join(WPT_PATH, suite, '')
+ file_iter = self.get_files(working_dir, exclude_dirs=[])
+ print('\nRunning the WPT lint on %s...' % working_dir)
+ for f in file_iter:
+ if filter_file(f):
+ yield f[len(working_dir):]
+
+ def run(self):
+ if self.stylo or self.no_wpt:
+ return
+
+ wpt_working_dir = os.path.abspath(os.path.join(WPT_PATH, "web-platform-tests"))
+ for suite in SUITES:
+ files = list(self._get_wpt_files(suite))
+ if not files:
+ continue
+ sys.path.insert(0, wpt_working_dir)
+ from tools.lint import lint
+ file_dir = os.path.abspath(os.path.join(WPT_PATH, suite))
+ returncode = lint.lint(file_dir, files, output_format="json")
+ sys.path.remove(wpt_working_dir)
+ if returncode:
+ yield ("WPT Lint Tool", "", "lint error(s) in Web Platform Tests: exit status %s" % returncode)
diff --git a/servo-tidy.toml b/servo-tidy.toml
index 7e198738942..5038fb8b65f 100644
--- a/servo-tidy.toml
+++ b/servo-tidy.toml
@@ -3,7 +3,6 @@ skip-check-length = false
skip-check-licenses = false
check-alphabetical-order = true
check-ordered-json-keys = ["./resources/prefs.json"]
-lint-scripts = ["./python/servo/lints/wpt_lint.py"]
# Packages which we avoid using in Servo.
# For each blocked package, we can list the exceptions,
@@ -123,6 +122,8 @@ files = [
"./tests/wpt/mozilla/tests/mozilla/textarea_placeholder.html",
# Python 3 syntax causes "E901 SyntaxError" when flake8 runs in Python 2
"./components/style/properties/build.py",
+ # The tidy tests currently don't pass tidy.
+ "./python/tidy/test.py",
]
# Directories that are ignored for the non-WPT tidy check.
directories = [
@@ -133,7 +134,7 @@ directories = [
"./tests/wpt/web-platform-tests",
"./tests/wpt/mozilla/tests/mozilla/referrer-policy",
"./tests/wpt/mozilla/tests/webgl",
- "./python/tidy/servo_tidy_tests",
+ "./python/tidy/tests",
"./components/script/dom/bindings/codegen/parser",
"./components/script/dom/bindings/codegen/ply",
"./python/_virtualenv*",
diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/css1/c414-flt-wrap-001.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/css1/c414-flt-wrap-001.xht.ini
new file mode 100644
index 00000000000..b07643272b6
--- /dev/null
+++ b/tests/wpt/metadata-layout-2020/css/CSS2/css1/c414-flt-wrap-001.xht.ini
@@ -0,0 +1,2 @@
+[c414-flt-wrap-001.xht]
+ expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/floats-clear/clear-clearance-calculation-003.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/floats-clear/clear-clearance-calculation-003.xht.ini
deleted file mode 100644
index 73ce7f8a1eb..00000000000
--- a/tests/wpt/metadata-layout-2020/css/CSS2/floats-clear/clear-clearance-calculation-003.xht.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[clear-clearance-calculation-003.xht]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-001.html.ini b/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-001.html.ini
deleted file mode 100644
index 17aa43d18b1..00000000000
--- a/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-001.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[floats-placement-001.html]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-002.html.ini b/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-002.html.ini
deleted file mode 100644
index 4e00856c08e..00000000000
--- a/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-002.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[floats-placement-002.html]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-003.html.ini b/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-003.html.ini
deleted file mode 100644
index 90225d8f4d4..00000000000
--- a/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-003.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[floats-placement-003.html]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-008.html.ini b/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-008.html.ini
deleted file mode 100644
index 5a1e705388f..00000000000
--- a/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-008.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[floats-placement-008.html]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-001.html.ini b/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-001.html.ini
new file mode 100644
index 00000000000..0842d0b5727
--- /dev/null
+++ b/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-001.html.ini
@@ -0,0 +1,3 @@
+[hit-test-floats-001.html]
+ [hit-test-floats-001]
+ expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/zindex/stack-floats-001.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/zindex/stack-floats-001.xht.ini
deleted file mode 100644
index 51b3c04a7f4..00000000000
--- a/tests/wpt/metadata-layout-2020/css/CSS2/zindex/stack-floats-001.xht.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[stack-floats-001.xht]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/zindex/stack-floats-002.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/zindex/stack-floats-002.xht.ini
deleted file mode 100644
index 413e005eeda..00000000000
--- a/tests/wpt/metadata-layout-2020/css/CSS2/zindex/stack-floats-002.xht.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[stack-floats-002.xht]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/zindex/stack-floats-004.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/zindex/stack-floats-004.xht.ini
deleted file mode 100644
index 0e8029cf3cb..00000000000
--- a/tests/wpt/metadata-layout-2020/css/CSS2/zindex/stack-floats-004.xht.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[stack-floats-004.xht]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-center.html.ini b/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-center.html.ini
deleted file mode 100644
index dcb5578932d..00000000000
--- a/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-center.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flex-align-content-center.html]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-end.html.ini b/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-end.html.ini
deleted file mode 100644
index d813a3dbc90..00000000000
--- a/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-end.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flex-align-content-end.html]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-space-around.html.ini b/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-space-around.html.ini
deleted file mode 100644
index 0df689e3f18..00000000000
--- a/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-space-around.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flex-align-content-space-around.html]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-space-between.html.ini b/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-space-between.html.ini
deleted file mode 100644
index e10b2f33ae2..00000000000
--- a/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-space-between.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flex-align-content-space-between.html]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-start.html.ini b/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-start.html.ini
deleted file mode 100644
index 19e606aada8..00000000000
--- a/tests/wpt/metadata-layout-2020/css/css-flexbox/flex-align-content-start.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[flex-align-content-start.html]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/css-flexbox/flexbox_flex-formatting-interop.html.ini b/tests/wpt/metadata-layout-2020/css/css-flexbox/flexbox_flex-formatting-interop.html.ini
new file mode 100644
index 00000000000..0a5916356e7
--- /dev/null
+++ b/tests/wpt/metadata-layout-2020/css/css-flexbox/flexbox_flex-formatting-interop.html.ini
@@ -0,0 +1,2 @@
+[flexbox_flex-formatting-interop.html]
+ expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/css-position/position-absolute-dynamic-static-position-floats-004.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/position-absolute-dynamic-static-position-floats-004.html.ini
deleted file mode 100644
index e488c064bb1..00000000000
--- a/tests/wpt/metadata-layout-2020/css/css-position/position-absolute-dynamic-static-position-floats-004.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[position-absolute-dynamic-static-position-floats-004.html]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/css-position/static-position/inline-level-absolute-in-block-level-context-004.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/static-position/inline-level-absolute-in-block-level-context-004.html.ini
deleted file mode 100644
index 972f6697b03..00000000000
--- a/tests/wpt/metadata-layout-2020/css/css-position/static-position/inline-level-absolute-in-block-level-context-004.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[inline-level-absolute-in-block-level-context-004.html]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/css-position/static-position/inline-level-absolute-in-block-level-context-009.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/static-position/inline-level-absolute-in-block-level-context-009.html.ini
deleted file mode 100644
index 0653a572396..00000000000
--- a/tests/wpt/metadata-layout-2020/css/css-position/static-position/inline-level-absolute-in-block-level-context-009.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[inline-level-absolute-in-block-level-context-009.html]
- expected: FAIL
diff --git a/tests/wpt/metadata-layout-2020/css/css-position/static-position/inline-level-absolute-in-block-level-context-010.html.ini b/tests/wpt/metadata-layout-2020/css/css-position/static-position/inline-level-absolute-in-block-level-context-010.html.ini
deleted file mode 100644
index 2035850bdc8..00000000000
--- a/tests/wpt/metadata-layout-2020/css/css-position/static-position/inline-level-absolute-in-block-level-context-010.html.ini
+++ /dev/null
@@ -1,2 +0,0 @@
-[inline-level-absolute-in-block-level-context-010.html]
- expected: FAIL