mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-21 22:34:34 +00:00
Don't fail subsequent tests if one panics
This commit is contained in:
parent
2a19fc1cb7
commit
5a7aabe836
@ -5,7 +5,7 @@ use lazy_static::lazy_static;
|
||||
use rustc_codegen_spirv::rspirv;
|
||||
use std::error::Error;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Mutex;
|
||||
use std::sync::{Mutex, MutexGuard};
|
||||
|
||||
// https://github.com/colin-kiegel/rust-pretty-assertions/issues/24
|
||||
#[derive(PartialEq, Eq)]
|
||||
@ -25,6 +25,14 @@ lazy_static! {
|
||||
static ref GLOBAL_MUTEX: Mutex<()> = Mutex::new(());
|
||||
}
|
||||
|
||||
fn global_lock() -> MutexGuard<'static, ()> {
|
||||
match GLOBAL_MUTEX.lock() {
|
||||
Ok(guard) => guard,
|
||||
// we don't care about poison - a previous test may have paniced, but that's okay
|
||||
Err(poisoned) => poisoned.into_inner(),
|
||||
}
|
||||
}
|
||||
|
||||
static CARGO_TOML: &str = r#"[package]
|
||||
name = "test-project"
|
||||
version = "0.1.0"
|
||||
@ -80,7 +88,7 @@ fn read_module(path: &Path) -> Result<rspirv::dr::Module, Box<dyn Error>> {
|
||||
}
|
||||
|
||||
fn val(src: &str) {
|
||||
let _lock = GLOBAL_MUTEX.lock().unwrap();
|
||||
let _lock = global_lock();
|
||||
// spirv-val is included in building
|
||||
build(src);
|
||||
}
|
||||
@ -102,7 +110,7 @@ fn assert_str_eq(expected: &str, result: &str) {
|
||||
}
|
||||
|
||||
fn dis_fn(src: &str, func: &str, expect: &str) {
|
||||
let _lock = GLOBAL_MUTEX.lock().unwrap();
|
||||
let _lock = global_lock();
|
||||
let module = read_module(&build(src)).unwrap();
|
||||
let id = module
|
||||
.debugs
|
||||
|
Loading…
Reference in New Issue
Block a user