Skip to content

Commit dc29f72

Browse files
Fix metallib tests (gfx-rs#9049)
* Single commit fix * Moved up the guards
1 parent 43a8847 commit dc29f72

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

  • tests/tests/wgpu-gpu/passthrough

tests/tests/wgpu-gpu/passthrough/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ static METAL_PASSTHROUGH_SHADER: GpuTestConfiguration = GpuTestConfiguration::ne
9696
.run_sync(metal_test);
9797

9898
fn metallib_source(test_hash: u64) -> Cow<'static, [u8]> {
99+
struct FileDropGuard<'a> {
100+
file_name: &'a str,
101+
}
102+
impl Drop for FileDropGuard<'_> {
103+
fn drop(&mut self) {
104+
let _ = std::fs::remove_file(self.file_name);
105+
}
106+
}
99107
if cfg!(not(target_vendor = "apple")) {
100108
return Cow::Borrowed(&[]);
101109
}
@@ -119,6 +127,10 @@ fn metallib_source(test_hash: u64) -> Cow<'static, [u8]> {
119127
env!("CARGO_MANIFEST_DIR")
120128
);
121129

130+
let _air_drop_guard = FileDropGuard {
131+
file_name: &air_name,
132+
};
133+
122134
{
123135
let output = std::process::Command::new("xcrun")
124136
.args([
@@ -140,6 +152,11 @@ fn metallib_source(test_hash: u64) -> Cow<'static, [u8]> {
140152
);
141153
}
142154
}
155+
156+
let _metallib_drop_guard = FileDropGuard {
157+
file_name: &output_name,
158+
};
159+
143160
{
144161
let output = std::process::Command::new("xcrun")
145162
.args(["metallib", &air_name, "-o", &output_name])

0 commit comments

Comments
 (0)