@@ -67,6 +67,7 @@ mod lockfile;
67
67
mod metadata;
68
68
mod show;
69
69
mod spirv_source;
70
+ mod test;
70
71
71
72
/// Central function to write to the user.
72
73
#[ macro_export]
@@ -223,57 +224,3 @@ fn to_dirname(text: &str) -> String {
223
224
. collect :: < Vec < _ > > ( )
224
225
. concat ( )
225
226
}
226
-
227
- #[ cfg( test) ]
228
- mod test {
229
- use crate :: cache_dir;
230
- use std:: io:: Write as _;
231
-
232
- fn copy_dir_all (
233
- src : impl AsRef < std:: path:: Path > ,
234
- dst : impl AsRef < std:: path:: Path > ,
235
- ) -> anyhow:: Result < ( ) > {
236
- std:: fs:: create_dir_all ( & dst) ?;
237
- for maybe_entry in std:: fs:: read_dir ( src) ? {
238
- let entry = maybe_entry?;
239
- let ty = entry. file_type ( ) ?;
240
- if ty. is_dir ( ) {
241
- copy_dir_all ( entry. path ( ) , dst. as_ref ( ) . join ( entry. file_name ( ) ) ) ?;
242
- } else {
243
- std:: fs:: copy ( entry. path ( ) , dst. as_ref ( ) . join ( entry. file_name ( ) ) ) ?;
244
- }
245
- }
246
- Ok ( ( ) )
247
- }
248
-
249
- pub fn shader_crate_template_path ( ) -> std:: path:: PathBuf {
250
- let project_base = std:: path:: PathBuf :: from ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
251
- project_base. join ( "../shader-crate-template" )
252
- }
253
-
254
- pub fn shader_crate_test_path ( ) -> std:: path:: PathBuf {
255
- let shader_crate_path = crate :: cache_dir ( ) . unwrap ( ) . join ( "shader_crate" ) ;
256
- copy_dir_all ( shader_crate_template_path ( ) , shader_crate_path. clone ( ) ) . unwrap ( ) ;
257
- shader_crate_path
258
- }
259
-
260
- pub fn overwrite_shader_cargo_toml ( shader_crate_path : & std:: path:: Path ) -> std:: fs:: File {
261
- let cargo_toml = shader_crate_path. join ( "Cargo.toml" ) ;
262
- let mut file = std:: fs:: OpenOptions :: new ( )
263
- . write ( true )
264
- . truncate ( true )
265
- . open ( cargo_toml)
266
- . unwrap ( ) ;
267
- writeln ! ( file, "[package]" ) . unwrap ( ) ;
268
- writeln ! ( file, "name = \" test\" " ) . unwrap ( ) ;
269
- file
270
- }
271
-
272
- pub fn tests_teardown ( ) {
273
- let cache_dir = cache_dir ( ) . unwrap ( ) ;
274
- if !cache_dir. exists ( ) {
275
- return ;
276
- }
277
- std:: fs:: remove_dir_all ( cache_dir) . unwrap ( ) ;
278
- }
279
- }
0 commit comments