@@ -6,7 +6,7 @@ use crate::scaffold::shader::WgslComputeShader;
66use anyhow:: Context ;
77use bytemuck:: Pod ;
88use futures:: executor:: block_on;
9- use std:: { borrow:: Cow , fs :: File , io :: Write , sync:: Arc } ;
9+ use std:: { borrow:: Cow , sync:: Arc } ;
1010use wgpu:: { PipelineCompilationOptions , util:: DeviceExt } ;
1111
1212pub type BufferConfig = backend:: BufferConfig ;
@@ -217,8 +217,7 @@ where
217217 /// Runs the compute shader with no input and writes the output to a file.
218218 pub fn run_test ( self , config : & Config ) -> anyhow:: Result < ( ) > {
219219 let output = self . run ( ) ?;
220- let mut f = File :: create ( & config. output_path ) ?;
221- f. write_all ( & output) ?;
220+ config. write_result ( & output) ?;
222221 Ok ( ( ) )
223222 }
224223
@@ -228,8 +227,7 @@ where
228227 I : Sized + Pod ,
229228 {
230229 let output = self . run_with_input ( input) ?;
231- let mut f = File :: create ( & config. output_path ) ?;
232- f. write_all ( & output) ?;
230+ config. write_result ( & output) ?;
233231 Ok ( ( ) )
234232 }
235233}
@@ -565,8 +563,7 @@ where
565563 // Write the first storage buffer output to the file.
566564 for ( output, buffer_config) in outputs. iter ( ) . zip ( & buffers) {
567565 if matches ! ( buffer_config. usage, BufferUsage :: Storage ) && !output. is_empty ( ) {
568- let mut f = File :: create ( & config. output_path ) ?;
569- f. write_all ( output) ?;
566+ config. write_result ( output) ?;
570567 return Ok ( ( ) ) ;
571568 }
572569 }
@@ -775,8 +772,7 @@ where
775772 // Write first storage buffer output to file.
776773 for ( data, buffer_config) in results. iter ( ) . zip ( & buffers) {
777774 if buffer_config. usage == BufferUsage :: Storage && !data. is_empty ( ) {
778- let mut f = File :: create ( & config. output_path ) ?;
779- f. write_all ( data) ?;
775+ config. write_result ( data) ?;
780776 return Ok ( ( ) ) ;
781777 }
782778 }
0 commit comments