diff --git a/src/back/spv/mod.rs b/src/back/spv/mod.rs index 15f1598357..6709e59ee4 100644 --- a/src/back/spv/mod.rs +++ b/src/back/spv/mod.rs @@ -9,6 +9,9 @@ mod test_framework; #[cfg(test)] mod layout_tests; +#[cfg(all(test, feature = "deserialize"))] +mod rosetta_tests; + pub use writer::Writer; use spirv::*; diff --git a/src/back/spv/rosetta_tests.rs b/src/back/spv/rosetta_tests.rs new file mode 100644 index 0000000000..4552ca13ba --- /dev/null +++ b/src/back/spv/rosetta_tests.rs @@ -0,0 +1,17 @@ +use std::{fs, path::Path}; + +const TEST_PATH: &str = "test-data"; + +fn rosetta_test(file_name: &str) { + let test_dir = Path::new(TEST_PATH); + let input = fs::read_to_string(test_dir.join(file_name)).unwrap(); + let module: crate::Module = ron::de::from_str(&input).unwrap(); + + let spv = super::Writer::new(&module.header, super::WriterFlags::NONE).write(&module); + assert!(spv.len() > 0, "spv.len() > 0"); +} + +#[test] +fn simple() { + rosetta_test("simple/simple.expected.ron") +}