mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Replace compiletest suite by doc-tests with compile_fail
compiletest-rs use internal rustc APIs and is broken in today’s Nightly. rustdoc however is maintained with rustc and so much less fragile.
This commit is contained in:
parent
d96f0ff6a7
commit
b1ce298d4b
18 changed files with 266 additions and 239 deletions
|
@ -1,28 +0,0 @@
|
|||
/* 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 compiletest_rs as compiletest;
|
||||
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn run_mode(mode: &'static str) {
|
||||
let mut config = compiletest::default_config();
|
||||
let cfg_mode = mode.parse().ok().expect("Invalid mode");
|
||||
|
||||
config.mode = cfg_mode;
|
||||
config.src_base = PathBuf::from(format!("{}", mode));
|
||||
|
||||
let mut base_path = env::current_dir().expect("Current directory is invalid");
|
||||
base_path.pop();
|
||||
base_path.pop();
|
||||
base_path.pop();
|
||||
|
||||
let mode = env::var("BUILD_MODE").expect("BUILD_MODE environment variable must be set");
|
||||
let debug_path = base_path.join(PathBuf::from(format!("target/{}", mode)));
|
||||
let deps_path = base_path.join(PathBuf::from(format!("target/{}/deps", mode)));
|
||||
|
||||
config.target_rustcflags = Some(format!("-L {} -L {}", debug_path.display(), deps_path.display()));
|
||||
compiletest::run_tests(&config);
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
[package]
|
||||
name = "plugin_compiletest"
|
||||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
license = "MPL-2.0"
|
||||
|
||||
[lib]
|
||||
name = "plugin_compiletest"
|
||||
path = "lib.rs"
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
compiletest_helper = {path = "../helper"}
|
||||
deny_public_fields = {path = "../../../components/deny_public_fields"}
|
||||
script = {path = "../../../components/script"}
|
||||
script_plugins = {path = "../../../components/script_plugins"}
|
|
@ -1,34 +0,0 @@
|
|||
/* 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 malloc_size_of;
|
||||
extern crate servo_arc;
|
||||
|
||||
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf};
|
||||
|
||||
fn sizeable<T: MallocSizeOf>() {
|
||||
}
|
||||
|
||||
fn shallow_sizeable<T: MallocShallowSizeOf>() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
sizeable::<::servo_arc::Arc<i32>>();
|
||||
//~^ ERROR the trait bound `servo_arc::Arc<i32>: malloc_size_of::MallocSizeOf` is not satisfied
|
||||
|
||||
sizeable::<::std::sync::Arc<i32>>();
|
||||
//~^ ERROR the trait bound `std::sync::Arc<i32>: malloc_size_of::MallocSizeOf` is not satisfied
|
||||
|
||||
sizeable::<::std::rc::Rc<i32>>();
|
||||
//~^ ERROR the trait bound `std::rc::Rc<i32>: malloc_size_of::MallocSizeOf` is not satisfied
|
||||
|
||||
shallow_sizeable::<::servo_arc::Arc<i32>>();
|
||||
//~^ ERROR the trait bound `servo_arc::Arc<i32>: malloc_size_of::MallocShallowSizeOf` is not satisfied
|
||||
|
||||
shallow_sizeable::<::std::sync::Arc<i32>>();
|
||||
//~^ ERROR the trait bound `std::sync::Arc<i32>: malloc_size_of::MallocShallowSizeOf` is not satisfied
|
||||
|
||||
shallow_sizeable::<::std::rc::Rc<i32>>();
|
||||
//~^ ERROR the trait bound `std::rc::Rc<i32>: malloc_size_of::MallocShallowSizeOf` is not satisfied
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
/* 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 script;
|
||||
|
||||
use script::test::TrustedPromise;
|
||||
|
||||
fn cloneable<T: Clone>() {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
cloneable::<TrustedPromise>();
|
||||
//~^ ERROR the trait bound `script::test::TrustedPromise: std::clone::Clone` is not satisfied
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
/* 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(dead_code)]
|
||||
#![feature(plugin)]
|
||||
#![plugin(script_plugins)]
|
||||
|
||||
#[must_root]
|
||||
struct Foo {
|
||||
v: i32
|
||||
}
|
||||
|
||||
struct Bar {
|
||||
f: Foo
|
||||
//~^ ERROR Type must be rooted, use #[must_root] on the struct definition to propagate
|
||||
}
|
||||
|
||||
fn foo1(_: Foo) {} //~ ERROR Type must be rooted
|
||||
|
||||
|
||||
fn foo2() -> Foo { //~ ERROR Type must be rooted
|
||||
Foo { v: 10 }
|
||||
}
|
||||
|
||||
|
||||
fn main() {}
|
|
@ -1,10 +0,0 @@
|
|||
/* 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 compiletest_helper;
|
||||
|
||||
#[test]
|
||||
fn compile_test() {
|
||||
compiletest_helper::run_mode("compile-fail");
|
||||
}
|
12
tests/unit/deny_public_fields/Cargo.toml
Normal file
12
tests/unit/deny_public_fields/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "deny_public_fields_tests"
|
||||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
license = "MPL-2.0"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
test = false
|
||||
|
||||
[dependencies]
|
||||
deny_public_fields = {path = "../../../components/deny_public_fields"}
|
|
@ -2,17 +2,32 @@
|
|||
* 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(dead_code)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate deny_public_fields;
|
||||
/**
|
||||
```compile_fail
|
||||
#[macro_use] extern crate deny_public_fields;
|
||||
|
||||
#[derive(DenyPublicFields)]
|
||||
//~^ ERROR proc-macro derive panicked
|
||||
//~| HELP Field `v1` should not be public
|
||||
struct Foo {
|
||||
pub v1: i32,
|
||||
v2: i32
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
*/
|
||||
pub fn deny_public_fields_failing() {}
|
||||
|
||||
/**
|
||||
```
|
||||
#[macro_use] extern crate deny_public_fields;
|
||||
|
||||
#[derive(DenyPublicFields)]
|
||||
struct Foo {
|
||||
v1: i32,
|
||||
v2: i32
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
*/
|
||||
pub fn deny_public_fields_ok() {}
|
13
tests/unit/malloc_size_of/Cargo.toml
Normal file
13
tests/unit/malloc_size_of/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "malloc_size_of_tests"
|
||||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
license = "MPL-2.0"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
test = false
|
||||
|
||||
[dependencies]
|
||||
malloc_size_of = {path = "../../../components/malloc_size_of"}
|
||||
servo_arc = {path = "../../../components/servo_arc"}
|
109
tests/unit/malloc_size_of/lib.rs
Normal file
109
tests/unit/malloc_size_of/lib.rs
Normal file
|
@ -0,0 +1,109 @@
|
|||
/* 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 malloc_size_of;
|
||||
extern crate servo_arc;
|
||||
|
||||
fn sizeable<T: malloc_size_of::MallocSizeOf>() {}
|
||||
fn shallow_sizeable<T: malloc_size_of::MallocShallowSizeOf>() {}
|
||||
fn cloneable<T: Clone>() {}
|
||||
|
||||
fn main() {
|
||||
cloneable::<servo_arc::Arc<i32>>();
|
||||
cloneable::<std::sync::Arc<i32>>();
|
||||
cloneable::<std::rc::Rc<i32>>();
|
||||
}
|
||||
```
|
||||
*/
|
||||
pub fn imports_ok() {}
|
||||
|
||||
pub mod does_not_impl_malloc_size_of {
|
||||
/**
|
||||
```compile_fail,E0277
|
||||
extern crate malloc_size_of;
|
||||
extern crate servo_arc;
|
||||
|
||||
fn sizeable<T: malloc_size_of::MallocSizeOf>() {}
|
||||
|
||||
fn main() {
|
||||
sizeable::<servo_arc::Arc<i32>>();
|
||||
}
|
||||
```
|
||||
*/
|
||||
pub fn servo_arc() {}
|
||||
|
||||
|
||||
/**
|
||||
```compile_fail,E0277
|
||||
extern crate malloc_size_of;
|
||||
|
||||
fn sizeable<T: malloc_size_of::MallocSizeOf>() {}
|
||||
|
||||
fn main() {
|
||||
sizeable::<std::sync::Arc<i32>>();
|
||||
}
|
||||
```
|
||||
*/
|
||||
pub fn std_arc() {}
|
||||
|
||||
|
||||
/**
|
||||
```compile_fail,E0277
|
||||
extern crate malloc_size_of;
|
||||
|
||||
fn sizeable<T: malloc_size_of::MallocSizeOf>() {}
|
||||
|
||||
fn main() {
|
||||
sizeable::<std::rc::Rc<i32>>();
|
||||
}
|
||||
```
|
||||
*/
|
||||
pub fn rc() {}
|
||||
}
|
||||
|
||||
pub mod does_not_impl_malloc_shallow_size_of {
|
||||
/**
|
||||
```compile_fail,E0277
|
||||
extern crate malloc_size_of;
|
||||
extern crate servo_arc;
|
||||
|
||||
fn shallow_sizeable<T: malloc_size_of::MallocShallowSizeOf>() {}
|
||||
|
||||
fn main() {
|
||||
shallow_sizeable::<servo_arc::Arc<i32>>();
|
||||
}
|
||||
```
|
||||
*/
|
||||
pub fn servo_arc() {}
|
||||
|
||||
|
||||
/**
|
||||
```compile_fail,E0277
|
||||
extern crate malloc_size_of;
|
||||
|
||||
fn shallow_sizeable<T: malloc_size_of::MallocShallowSizeOf>() {}
|
||||
|
||||
fn main() {
|
||||
shallow_sizeable::<std::sync::Arc<i32>>();
|
||||
}
|
||||
```
|
||||
*/
|
||||
pub fn std_arc() {}
|
||||
|
||||
|
||||
/**
|
||||
```compile_fail,E0277
|
||||
extern crate malloc_size_of;
|
||||
|
||||
fn shallow_sizeable<T: malloc_size_of::MallocShallowSizeOf>() {}
|
||||
|
||||
fn main() {
|
||||
shallow_sizeable::<std::rc::Rc<i32>>();
|
||||
}
|
||||
```
|
||||
*/
|
||||
pub fn rc() {}
|
||||
}
|
|
@ -7,7 +7,6 @@ license = "MPL-2.0"
|
|||
[lib]
|
||||
name = "script_tests"
|
||||
path = "lib.rs"
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
euclid = "0.15"
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
* 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 euclid;
|
||||
extern crate msg;
|
||||
extern crate script;
|
||||
extern crate servo_url;
|
||||
extern crate style;
|
||||
#[cfg(test)] extern crate euclid;
|
||||
#[cfg(test)] extern crate msg;
|
||||
#[cfg(test)] extern crate script;
|
||||
#[cfg(test)] extern crate servo_url;
|
||||
#[cfg(test)] extern crate style;
|
||||
|
||||
#[cfg(test)] mod origin;
|
||||
#[cfg(all(test, target_pointer_width = "64"))] mod size_of;
|
||||
|
@ -15,3 +15,15 @@ extern crate style;
|
|||
#[cfg(test)] mod htmlareaelement;
|
||||
#[cfg(test)] mod htmlimageelement;
|
||||
|
||||
/**
|
||||
```compile_fail,E0277
|
||||
extern crate script;
|
||||
|
||||
fn cloneable<T: Clone>() {}
|
||||
|
||||
fn main() {
|
||||
cloneable::<script::test::TrustedPromise>();
|
||||
}
|
||||
```
|
||||
*/
|
||||
pub fn trustedpromise_does_not_impl_clone() {}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
[package]
|
||||
name = "compiletest_helper"
|
||||
name = "script_plugins_tests"
|
||||
version = "0.0.1"
|
||||
authors = ["The Servo Project Developers"]
|
||||
license = "MPL-2.0"
|
||||
|
||||
[lib]
|
||||
name = "compiletest_helper"
|
||||
path = "lib.rs"
|
||||
doctest = false
|
||||
test = false
|
||||
|
||||
[dependencies]
|
||||
compiletest_rs = "0.2.0"
|
||||
script_plugins = {path = "../../../components/script_plugins"}
|
63
tests/unit/script_plugins/lib.rs
Normal file
63
tests/unit/script_plugins/lib.rs
Normal file
|
@ -0,0 +1,63 @@
|
|||
/* 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/. */
|
||||
|
||||
pub mod unrooted_must_root {
|
||||
/**
|
||||
```
|
||||
#![feature(plugin)]
|
||||
#![plugin(script_plugins)]
|
||||
|
||||
#[must_root] struct Foo(i32);
|
||||
#[must_root] struct Bar(Foo);
|
||||
|
||||
fn foo1(_: &Foo) {}
|
||||
fn foo2(_: &()) -> &Foo { unimplemented!() }
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
*/
|
||||
pub fn ok() {}
|
||||
|
||||
/**
|
||||
```compile_fail
|
||||
#![feature(plugin)]
|
||||
#![plugin(script_plugins)]
|
||||
|
||||
#[must_root] struct Foo(i32);
|
||||
struct Bar(Foo);
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
*/
|
||||
pub fn struct_field() {}
|
||||
|
||||
/**
|
||||
```compile_fail
|
||||
#![feature(plugin)]
|
||||
#![plugin(script_plugins)]
|
||||
|
||||
#[must_root] struct Foo(i32);
|
||||
|
||||
fn foo1(_: Foo) {}
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
*/
|
||||
pub fn parameter() {}
|
||||
|
||||
/**
|
||||
```compile_fail
|
||||
#![feature(plugin)]
|
||||
#![plugin(script_plugins)]
|
||||
|
||||
#[must_root] struct Foo(i32);
|
||||
|
||||
fn foo2() -> Foo { unimplemented!() }
|
||||
|
||||
fn main() {}
|
||||
```
|
||||
*/
|
||||
pub fn return_type() {}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue