Move bindings tests out of the style crate.

This cuts in almost half the time to run:

```
touch components/style/lib.rs
./mach test-stylo
```
This commit is contained in:
Simon Sapin 2017-05-18 18:28:25 +02:00
parent 5e60865d19
commit ee2794e966
6 changed files with 25 additions and 7 deletions

View file

@ -7,6 +7,9 @@ publish = false
build = "build.rs" build = "build.rs"
# https://github.com/rust-lang/cargo/issues/3544
links = "for some reason the links key is required to pass data around between build scripts"
[lib] [lib]
name = "style" name = "style"
path = "lib.rs" path = "lib.rs"

View file

@ -83,6 +83,7 @@ fn generate_properties() {
fn main() { fn main() {
println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build.rs");
println!("cargo:out_dir={}", env::var("OUT_DIR").unwrap());
generate_properties(); generate_properties();
build_gecko::generate(); build_gecko::generate();
} }

View file

@ -61,7 +61,7 @@ extern crate log;
extern crate matches; extern crate matches;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
#[macro_use] #[macro_use]
extern crate nsstring_vendor as nsstring; pub extern crate nsstring_vendor as nsstring;
#[cfg(feature = "gecko")] extern crate num_cpus; #[cfg(feature = "gecko")] extern crate num_cpus;
extern crate num_integer; extern crate num_integer;
extern crate num_traits; extern crate num_traits;

View file

@ -299,13 +299,8 @@ class MachCommands(CommandBase):
env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8") env["CARGO_TARGET_DIR"] = path.join(self.context.topdir, "target", "geckolib").encode("UTF-8")
release = ["--release"] if release else [] release = ["--release"] if release else []
ret = 0
with cd(path.join("ports", "geckolib")): with cd(path.join("ports", "geckolib")):
ret = call(["cargo", "test", "-p", "stylo_tests", "--features", "testing"] + release, env=env) return call(["cargo", "test", "-p", "stylo_tests", "--features", "testing"] + release, env=env)
if ret != 0:
return ret
with cd(path.join("ports", "geckolib")):
return call(["cargo", "test", "-p", "style"] + release, env=env)
@Command('test-compiletest', @Command('test-compiletest',
description='Run compiletests', description='Run compiletests',

View file

@ -2,6 +2,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::env;
use std::fs;
use std::io::Write;
use std::path;
use std::process::Command; use std::process::Command;
fn main() { fn main() {
@ -11,4 +15,13 @@ fn main() {
println!("cargo:rerun-if-changed=../../../components/style/gecko_bindings/bindings.rs"); println!("cargo:rerun-if-changed=../../../components/style/gecko_bindings/bindings.rs");
assert!(Command::new("python").arg("./check_bindings.py") assert!(Command::new("python").arg("./check_bindings.py")
.spawn().unwrap().wait().unwrap().success()); .spawn().unwrap().wait().unwrap().success());
// https://github.com/rust-lang/cargo/issues/3544
let style_out_dir = env::var_os("DEP_FOR SOME REASON THE LINKS KEY IS REQUIRED \
TO PASS DATA AROUND BETWEEN BUILD SCRIPTS_OUT_DIR").unwrap();
fs::File::create(path::PathBuf::from(env::var_os("OUT_DIR").unwrap()).join("bindings.rs"))
.unwrap()
.write_all(format!("include!(concat!({:?}, \"/gecko/structs_debug.rs\"));",
style_out_dir).as_bytes())
.unwrap();
} }

View file

@ -17,3 +17,9 @@ mod size_of;
mod servo_function_signatures; mod servo_function_signatures;
use style::*;
#[allow(dead_code, improper_ctypes)]
mod bindings {
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}