mirror of
https://github.com/servo/servo.git
synced 2025-07-24 07:40:27 +01:00
Make unit tests pass on TravisCI.
This commit is contained in:
parent
0abd5bbabd
commit
f3f9e28e88
6 changed files with 53 additions and 28 deletions
|
@ -22,7 +22,7 @@ matrix:
|
||||||
- bash etc/ci/lockfile_changed.sh
|
- bash etc/ci/lockfile_changed.sh
|
||||||
- bash etc/ci/manifest_changed.sh
|
- bash etc/ci/manifest_changed.sh
|
||||||
- ./mach cargo test -p selectors
|
- ./mach cargo test -p selectors
|
||||||
- ./mach cargo test -p style
|
- ./mach test-unit -p style
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- .cargo
|
- .cargo
|
||||||
|
|
|
@ -14,6 +14,8 @@ license = "MPL-2.0"
|
||||||
[lib]
|
[lib]
|
||||||
name = "selectors"
|
name = "selectors"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
# https://github.com/servo/servo/issues/16710
|
||||||
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "0.7"
|
bitflags = "0.7"
|
||||||
|
|
|
@ -431,8 +431,11 @@ fn combinator_to_restyle_hint(combinator: Option<Combinator>) -> RestyleHint {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
struct Sensitivities {
|
/// The aspects of an selector which are sensitive.
|
||||||
|
pub struct Sensitivities {
|
||||||
|
/// The states which are sensitive.
|
||||||
pub states: ElementState,
|
pub states: ElementState,
|
||||||
|
/// Whether attributes are sensitive.
|
||||||
pub attrs: bool,
|
pub attrs: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,11 +472,13 @@ impl Sensitivities {
|
||||||
/// change may have on the style of elements in the document.
|
/// change may have on the style of elements in the document.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
struct Dependency {
|
pub struct Dependency {
|
||||||
#[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")]
|
#[cfg_attr(feature = "servo", ignore_heap_size_of = "Arc")]
|
||||||
selector: SelectorInner<SelectorImpl>,
|
selector: SelectorInner<SelectorImpl>,
|
||||||
hint: RestyleHint,
|
/// The hint associated with this dependency.
|
||||||
sensitivities: Sensitivities,
|
pub hint: RestyleHint,
|
||||||
|
/// The sensitivities associated with this dependency.
|
||||||
|
pub sensitivities: Sensitivities,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -681,27 +686,9 @@ impl DependencySet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/// Get the dependencies affected by state.
|
||||||
#[test]
|
pub fn get_state_deps(&self) -> &[Dependency] {
|
||||||
#[cfg(all(test, feature = "servo"))]
|
&self.state_deps
|
||||||
fn smoke_restyle_hints() {
|
}
|
||||||
use cssparser::Parser;
|
|
||||||
use selector_parser::SelectorParser;
|
|
||||||
use stylesheets::{Origin, Namespaces};
|
|
||||||
let namespaces = Namespaces::default();
|
|
||||||
let parser = SelectorParser {
|
|
||||||
stylesheet_origin: Origin::Author,
|
|
||||||
namespaces: &namespaces,
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut dependencies = DependencySet::new();
|
|
||||||
|
|
||||||
let mut p = Parser::new(":not(:active) ~ label");
|
|
||||||
let selector = ComplexSelector::parse(&parser, &mut p).unwrap();
|
|
||||||
dependencies.note_selector(&selector);
|
|
||||||
assert_eq!(dependencies.len(), 1);
|
|
||||||
assert_eq!(dependencies.state_deps.len(), 1);
|
|
||||||
assert!(!dependencies.state_deps[0].sensitivities.states.is_empty());
|
|
||||||
assert!(dependencies.state_deps[0].hint.contains(RESTYLE_LATER_SIBLINGS));
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,8 +231,10 @@ class MachCommands(CommandBase):
|
||||||
else:
|
else:
|
||||||
test_patterns.append(test)
|
test_patterns.append(test)
|
||||||
|
|
||||||
|
in_crate_packages = []
|
||||||
if not packages:
|
if not packages:
|
||||||
packages = set(os.listdir(path.join(self.context.topdir, "tests", "unit"))) - set(['.DS_Store'])
|
packages = set(os.listdir(path.join(self.context.topdir, "tests", "unit"))) - set(['.DS_Store'])
|
||||||
|
in_crate_packages += ["selectors"]
|
||||||
|
|
||||||
packages.discard('stylo')
|
packages.discard('stylo')
|
||||||
|
|
||||||
|
@ -255,6 +257,8 @@ class MachCommands(CommandBase):
|
||||||
args = ["cargo", "bench" if bench else "test"]
|
args = ["cargo", "bench" if bench else "test"]
|
||||||
for crate in packages:
|
for crate in packages:
|
||||||
args += ["-p", "%s_tests" % crate]
|
args += ["-p", "%s_tests" % crate]
|
||||||
|
for crate in in_crate_packages:
|
||||||
|
args += ["-p", crate]
|
||||||
args += test_patterns
|
args += test_patterns
|
||||||
|
|
||||||
if features:
|
if features:
|
||||||
|
|
|
@ -27,6 +27,7 @@ mod logical_geometry;
|
||||||
mod media_queries;
|
mod media_queries;
|
||||||
mod parsing;
|
mod parsing;
|
||||||
mod properties;
|
mod properties;
|
||||||
|
mod restyle_hints;
|
||||||
mod rule_tree;
|
mod rule_tree;
|
||||||
mod size_of;
|
mod size_of;
|
||||||
mod str;
|
mod str;
|
||||||
|
|
31
tests/unit/style/restyle_hints.rs
Normal file
31
tests/unit/style/restyle_hints.rs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn smoke_restyle_hints() {
|
||||||
|
use cssparser::Parser;
|
||||||
|
use selectors::parser::SelectorList;
|
||||||
|
use style::restyle_hints::{DependencySet, RESTYLE_LATER_SIBLINGS};
|
||||||
|
use style::selector_parser::SelectorParser;
|
||||||
|
use style::stylesheets::{Origin, Namespaces};
|
||||||
|
let namespaces = Namespaces::default();
|
||||||
|
let parser = SelectorParser {
|
||||||
|
stylesheet_origin: Origin::Author,
|
||||||
|
namespaces: &namespaces,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut dependencies = DependencySet::new();
|
||||||
|
|
||||||
|
let mut p = Parser::new(":not(:active) ~ label");
|
||||||
|
let selectors = SelectorList::parse(&parser, &mut p).unwrap();
|
||||||
|
assert_eq!((selectors.0).len(), 1);
|
||||||
|
|
||||||
|
let selector = (selectors.0).first().unwrap();
|
||||||
|
dependencies.note_selector(selector);
|
||||||
|
assert_eq!(dependencies.len(), 1);
|
||||||
|
let state_deps = dependencies.get_state_deps();
|
||||||
|
assert_eq!(state_deps.len(), 1);
|
||||||
|
assert!(!state_deps[0].sensitivities.states.is_empty());
|
||||||
|
assert!(state_deps[0].hint.contains(RESTYLE_LATER_SIBLINGS));
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue