EmbarkStudios/rust-gpu

We should replace `rustc_codegen_spirv::linker::test` unit tests with compiletest ones.

eddyb opened this issue · 0 comments

eddyb commented

The main unique aspect of these tests is they take SPIR-V assembly as an input, not Rust code, e.g.:

#[test]
fn unresolved_symbol() {
let a = assemble_spirv(
r#"OpCapability Linkage
OpDecorate %1 LinkageAttributes "foo" Import
%2 = OpTypeFloat 32
%1 = OpVariable %2 Uniform"#,
);
let b = assemble_spirv("OpCapability Linkage");
let result = assemble_and_link(&[&a, &b]);
assert_eq!(
result.err().as_deref(),
Some("error: Unresolved symbol \"foo\"")
);
}

However, we might be able to use module_asm! to feed SPIR-V assembly into the compilation, and compiletest does have the ability to introduce dependencies to link against. The main weirdness we might need to deal with is all the definitions from e.g. core that we don't use, but DCE might be able to clean that up.

(Or we could even use e.g. extern "C" FFI in Rust code to describe such situations without module_asm! at all!)

If we can do this transition, we wouldn't have to deal with weird artificial compiler sessions and e.g.: