fix(tests): proper flag handling
This commit is contained in:
parent
cd9305288a
commit
23ec12cd00
1 changed files with 72 additions and 71 deletions
131
tests/macros.rs
131
tests/macros.rs
|
|
@ -1,12 +1,4 @@
|
||||||
use std::fs;
|
use sabry::styly;
|
||||||
|
|
||||||
use insta::{glob, Settings};
|
|
||||||
|
|
||||||
use sabry::{
|
|
||||||
buildmagic::SabryBuilder,
|
|
||||||
config::{BehavHashCollision, BehavSassModCollision, SabryConfig},
|
|
||||||
sassy, styly, usey,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub mod sass {
|
pub mod sass {
|
||||||
use sabry::sassy;
|
use sabry::sassy;
|
||||||
|
|
@ -113,70 +105,79 @@ fn syntax_contract() {
|
||||||
assert_eq!(sass::module_inline_a!(syntax), "sass");
|
assert_eq!(sass::module_inline_a!(syntax), "sass");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_config() -> SabryConfig {
|
#[cfg(test)]
|
||||||
let mut config = SabryConfig::require().unwrap();
|
#[cfg(all(feature = "procmacro", feature = "build"))]
|
||||||
config.css.bundle = Some("tests/sabry_output/bundle.css".into());
|
mod build_tests {
|
||||||
config.css.scopes = Some("tests/sabry_output/scopes".into());
|
use std::fs;
|
||||||
config.css.minify = true;
|
|
||||||
config.css.prelude = Some(vec!["tests/assets/prelude.css".into()]);
|
|
||||||
|
|
||||||
config.sass.prelude = Some(vec![
|
use insta::{glob, Settings};
|
||||||
"tests/assets/prelude.sass".into(),
|
use sabry::{usey, buildmagic::SabryBuilder, config::{BehavHashCollision, BehavSassModCollision, SabryConfig}};
|
||||||
"tests/assets/prelude.scss".into(),
|
|
||||||
]);
|
|
||||||
config.sass.intermediate_dir = "tests/sabry_intermediate".into();
|
|
||||||
config.sass.scanroot = "tests".into();
|
|
||||||
config.sass.module_name_collision = BehavSassModCollision::Merge;
|
|
||||||
|
|
||||||
config.hash.collision = BehavHashCollision::Error;
|
fn gen_config() -> SabryConfig {
|
||||||
config.hash.size = 16;
|
let mut config = SabryConfig::require().unwrap();
|
||||||
config.hash.use_code_size = true;
|
config.css.bundle = Some("tests/sabry_output/bundle.css".into());
|
||||||
config.hash.use_code_text = true;
|
config.css.scopes = Some("tests/sabry_output/scopes".into());
|
||||||
config.hash.use_item_names = true;
|
config.css.minify = true;
|
||||||
config.hash.use_scope_name = true;
|
config.css.prelude = Some(vec!["tests/assets/prelude.css".into()]);
|
||||||
|
|
||||||
config.lightningcss.targets.android = Some("10".into());
|
config.sass.prelude = Some(vec![
|
||||||
config.lightningcss.targets.chrome = Some("100".into());
|
"tests/assets/prelude.sass".into(),
|
||||||
config.lightningcss.targets.edge = Some("80".into());
|
"tests/assets/prelude.scss".into(),
|
||||||
config.lightningcss.targets.firefox = Some("100".into());
|
]);
|
||||||
config.lightningcss.targets.ie = Some("8".into());
|
config.sass.intermediate_dir = "tests/sabry_intermediate".into();
|
||||||
config.lightningcss.targets.ios_saf = Some("13.2".into());
|
config.sass.scanroot = "tests".into();
|
||||||
config.lightningcss.targets.opera = Some("80".into());
|
config.sass.module_name_collision = BehavSassModCollision::Merge;
|
||||||
config.lightningcss.targets.safari = Some("11".into());
|
|
||||||
config.lightningcss.targets.samsung = Some("80".into());
|
|
||||||
|
|
||||||
config
|
config.hash.collision = BehavHashCollision::Error;
|
||||||
}
|
config.hash.size = 16;
|
||||||
|
config.hash.use_code_size = true;
|
||||||
|
config.hash.use_code_text = true;
|
||||||
|
config.hash.use_item_names = true;
|
||||||
|
config.hash.use_scope_name = true;
|
||||||
|
|
||||||
fn gen_builder() -> SabryBuilder {
|
config.lightningcss.targets.android = Some("10".into());
|
||||||
let config = gen_config();
|
config.lightningcss.targets.chrome = Some("100".into());
|
||||||
let builder = SabryBuilder::new(config);
|
config.lightningcss.targets.edge = Some("80".into());
|
||||||
|
config.lightningcss.targets.firefox = Some("100".into());
|
||||||
|
config.lightningcss.targets.ie = Some("8".into());
|
||||||
|
config.lightningcss.targets.ios_saf = Some("13.2".into());
|
||||||
|
config.lightningcss.targets.opera = Some("80".into());
|
||||||
|
config.lightningcss.targets.safari = Some("11".into());
|
||||||
|
config.lightningcss.targets.samsung = Some("80".into());
|
||||||
|
|
||||||
builder
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
fn gen_builder() -> SabryBuilder {
|
||||||
fn compilation_with_buildy() {
|
let config = gen_config();
|
||||||
let mut builder = gen_builder();
|
let builder = SabryBuilder::new(config);
|
||||||
builder
|
|
||||||
.build(usey!(
|
|
||||||
sass::mixins_a!(),
|
|
||||||
sass::module_a!(),
|
|
||||||
scss::mixins_c!(),
|
|
||||||
scss::module_c!()
|
|
||||||
))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
glob!("sabry_output/**/*.css", |path| {
|
builder
|
||||||
let generated = fs::read_to_string(path).unwrap();
|
}
|
||||||
|
|
||||||
let mut settings = Settings::clone_current();
|
#[test]
|
||||||
settings.set_snapshot_path("sabry_output_snapshots");
|
fn compilation_with_buildy() {
|
||||||
settings.set_prepend_module_to_snapshot(false);
|
let mut builder = gen_builder();
|
||||||
settings.set_omit_expression(true);
|
builder
|
||||||
settings.remove_info();
|
.build(usey!(
|
||||||
settings.bind(|| {
|
super::sass::mixins_a!(),
|
||||||
insta::assert_snapshot!(generated);
|
super::sass::module_a!(),
|
||||||
|
super::scss::mixins_c!(),
|
||||||
|
super::scss::module_c!()
|
||||||
|
))
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
glob!("sabry_output/**/*.css", |path| {
|
||||||
|
let generated = fs::read_to_string(path).unwrap();
|
||||||
|
|
||||||
|
let mut settings = Settings::clone_current();
|
||||||
|
settings.set_snapshot_path("sabry_output_snapshots");
|
||||||
|
settings.set_prepend_module_to_snapshot(false);
|
||||||
|
settings.set_omit_expression(true);
|
||||||
|
settings.remove_info();
|
||||||
|
settings.bind(|| {
|
||||||
|
insta::assert_snapshot!(generated);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue