test: add test for shader preprocess

This commit is contained in:
chyyran 2023-02-08 03:28:27 -05:00
parent 85497e47c1
commit 2128945c06
3 changed files with 25 additions and 0 deletions

2
Cargo.lock generated
View file

@ -789,7 +789,9 @@ name = "librashader-preprocess"
version = "0.1.0-beta.16"
dependencies = [
"encoding_rs",
"glob",
"librashader-common",
"librashader-presets",
"nom",
"rustc-hash",
"thiserror",

View file

@ -21,3 +21,7 @@ encoding_rs = "0.8.31"
[features]
default = [ "line_directives" ]
line_directives = []
[dev-dependencies]
glob = "0.3.1"
librashader-presets = { version = "0.1.0-beta.16", path = "../librashader-presets"}

View file

@ -0,0 +1,19 @@
use glob::glob;
use librashader_preprocess::{PreprocessError, ShaderSource};
use librashader_presets::ShaderPreset;
#[test]
fn preprocess_all_slang_presets_parsed() {
for entry in glob("../test/slang-shaders/**/*.slangp").unwrap() {
if let Ok(path) = entry {
if let Ok(preset) = ShaderPreset::try_parse(&path) {
for shader in preset.shaders {
ShaderSource::load(&shader.name).expect(&format!(
"Failed to preprocess shader {} from preset {}",
shader.name.display(),
path.display()
));
}
}
}
}
}