mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Add a snapshot for parsing spirv input
This commit is contained in:
committed by
Dzmitry Malyshau
parent
cf0a86afd4
commit
5b94ecd9b2
@@ -16,8 +16,6 @@ mod error;
|
||||
mod flow;
|
||||
mod function;
|
||||
mod image;
|
||||
#[cfg(all(test, feature = "serialize"))]
|
||||
mod rosetta;
|
||||
|
||||
use convert::*;
|
||||
use error::Error;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
use std::{fs, path::Path};
|
||||
|
||||
const TEST_PATH: &str = "test-data";
|
||||
|
||||
fn rosetta_test(file_name: &str) {
|
||||
if true {
|
||||
return; //TODO: fix this test
|
||||
}
|
||||
let file_path = Path::new(TEST_PATH).join(file_name);
|
||||
let input = fs::read(&file_path).unwrap();
|
||||
|
||||
let module = super::parse_u8_slice(&input, &Default::default()).unwrap();
|
||||
let output = ron::ser::to_string_pretty(&module, Default::default()).unwrap();
|
||||
|
||||
let expected = fs::read_to_string(file_path.with_extension("expected.ron")).unwrap();
|
||||
|
||||
difference::assert_diff!(output.as_str(), expected.as_str(), "", 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn simple() {
|
||||
rosetta_test("simple/simple.spv")
|
||||
}
|
||||
BIN
tests/in/shadow.spv
Normal file
BIN
tests/in/shadow.spv
Normal file
Binary file not shown.
1150
tests/out/shadow.ron.snap
Normal file
1150
tests/out/shadow.ron.snap
Normal file
File diff suppressed because it is too large
Load Diff
@@ -208,3 +208,28 @@ fn convert_wgsl_shadow() {
|
||||
fn convert_wgsl_texture_array() {
|
||||
convert_wgsl("texture-array", Language::SPIRV);
|
||||
}
|
||||
|
||||
#[cfg(feature = "spv-in")]
|
||||
fn convert_spv(name: &str) {
|
||||
let module = naga::front::spv::parse_u8_slice(
|
||||
&std::fs::read(format!("tests/in/{}{}", name, ".spv")).expect("Couldn't find spv file"),
|
||||
&Default::default(),
|
||||
)
|
||||
.unwrap();
|
||||
naga::proc::Validator::new().validate(&module).unwrap();
|
||||
|
||||
#[cfg(feature = "serialize")]
|
||||
{
|
||||
let config = ron::ser::PrettyConfig::default();
|
||||
let output = ron::ser::to_string_pretty(&module, config).unwrap();
|
||||
with_snapshot_settings(|| {
|
||||
insta::assert_snapshot!(format!("{}.ron", name), output);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "spv-in")]
|
||||
#[test]
|
||||
fn convert_spv_shadow() {
|
||||
convert_spv("shadow");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user