mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Use size_of_test! macro in style and stylo tests.
This commit is contained in:
parent
864f5509d8
commit
5e60865d19
8 changed files with 12 additions and 34 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -2872,6 +2872,7 @@ dependencies = [
|
||||||
"servo_atoms 0.0.1",
|
"servo_atoms 0.0.1",
|
||||||
"servo_config 0.0.1",
|
"servo_config 0.0.1",
|
||||||
"servo_url 0.0.1",
|
"servo_url 0.0.1",
|
||||||
|
"size_of_test 0.0.1",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
]
|
]
|
||||||
|
@ -2901,6 +2902,7 @@ dependencies = [
|
||||||
"libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
"libc 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"selectors 0.18.0",
|
"selectors 0.18.0",
|
||||||
|
"size_of_test 0.0.1",
|
||||||
"style 0.0.1",
|
"style 0.0.1",
|
||||||
"style_traits 0.0.1",
|
"style_traits 0.0.1",
|
||||||
]
|
]
|
||||||
|
|
|
@ -2802,30 +2802,6 @@ macro_rules! longhand_properties_idents {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Testing function to check the size of a PropertyDeclaration. We implement
|
|
||||||
/// this here so that the code can be used by both servo and stylo unit tests.
|
|
||||||
/// This is important because structs can have different sizes in stylo and
|
|
||||||
/// servo.
|
|
||||||
#[cfg(feature = "testing")]
|
|
||||||
pub fn test_size_of_property_declaration() {
|
|
||||||
use std::mem::size_of;
|
|
||||||
|
|
||||||
let old = 32;
|
|
||||||
let new = size_of::<PropertyDeclaration>();
|
|
||||||
if new < old {
|
|
||||||
panic!("Your changes have decreased the stack size of PropertyDeclaration enum from {} to {}. \
|
|
||||||
Good work! Please update the size in components/style/properties/properties.mako.rs.",
|
|
||||||
old, new)
|
|
||||||
} else if new > old {
|
|
||||||
panic!("Your changes have increased the stack size of PropertyDeclaration enum from {} to {}. \
|
|
||||||
These enum is present in large quantities in the style, and increasing the size \
|
|
||||||
may negatively affect style system performance. Please consider using `boxed=\"True\"` in \
|
|
||||||
the longhand If you feel that the increase is necessary, update to the new size in \
|
|
||||||
components/style/properties/properties.mako.rs.",
|
|
||||||
old, new)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Testing function to check the size of all SpecifiedValues.
|
/// Testing function to check the size of all SpecifiedValues.
|
||||||
#[cfg(feature = "testing")]
|
#[cfg(feature = "testing")]
|
||||||
pub fn test_size_of_specified_values() {
|
pub fn test_size_of_specified_values() {
|
||||||
|
|
|
@ -24,6 +24,7 @@ rustc-serialize = "0.3"
|
||||||
selectors = {path = "../../../components/selectors"}
|
selectors = {path = "../../../components/selectors"}
|
||||||
servo_atoms = {path = "../../../components/atoms"}
|
servo_atoms = {path = "../../../components/atoms"}
|
||||||
servo_config = {path = "../../../components/config"}
|
servo_config = {path = "../../../components/config"}
|
||||||
|
servo_url = {path = "../../../components/url"}
|
||||||
|
size_of_test = {path = "../../../components/size_of_test"}
|
||||||
style = {path = "../../../components/style"}
|
style = {path = "../../../components/style"}
|
||||||
style_traits = {path = "../../../components/style_traits"}
|
style_traits = {path = "../../../components/style_traits"}
|
||||||
servo_url = {path = "../../../components/url"}
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ extern crate selectors;
|
||||||
extern crate servo_atoms;
|
extern crate servo_atoms;
|
||||||
extern crate servo_config;
|
extern crate servo_config;
|
||||||
extern crate servo_url;
|
extern crate servo_url;
|
||||||
|
#[macro_use] extern crate size_of_test;
|
||||||
extern crate style;
|
extern crate style;
|
||||||
extern crate style_traits;
|
extern crate style_traits;
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
* 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/. */
|
||||||
|
|
||||||
#[test]
|
use style::properties;
|
||||||
fn size_of_property_declaration() {
|
|
||||||
::style::properties::test_size_of_property_declaration();
|
size_of_test!(test_size_of_property_declaration, properties::PropertyDeclaration, 32);
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn size_of_specified_values() {
|
fn size_of_specified_values() {
|
||||||
|
|
|
@ -19,9 +19,10 @@ atomic_refcell = "0.1"
|
||||||
cssparser = "0.13.3"
|
cssparser = "0.13.3"
|
||||||
env_logger = "0.4"
|
env_logger = "0.4"
|
||||||
euclid = "0.11"
|
euclid = "0.11"
|
||||||
|
geckoservo = {path = "../../../ports/geckolib"}
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
log = {version = "0.3.5", features = ["release_max_level_info"]}
|
log = {version = "0.3.5", features = ["release_max_level_info"]}
|
||||||
selectors = {path = "../../../components/selectors", features = ["gecko_like_types"]}
|
selectors = {path = "../../../components/selectors", features = ["gecko_like_types"]}
|
||||||
|
size_of_test = {path = "../../../components/size_of_test"}
|
||||||
style_traits = {path = "../../../components/style_traits"}
|
style_traits = {path = "../../../components/style_traits"}
|
||||||
geckoservo = {path = "../../../ports/geckolib"}
|
|
||||||
style = {path = "../../../components/style", features = ["gecko"]}
|
style = {path = "../../../components/style", features = ["gecko"]}
|
||||||
|
|
|
@ -8,6 +8,7 @@ extern crate env_logger;
|
||||||
extern crate geckoservo;
|
extern crate geckoservo;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
extern crate selectors;
|
extern crate selectors;
|
||||||
|
#[macro_use] extern crate size_of_test;
|
||||||
#[macro_use] extern crate style;
|
#[macro_use] extern crate style;
|
||||||
extern crate style_traits;
|
extern crate style_traits;
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,7 @@ fn size_of_selectors_dummy_types() {
|
||||||
assert_eq!(align_of::<dummies::Atom>(), align_of::<style::Atom>());
|
assert_eq!(align_of::<dummies::Atom>(), align_of::<style::Atom>());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
size_of_test!(test_size_of_property_declaration, style::properties::PropertyDeclaration, 32);
|
||||||
fn size_of_property_declaration() {
|
|
||||||
::style::properties::test_size_of_property_declaration();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn size_of_specified_values() {
|
fn size_of_specified_values() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue