[spv-out] Add initial Rosetta test (#181)

* [spv-out] Add initial Rosetta test

For now just check that spv-out succeeds

* [spv-out] Check spv output has len > 0
This commit is contained in:
Pelle Johnsen
2020-09-10 06:32:02 +02:00
committed by GitHub
parent e1e116537e
commit 2fa8eb596d
2 changed files with 20 additions and 0 deletions

View File

@@ -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::*;

View File

@@ -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")
}