Skip to content

Commit ab44ffc

Browse files
committed
Move tests from spirv-builder to their own crate
1 parent 72e1373 commit ab44ffc

File tree

9 files changed

+36
-8
lines changed

9 files changed

+36
-8
lines changed

.github/workflows/clippy.sh

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ clippy crates/spirv-tools-sys
3232
clippy crates/spirv-tools
3333
clippy crates/rustc_codegen_spirv
3434
clippy crates/spirv-builder
35+
clippy crates/testsuite
3536

3637
# Examples
3738

.github/workflows/test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ cargo_test crates/spirv-tools-sys
4141
cargo_test crates/spirv-tools
4242
cargo_test crates/rustc_codegen_spirv
4343
cargo_test crates/spirv-builder
44+
cargo_test crates/testsuite
4445

4546
# Examples
4647
# See: https://github.com/EmbarkStudios/rust-gpu/issues/84

Cargo.lock

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ members = [
1010
"crates/spirv-std",
1111
"crates/spirv-tools",
1212
"crates/spirv-tools-sys",
13+
"crates/testsuite",
1314
]
1415

1516
[patch.crates-io]

crates/spirv-builder/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#[cfg(test)]
2-
mod test;
3-
41
mod depfile;
52

63
use raw_string::{RawStr, RawString};

crates/testsuite/Cargo.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "testsuite"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
spirv-builder = { path = "../spirv-builder", default-features = false }
10+
rustc_codegen_spirv = { path = "../rustc_codegen_spirv", default-features = false }
11+
lazy_static = "1.4"
12+
pretty_assertions = "0.6"
13+
cfg-if = "0.1.10"

crates/spirv-builder/src/test/mod.rs renamed to crates/testsuite/src/lib.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
mod basic;
2-
mod control_flow;
1+
cfg_if::cfg_if! {
2+
if #[cfg(test)] {
3+
mod basic;
4+
mod control_flow;
5+
}
6+
}
37

48
use lazy_static::lazy_static;
59
use rustc_codegen_spirv::rspirv;
@@ -74,7 +78,7 @@ fn setup(src: &str) -> Result<PathBuf, Box<dyn Error>> {
7478

7579
fn build(src: &str) -> PathBuf {
7680
let project = setup(src).expect("Failed to set up project");
77-
crate::SpirvBuilder::new(&project)
81+
spirv_builder::SpirvBuilder::new(&project)
7882
.print_metadata(false)
7983
.build()
8084
.expect("Failed to build test")
@@ -87,7 +91,7 @@ fn read_module(path: &Path) -> Result<rspirv::dr::Module, Box<dyn Error>> {
8791
Ok(loader.module())
8892
}
8993

90-
fn val(src: &str) {
94+
pub fn val(src: &str) {
9195
let _lock = global_lock();
9296
// spirv-val is included in building
9397
build(src);
@@ -109,7 +113,7 @@ fn assert_str_eq(expected: &str, result: &str) {
109113
pretty_assertions::assert_eq!(PrettyString(&expected), PrettyString(&result))
110114
}
111115

112-
fn dis_fn(src: &str, func: &str, expect: &str) {
116+
pub fn dis_fn(src: &str, func: &str, expect: &str) {
113117
let _lock = global_lock();
114118
let module = read_module(&build(src)).unwrap();
115119
let id = module

0 commit comments

Comments
 (0)