@@ -556,3 +556,29 @@ fn depends_on_cdylibs() {
556556
557557 assert_file_contains ( js_path, "depends_on_cdylibs.wasm" ) ;
558558}
559+
560+ #[ test]
561+ fn deploy_with_output_overwrites_files_but_does_not_delete_the_directory ( ) {
562+ let template_dir = crate_path ( "static-files" ) ;
563+ let cwd = REPOSITORY_ROOT . join ( "target" ) . join ( "tmp" ) . join ( "static-files-output-test" ) ;
564+
565+ let _ = fs:: remove_dir_all ( & cwd ) ;
566+ fs:: create_dir_all ( & cwd ) . unwrap ( ) ;
567+ fs:: create_dir_all ( cwd. join ( "static" ) ) . unwrap ( ) ;
568+ fs:: create_dir_all ( cwd. join ( "src" ) ) . unwrap ( ) ;
569+
570+ fs:: copy ( template_dir. join ( "Cargo.toml" ) , cwd. join ( "Cargo.toml" ) ) . unwrap ( ) ;
571+ fs:: copy ( template_dir. join ( "src" ) . join ( "main.rs" ) , cwd. join ( "src" ) . join ( "main.rs" ) ) . unwrap ( ) ;
572+
573+ fs:: write ( cwd. join ( "static" ) . join ( "test1.txt" ) , "A" ) . unwrap ( ) ;
574+ fs:: write ( cwd. join ( "static" ) . join ( "test2.txt" ) , "B" ) . unwrap ( ) ;
575+ run ( & cwd, & * CARGO_WEB , & [ "deploy" , "--target" , "wasm32-unknown-unknown" , "--output" , "custom-output" ] ) . assert_success ( ) ;
576+
577+ assert_file_contains ( cwd. join ( "custom-output" ) . join ( "test1.txt" ) , "A" ) ;
578+
579+ fs:: write ( cwd. join ( "static" ) . join ( "test1.txt" ) , "C" ) . unwrap ( ) ;
580+ run ( & cwd, & * CARGO_WEB , & [ "deploy" , "--target" , "wasm32-unknown-unknown" , "--output" , "custom-output" ] ) . assert_success ( ) ;
581+
582+ assert_file_contains ( cwd. join ( "custom-output" ) . join ( "test1.txt" ) , "C" ) ;
583+ assert_file_exists ( cwd. join ( "custom-output" ) . join ( "test2.txt" ) ) ;
584+ }
0 commit comments