From c615a0dabc8828a6c63af83746c428c3d2bb0b7e Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 20 Sep 2016 20:22:36 +0530 Subject: [PATCH] Add unit test crate for stylo --- ports/geckolib/Cargo.lock | 12 ++++++++++++ ports/geckolib/Cargo.toml | 3 +++ python/servo/testing_commands.py | 22 +++++++++++++++++++++- tests/unit/stylo/Cargo.toml | 16 ++++++++++++++++ tests/unit/stylo/lib.rs | 10 ++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 tests/unit/stylo/Cargo.toml create mode 100644 tests/unit/stylo/lib.rs diff --git a/ports/geckolib/Cargo.lock b/ports/geckolib/Cargo.lock index dd84fdf5284..4bb97da9835 100644 --- a/ports/geckolib/Cargo.lock +++ b/ports/geckolib/Cargo.lock @@ -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" diff --git a/ports/geckolib/Cargo.toml b/ports/geckolib/Cargo.toml index bcf38096e85..604411df56b 100644 --- a/ports/geckolib/Cargo.toml +++ b/ports/geckolib/Cargo.toml @@ -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"} \ No newline at end of file diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 97bf8635190..7e146afc055 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -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') diff --git a/tests/unit/stylo/Cargo.toml b/tests/unit/stylo/Cargo.toml new file mode 100644 index 00000000000..e64d2de3c2b --- /dev/null +++ b/tests/unit/stylo/Cargo.toml @@ -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"} diff --git a/tests/unit/stylo/lib.rs b/tests/unit/stylo/lib.rs new file mode 100644 index 00000000000..3af0f5c54ee --- /dev/null +++ b/tests/unit/stylo/lib.rs @@ -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 +} \ No newline at end of file