fix tests

This commit is contained in:
Robin Appelman 2026-07-11 21:20:47 +02:00
commit 8513568506
11 changed files with 394 additions and 424 deletions

View file

@ -24,12 +24,12 @@ fn test_serde(path: &str) {
let raw = read_to_string(path).unwrap();
match from_str(&raw) {
Ok(result) => {
insta::assert_ron_snapshot!(path, result);
insta::assert_json_snapshot!(path, result);
if let Material::Patch(patch) = result {
let patched = patch
.resolve(|path| read_to_string(path).map_err(LoaderError::from))
.unwrap();
insta::assert_ron_snapshot!(format!("{}_resolved", path), patched);
insta::assert_json_snapshot!(format!("{}_resolved", path), patched);
}
}
Err(e) => {

View file

@ -2,35 +2,44 @@
source: tests/parse.rs
expression: result
---
worldvertextransition(WorldVertexTransitionMaterial(
r#$basetexture: "cp_mountainlab/nature/rockwall001",
r#$basetexture2: "cp_mountainlab/nature/grass001",
r#$blendmodulatetexture: Some("nature/grass_blendmask"),
r#$decal: false,
r#$detail: None,
r#$surfaceprop: Some("dirt"),
r#$basetexturetransform: "center 0.5 0.5 scale 1 1 rotate 0 translate 0 0",
r#$color: Vec3((1.0, 1.0, 1.0)),
r#$decalscale: 1.0,
r#$detailscale: Vec2((4.0, 4.0)),
r#$detailblendfactor: 1.0,
r#$detailblendmode: 1,
r#$modelmaterial: None,
r#$pointsamplemagfilter: false,
r#$seamless_scale: 1.0,
r#$alpha: 1.0,
r#$alphatest: false,
r#$alphatestreference: 1.0,
r#$distancealpha: false,
r#$nocull: false,
r#$translucent: false,
r#$bumpmap: Some("nature/rockwall009_height-ssbump"),
r#$bumpmap2: None,
r#$lightwarptexture: None,
r#$selfillum: false,
r#$ssbump: true,
r#$envmap: None,
r#$phong: 0.0,
r#$nofog: false,
r#$ignorez: false,
))
{
"worldvertextransition": {
"$basetexture": "cp_mountainlab/nature/rockwall001",
"$basetexture2": "cp_mountainlab/nature/grass001",
"$blendmodulatetexture": "nature/grass_blendmask",
"$decal": false,
"$detail": null,
"$surfaceprop": "dirt",
"$basetexturetransform": "center 0.5 0.5 scale 1 1 rotate 0 translate 0 0",
"$color": [
1.0,
1.0,
1.0
],
"$decalscale": 1.0,
"$detailscale": [
4.0,
4.0
],
"$detailblendfactor": 1.0,
"$detailblendmode": 1,
"$modelmaterial": null,
"$pointsamplemagfilter": false,
"$seamless_scale": 1.0,
"$alpha": 1.0,
"$alphatest": false,
"$alphatestreference": 1.0,
"$distancealpha": false,
"$nocull": false,
"$translucent": false,
"$bumpmap": "nature/rockwall009_height-ssbump",
"$bumpmap2": null,
"$lightwarptexture": null,
"$selfillum": false,
"$ssbump": true,
"$envmap": null,
"$phong": 0.0,
"$nofog": false,
"$ignorez": false
}
}

View file

@ -2,32 +2,41 @@
source: tests/parse.rs
expression: result
---
lightmappedgeneric(LightMappedGenericMaterial(
r#$basetexture: "cp_mountainlab/concrete/concretefloor003",
r#$decal: false,
r#$detail: Some("overlays/detail001"),
r#$surfaceprop: None,
r#$basetexturetransform: "center 0.5 0.5 scale 1 1 rotate 0 translate 0 0",
r#$color: Vec3((1.0, 1.0, 1.0)),
r#$decalscale: 1.0,
r#$detailscale: Vec2((1.9, 1.9)),
r#$detailblendfactor: 1.0,
r#$detailblendmode: 0,
r#$modelmaterial: None,
r#$pointsamplemagfilter: false,
r#$seamless_scale: 1.0,
r#$alpha: 1.0,
r#$alphatest: false,
r#$alphatestreference: 1.0,
r#$distancealpha: false,
r#$nocull: false,
r#$translucent: false,
r#$bumpmap: Some("concrete/concretefloor007b_height-ssbump"),
r#$lightwarptexture: None,
r#$selfillum: false,
r#$ssbump: true,
r#$envmap: None,
r#$phong: 0.0,
r#$nofog: false,
r#$ignorez: false,
))
{
"lightmappedgeneric": {
"$basetexture": "cp_mountainlab/concrete/concretefloor003",
"$decal": false,
"$detail": "overlays/detail001",
"$surfaceprop": null,
"$basetexturetransform": "center 0.5 0.5 scale 1 1 rotate 0 translate 0 0",
"$color": [
1.0,
1.0,
1.0
],
"$decalscale": 1.0,
"$detailscale": [
1.9,
1.9
],
"$detailblendfactor": 1.0,
"$detailblendmode": 0,
"$modelmaterial": null,
"$pointsamplemagfilter": false,
"$seamless_scale": 1.0,
"$alpha": 1.0,
"$alphatest": false,
"$alphatestreference": 1.0,
"$distancealpha": false,
"$nocull": false,
"$translucent": false,
"$bumpmap": "concrete/concretefloor007b_height-ssbump",
"$lightwarptexture": null,
"$selfillum": false,
"$ssbump": true,
"$envmap": null,
"$phong": 0.0,
"$nofog": false,
"$ignorez": false
}
}

View file

@ -2,31 +2,44 @@
source: tests/parse.rs
expression: result
---
vertexlitgeneric(VertexLitGenericMaterial(
r#$basetexture: Some("models/props_trainyard/handrail128_skin2"),
r#$detail: None,
r#$decaltexture: None,
r#$color2: Vec3((1.0, 1.0, 1.0)),
r#$basetexturetransform: "center 0.5 0.5 scale 1 1 rotate 0 translate 0 0",
r#$color: Vec3((1.0, 1.0, 1.0)),
r#$decalscale: Vec2((4.0, 4.0)),
r#$detailblendfactor: 1.0,
r#$detailblendmode: 1,
r#$modelmaterial: None,
r#$pointsamplemagfilter: false,
r#$seamless_scale: 1.0,
r#$alpha: 1.0,
r#$alphatest: false,
r#$alphatestreference: 1.0,
r#$distancealpha: false,
r#$nocull: false,
r#$translucent: false,
r#$bumpmap: None,
r#$lightwarptexture: None,
r#$selfillum: false,
r#$ssbump: false,
r#$envmap: None,
r#$phong: 0.0,
r#$nofog: false,
r#$ignorez: false,
))
{
"vertexlitgeneric": {
"$basetexture": "models/props_trainyard/handrail128_skin2",
"$detail": null,
"$decaltexture": null,
"$color2": [
1.0,
1.0,
1.0
],
"$basetexturetransform": "center 0.5 0.5 scale 1 1 rotate 0 translate 0 0",
"$color": [
1.0,
1.0,
1.0
],
"$decalscale": [
4.0,
4.0
],
"$detailblendfactor": 1.0,
"$detailblendmode": 1,
"$modelmaterial": null,
"$pointsamplemagfilter": false,
"$seamless_scale": 1.0,
"$alpha": 1.0,
"$alphatest": false,
"$alphatestreference": 1.0,
"$distancealpha": false,
"$nocull": false,
"$translucent": false,
"$bumpmap": null,
"$lightwarptexture": null,
"$selfillum": false,
"$ssbump": false,
"$envmap": null,
"$phong": 0.0,
"$nofog": false,
"$ignorez": false
}
}

View file

@ -2,20 +2,26 @@
source: tests/parse.rs
expression: result
---
unlitgeneric(UnlitGenericMaterial(
r#$basetexture: Some("vgui/pve/mvm_backpack"),
r#$surfaceprop: None,
r#$model: false,
r#$color: Vec3((1.0, 1.0, 1.0)),
r#$alpha: 1.0,
r#$alphatest: false,
r#$alphatestreference: 1.0,
r#$nocull: false,
r#$translucent: true,
r#$bumpmap: None,
r#$ignorez: true,
r#$nofog: false,
r#$receiveflashlight: false,
singlepassflashlight: false,
r#$no_fullbright: true,
))
{
"unlitgeneric": {
"$basetexture": "vgui/pve/mvm_backpack",
"$surfaceprop": null,
"$model": false,
"$color": [
1.0,
1.0,
1.0
],
"$alpha": 1.0,
"$alphatest": false,
"$alphatestreference": 1.0,
"$nocull": false,
"$translucent": true,
"$bumpmap": null,
"$ignorez": true,
"$nofog": false,
"$receiveflashlight": false,
"singlepassflashlight": false,
"$no_fullbright": true
}
}

View file

@ -2,9 +2,11 @@
source: tests/parse.rs
expression: result
---
patch(PatchMaterial(
include: "tests/data/concretefloor003.vmt",
replace: {
"$ssbump": "0",
},
))
{
"patch": {
"include": "tests/data/concretefloor003.vmt",
"replace": {
"$ssbump": "0"
}
}
}

View file

@ -2,32 +2,41 @@
source: tests/parse.rs
expression: patched
---
lightmappedgeneric(LightMappedGenericMaterial(
r#$basetexture: "cp_mountainlab/concrete/concretefloor003",
r#$decal: false,
r#$detail: Some("overlays/detail001"),
r#$surfaceprop: None,
r#$basetexturetransform: "center 0.5 0.5 scale 1 1 rotate 0 translate 0 0",
r#$color: Vec3((1.0, 1.0, 1.0)),
r#$decalscale: 1.0,
r#$detailscale: Vec2((1.9, 1.9)),
r#$detailblendfactor: 1.0,
r#$detailblendmode: 0,
r#$modelmaterial: None,
r#$pointsamplemagfilter: false,
r#$seamless_scale: 1.0,
r#$alpha: 1.0,
r#$alphatest: false,
r#$alphatestreference: 1.0,
r#$distancealpha: false,
r#$nocull: false,
r#$translucent: false,
r#$bumpmap: Some("concrete/concretefloor007b_height-ssbump"),
r#$lightwarptexture: None,
r#$selfillum: false,
r#$ssbump: false,
r#$envmap: None,
r#$phong: 0.0,
r#$nofog: false,
r#$ignorez: false,
))
{
"lightmappedgeneric": {
"$basetexture": "cp_mountainlab/concrete/concretefloor003",
"$decal": false,
"$detail": "overlays/detail001",
"$surfaceprop": null,
"$basetexturetransform": "center 0.5 0.5 scale 1 1 rotate 0 translate 0 0",
"$color": [
1.0,
1.0,
1.0
],
"$decalscale": 1.0,
"$detailscale": [
1.9,
1.9
],
"$detailblendfactor": 1.0,
"$detailblendmode": 0,
"$modelmaterial": null,
"$pointsamplemagfilter": false,
"$seamless_scale": 1.0,
"$alpha": 1.0,
"$alphatest": false,
"$alphatestreference": 1.0,
"$distancealpha": false,
"$nocull": false,
"$translucent": false,
"$bumpmap": "concrete/concretefloor007b_height-ssbump",
"$lightwarptexture": null,
"$selfillum": false,
"$ssbump": false,
"$envmap": null,
"$phong": 0.0,
"$nofog": false,
"$ignorez": false
}
}

View file

@ -2,8 +2,16 @@
source: tests/parse.rs
expression: result
---
subrect(SubRectMaterial(
r#$material: "decals/decals_mod2x",
r#$pos: Vec2((64.0, 0.0)),
r#$size: Vec2((64.0, 64.0)),
))
{
"subrect": {
"$material": "decals/decals_mod2x",
"$pos": [
64.0,
0.0
],
"$size": [
64.0,
64.0
]
}
}

View file

@ -2,20 +2,26 @@
source: tests/parse.rs
expression: result
---
water(WaterMaterial(
r#$basetexture: Some("swamp/water/water_murky"),
r#$abovewater: true,
r#$bottommaterial: Some("swamp/water/water_murky_beneath.vmt"),
r#$underwaterover: None,
r#$bumpmap: None,
r#$normalmap: Some("water/tfwater001_normal"),
r#$dudvframe: 0,
r#$bumpframe: 0,
r#$bumptransform: "center 0.5 0.5 scale 1 1 rotate 0 translate 0 0",
r#$flashlighttint: 1.0,
r#$fogenable: true,
r#$fogcolor: Vec3((35.0, 32.0, 20.0)),
r#$fogstart: 0.0,
r#$fogend: 170.0,
r#$lightmapwaterfog: false,
))
{
"water": {
"$basetexture": "swamp/water/water_murky",
"$abovewater": true,
"$bottommaterial": "swamp/water/water_murky_beneath.vmt",
"$underwaterover": null,
"$bumpmap": null,
"$normalmap": "water/tfwater001_normal",
"$dudvframe": 0,
"$bumpframe": 0,
"$bumptransform": "center 0.5 0.5 scale 1 1 rotate 0 translate 0 0",
"$flashlighttint": 1.0,
"$fogenable": true,
"$fogcolor": [
35.0,
32.0,
20.0
],
"$fogstart": 0.0,
"$fogend": 170.0,
"$lightmapwaterfog": false
}
}