Add unit test crate for stylo

This commit is contained in:
Manish Goregaokar 2016-09-20 20:22:36 +05:30
parent 53938c439f
commit c615a0dabc
No known key found for this signature in database
GPG key ID: 3BBF4D3E2EF79F98
5 changed files with 62 additions and 1 deletions

View file

@ -14,6 +14,7 @@ dependencies = [
"selectors 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
"style 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)",
]
@ -52,6 +53,7 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"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)",
]
@ -393,6 +395,16 @@ dependencies = [
"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)",
"style 0.0.1",
"style_traits 0.0.1",
]
[[package]]
name = "thread-id"
version = "2.0.0"

View file

@ -23,3 +23,6 @@ selectors = "0.13"
style = {path = "../../components/style", features = ["gecko"]}
style_traits = {path = "../../components/style_traits"}
url = "1.2"
[dev-dependencies]
stylo_tests = {path = "../../tests/unit/stylo"}

View file

@ -25,7 +25,7 @@ from mach.decorators import (
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 update import updatecommandline
from servo_tidy import tidy
@ -232,6 +232,26 @@ class MachCommands(CommandBase):
if result != 0:
return result
@Command('test-stylo',
description='Run stylo unit tests',
category='testing')
def test_unit(self, test_name=None, package=None):
if test_name is None:
test_name = []
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',
description='Run compiletests',
category='testing')

View file

@ -0,0 +1,16 @@
[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"]}
style = {path = "../../../components/style", features = ["gecko"]}
style_traits = {path = "../../../components/style_traits"}

10
tests/unit/stylo/lib.rs Normal file
View file

@ -0,0 +1,10 @@
extern crate app_units;
extern crate cssparser;
extern crate style;
extern crate style_traits;
#[test]
fn test_test() {
// do nothing
// this is a temporary test testing that the test runs
}