mirror of
https://github.com/servo/servo.git
synced 2025-07-09 08:23:38 +01:00
Auto merge of #13335 - Manishearth:stylo-tests, r=emilio
Add unit test crate for stylo @canaltinova needs this for his mask work -- we need a way to test stylo code (or style code that's conditionally compiled out for gecko) We can add this to the CI as well. r? @emilio <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13335) <!-- Reviewable:end -->
This commit is contained in:
commit
66c736194d
7 changed files with 65 additions and 3 deletions
13
ports/geckolib/Cargo.lock
generated
13
ports/geckolib/Cargo.lock
generated
|
@ -14,6 +14,7 @@ dependencies = [
|
||||||
"selectors 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"selectors 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
|
"stylo_tests 0.0.1",
|
||||||
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"url 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -52,6 +53,7 @@ version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
"encoding 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -393,6 +395,17 @@ dependencies = [
|
||||||
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "stylo_tests"
|
||||||
|
version = "0.0.1"
|
||||||
|
dependencies = [
|
||||||
|
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"cssparser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"gecko_bindings 0.0.1",
|
||||||
|
"style 0.0.1",
|
||||||
|
"style_traits 0.0.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thread-id"
|
name = "thread-id"
|
||||||
version = "2.0.0"
|
version = "2.0.0"
|
||||||
|
|
|
@ -23,3 +23,6 @@ selectors = "0.13"
|
||||||
style = {path = "../../components/style", features = ["gecko"]}
|
style = {path = "../../components/style", features = ["gecko"]}
|
||||||
style_traits = {path = "../../components/style_traits"}
|
style_traits = {path = "../../components/style_traits"}
|
||||||
url = "1.2"
|
url = "1.2"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
stylo_tests = {path = "../../tests/unit/stylo"}
|
||||||
|
|
|
@ -22,7 +22,6 @@ mod snapshot;
|
||||||
mod snapshot_helpers;
|
mod snapshot_helpers;
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub mod glue;
|
pub mod glue;
|
||||||
mod sanity_checks;
|
|
||||||
mod traversal;
|
mod traversal;
|
||||||
mod wrapper;
|
mod wrapper;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ from mach.decorators import (
|
||||||
Command,
|
Command,
|
||||||
)
|
)
|
||||||
|
|
||||||
from servo.command_base import CommandBase, call, check_call, host_triple
|
from servo.command_base import CommandBase, call, cd, check_call, host_triple
|
||||||
from wptrunner import wptcommandline
|
from wptrunner import wptcommandline
|
||||||
from update import updatecommandline
|
from update import updatecommandline
|
||||||
from servo_tidy import tidy
|
from servo_tidy import tidy
|
||||||
|
@ -208,6 +208,8 @@ class MachCommands(CommandBase):
|
||||||
if not packages:
|
if not packages:
|
||||||
packages = set(os.listdir(path.join(self.context.topdir, "tests", "unit")))
|
packages = set(os.listdir(path.join(self.context.topdir, "tests", "unit")))
|
||||||
|
|
||||||
|
packages.remove('stylo')
|
||||||
|
|
||||||
args = ["cargo", "test"]
|
args = ["cargo", "test"]
|
||||||
for crate in packages:
|
for crate in packages:
|
||||||
args += ["-p", "%s_tests" % crate]
|
args += ["-p", "%s_tests" % crate]
|
||||||
|
@ -232,6 +234,23 @@ class MachCommands(CommandBase):
|
||||||
if result != 0:
|
if result != 0:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@Command('test-stylo',
|
||||||
|
description='Run stylo unit tests',
|
||||||
|
category='testing')
|
||||||
|
def test_stylo(self):
|
||||||
|
self.set_use_stable_rust()
|
||||||
|
self.ensure_bootstrapped()
|
||||||
|
|
||||||
|
env = self.build_env()
|
||||||
|
env["RUST_BACKTRACE"] = "1"
|
||||||
|
env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8")
|
||||||
|
|
||||||
|
with cd(path.join("ports", "geckolib")):
|
||||||
|
result = call(["cargo", "test", "-p", "stylo_tests"], env=env)
|
||||||
|
|
||||||
|
if result != 0:
|
||||||
|
return result
|
||||||
|
|
||||||
@Command('test-compiletest',
|
@Command('test-compiletest',
|
||||||
description='Run compiletests',
|
description='Run compiletests',
|
||||||
category='testing')
|
category='testing')
|
||||||
|
|
17
tests/unit/stylo/Cargo.toml
Normal file
17
tests/unit/stylo/Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[package]
|
||||||
|
name = "stylo_tests"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = ["The Servo Project Developers"]
|
||||||
|
license = "MPL-2.0"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
name = "stylo_tests"
|
||||||
|
path = "lib.rs"
|
||||||
|
doctest = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
app_units = "0.3"
|
||||||
|
cssparser = {version = "0.7", features = ["heap_size"]}
|
||||||
|
gecko_bindings = {path = "../../../ports/geckolib/gecko_bindings"}
|
||||||
|
style = {path = "../../../components/style", features = ["gecko"]}
|
||||||
|
style_traits = {path = "../../../components/style_traits"}
|
11
tests/unit/stylo/lib.rs
Normal file
11
tests/unit/stylo/lib.rs
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
extern crate app_units;
|
||||||
|
extern crate cssparser;
|
||||||
|
extern crate gecko_bindings;
|
||||||
|
extern crate style;
|
||||||
|
extern crate style_traits;
|
||||||
|
|
||||||
|
mod sanity_checks;
|
|
@ -62,7 +62,7 @@ fn assert_basic_pseudo_elements() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
include!("../../components/style/generated/gecko_pseudo_element_helper.rs");
|
include!("../../../components/style/generated/gecko_pseudo_element_helper.rs");
|
||||||
|
|
||||||
assert!(saw_before);
|
assert!(saw_before);
|
||||||
assert!(saw_after);
|
assert!(saw_after);
|
Loading…
Add table
Add a link
Reference in a new issue