mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
move specified values size testing entirely into stylo_tests
This change means that stylo_tests doesn't depend on a version of the style crate with the `testing` feature defined.
This commit is contained in:
parent
e962ac365b
commit
018968877a
6 changed files with 54 additions and 48 deletions
|
@ -3414,7 +3414,7 @@ macro_rules! css_properties_accessors {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! longhand_properties_idents {
|
||||
($macro_name: ident) => {
|
||||
$macro_name! {
|
||||
|
@ -3424,39 +3424,3 @@ macro_rules! longhand_properties_idents {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Testing function to check the size of all SpecifiedValues.
|
||||
#[cfg(feature = "testing")]
|
||||
pub fn test_size_of_specified_values() {
|
||||
use std::mem::size_of;
|
||||
let threshold = 24;
|
||||
|
||||
let mut longhands = vec![];
|
||||
% for property in data.longhands:
|
||||
longhands.push(("${property.name}",
|
||||
size_of::<longhands::${property.ident}::SpecifiedValue>(),
|
||||
${"true" if property.boxed else "false"}));
|
||||
% endfor
|
||||
|
||||
let mut failing_messages = vec![];
|
||||
|
||||
for specified_value in longhands {
|
||||
if specified_value.1 > threshold && !specified_value.2 {
|
||||
failing_messages.push(
|
||||
format!("Your changes have increased the size of {} SpecifiedValue to {}. The threshold is \
|
||||
currently {}. SpecifiedValues affect size of PropertyDeclaration enum and \
|
||||
increasing the size may negative affect style system performance. Please consider \
|
||||
using `boxed=\"True\"` in this longhand.",
|
||||
specified_value.0, specified_value.1, threshold));
|
||||
} else if specified_value.1 <= threshold && specified_value.2 {
|
||||
failing_messages.push(
|
||||
format!("Your changes have decreased the size of {} SpecifiedValue to {}. Good work! \
|
||||
The threshold is currently {}. Please consider removing `boxed=\"True\"` from this longhand.",
|
||||
specified_value.0, specified_value.1, threshold));
|
||||
}
|
||||
}
|
||||
|
||||
if !failing_messages.is_empty() {
|
||||
panic!("{}", failing_messages.join("\n\n"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue