mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
parent
6bd898626f
commit
af57a98694
9 changed files with 148 additions and 37 deletions
|
@ -4,6 +4,8 @@ version = "0.0.1"
|
|||
authors = ["The Servo Project Developers"]
|
||||
license = "MPL-2.0"
|
||||
|
||||
build = "build.rs"
|
||||
|
||||
[lib]
|
||||
name = "stylo_tests"
|
||||
path = "lib.rs"
|
||||
|
@ -11,6 +13,15 @@ doctest = false
|
|||
|
||||
[dependencies]
|
||||
app_units = "0.3"
|
||||
cssparser = {version = "0.7", features = ["heap_size"]}
|
||||
style = {path = "../../../components/style", features = ["gecko"]}
|
||||
env_logger = "0.3"
|
||||
euclid = "0.10.1"
|
||||
lazy_static = "0.2"
|
||||
libc = "0.2"
|
||||
log = {version = "0.3.5", features = ["release_max_level_info"]}
|
||||
num_cpus = "0.2.2"
|
||||
parking_lot = "0.3"
|
||||
selectors = "0.13"
|
||||
url = "1.2"
|
||||
style_traits = {path = "../../../components/style_traits"}
|
||||
geckoservo = {path = "../../../ports/geckolib"}
|
||||
style = {path = "../../../components/style", features = ["gecko"]}
|
||||
|
|
13
tests/unit/stylo/build.rs
Normal file
13
tests/unit/stylo/build.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
/* 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/. */
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=build.rs");
|
||||
println!("cargo:rerun-if-changed=check_bindings.py");
|
||||
println!("cargo:rerun-if-changed=../../../ports/geckolib/glue.rs");
|
||||
assert!(Command::new("python").arg("./check_bindings.py")
|
||||
.spawn().unwrap().wait().unwrap().success());
|
||||
}
|
37
tests/unit/stylo/check_bindings.py
Executable file
37
tests/unit/stylo/check_bindings.py
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# 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/.
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
ROOT_PATH = os.path.join("..", "..", "..")
|
||||
INPUT_FILE = os.path.join(ROOT_PATH, "components", "style", "gecko_bindings", "bindings.rs")
|
||||
OUTPUT_FILE = os.path.join(os.environ["OUT_DIR"], "check_bindings.rs")
|
||||
GLUE_FILE = os.path.join(ROOT_PATH, "ports", "geckolib", "glue.rs")
|
||||
GLUE_OUTPUT_FILE = os.path.join(os.environ["OUT_DIR"], "glue.rs")
|
||||
|
||||
TEMPLATE = """\
|
||||
[ Servo_{name}, bindings::Servo_{name} ];
|
||||
"""
|
||||
|
||||
with open(INPUT_FILE, "r") as bindings, open(OUTPUT_FILE, "w+") as tests:
|
||||
tests.write("fn assert_types() {\n")
|
||||
|
||||
pattern = re.compile("fn\s*Servo_([a-zA-Z0-9_]+)\s*\(")
|
||||
|
||||
for line in bindings:
|
||||
match = pattern.search(line)
|
||||
|
||||
# GetStyleVariables is a Servo_* function, but temporarily defined on
|
||||
# the gecko side
|
||||
if match and match.group(1) != "GetStyleVariables":
|
||||
tests.write(TEMPLATE.format(name=match.group(1)))
|
||||
|
||||
tests.write("}\n")
|
||||
|
||||
with open(GLUE_FILE, "r") as glue, open(GLUE_OUTPUT_FILE, "w+") as glue_output:
|
||||
for line in glue:
|
||||
glue_output.write(line.replace("pub extern \"C\" fn", "pub unsafe extern \"C\" fn"))
|
|
@ -3,8 +3,16 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
extern crate app_units;
|
||||
extern crate cssparser;
|
||||
extern crate env_logger;
|
||||
extern crate euclid;
|
||||
extern crate geckoservo;
|
||||
extern crate libc;
|
||||
#[macro_use] extern crate log;
|
||||
extern crate parking_lot;
|
||||
extern crate style;
|
||||
extern crate style_traits;
|
||||
extern crate url;
|
||||
|
||||
mod sanity_checks;
|
||||
|
||||
mod servo_function_signatures;
|
||||
|
||||
|
|
20
tests/unit/stylo/servo_function_signatures.rs
Normal file
20
tests/unit/stylo/servo_function_signatures.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
/* 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/. */
|
||||
|
||||
#![allow(unused)]
|
||||
|
||||
use self::glue::*;
|
||||
use style::gecko_bindings::bindings;
|
||||
use style::gecko_properties::*;
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/check_bindings.rs"));
|
||||
|
||||
#[allow(non_snake_case, unused_unsafe, private_no_mangle_fns)]
|
||||
mod glue {
|
||||
// this module pretends to be glue.rs, with the safe functions swapped for unsafe ones. This is
|
||||
// a hack to compensate for the fact that `fn` types cannot coerce to `unsafe fn` types. The
|
||||
// imports are populated with the same things so the type assertion should be equivalent
|
||||
use geckoservo::*;
|
||||
include!(concat!(env!("OUT_DIR"), "/glue.rs"));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue