@@ -954,51 +954,6 @@ pub(crate) mod sealed {
954954 }
955955}
956956
957- #[ cfg( any( test, feature = "test" ) ) ]
958- #[ cfg_attr( docsrs, doc( cfg( feature = "test" ) ) ) ]
959- pub mod test;
960-
961- #[ cfg( test) ]
962- mod tests {
963- use cargo_toml:: Manifest ;
964- use std:: { env:: var, fs:: read_to_string, path:: PathBuf , sync:: OnceLock } ;
965-
966- static MANIFEST : OnceLock < Manifest > = OnceLock :: new ( ) ;
967- const CHECKED_FEATURES : & str = include_str ! ( concat!( env!( "OUT_DIR" ) , "/checked_features" ) ) ;
968-
969- fn get_manifest ( ) -> & ' static Manifest {
970- MANIFEST . get_or_init ( || {
971- let manifest_dir = PathBuf :: from ( var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
972- Manifest :: from_path ( manifest_dir. join ( "Cargo.toml" ) ) . expect ( "failed to parse Cargo manifest" )
973- } )
974- }
975-
976- #[ test]
977- fn features_are_documented ( ) {
978- let manifest_dir = PathBuf :: from ( var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
979- let lib_code = read_to_string ( manifest_dir. join ( "src/lib.rs" ) ) . expect ( "failed to read lib.rs" ) ;
980-
981- for f in get_manifest ( ) . features . keys ( ) {
982- if !( f. starts_with ( "__" ) || f == "default" || lib_code. contains ( & format ! ( "*{f}**" ) ) ) {
983- panic ! ( "Feature {f} is not documented" ) ;
984- }
985- }
986- }
987-
988- #[ test]
989- fn aliased_features_exist ( ) {
990- let checked_features = CHECKED_FEATURES . split ( ',' ) ;
991- let manifest = get_manifest ( ) ;
992- for checked_feature in checked_features {
993- if !manifest. features . iter ( ) . any ( |( f, _) | f == checked_feature) {
994- panic ! (
995- "Feature {checked_feature} was checked in the alias build step but it does not exist in core/tauri/Cargo.toml"
996- ) ;
997- }
998- }
999- }
1000- }
1001-
1002957#[ derive( Deserialize ) ]
1003958#[ serde( untagged) ]
1004959pub ( crate ) enum IconDto {
@@ -1035,22 +990,67 @@ impl From<IconDto> for Icon {
1035990
1036991#[ allow( unused) ]
1037992macro_rules! run_main_thread {
1038- ( $self : ident, $ex: expr) => { {
993+ ( $handle : ident, $ex: expr) => { {
1039994 use std:: sync:: mpsc:: channel;
1040995 let ( tx, rx) = channel( ) ;
1041- let self_ = $self. clone( ) ;
1042996 let task = move || {
1043997 let f = $ex;
1044- let _ = tx. send( f( self_ ) ) ;
998+ let _ = tx. send( f( ) ) ;
1045999 } ;
1046- $self. app_handle. run_on_main_thread( Box :: new( task) ) ?;
1047- rx. recv( ) . map_err( |_| crate :: Error :: FailedToReceiveMessage )
1000+ $handle
1001+ . run_on_main_thread( task)
1002+ . and_then( |_| rx. recv( ) . map_err( |_| crate :: Error :: FailedToReceiveMessage ) )
10481003 } } ;
10491004}
10501005
10511006#[ allow( unused) ]
10521007pub ( crate ) use run_main_thread;
10531008
1009+ #[ cfg( any( test, feature = "test" ) ) ]
1010+ #[ cfg_attr( docsrs, doc( cfg( feature = "test" ) ) ) ]
1011+ pub mod test;
1012+
1013+ #[ cfg( test) ]
1014+ mod tests {
1015+ use cargo_toml:: Manifest ;
1016+ use std:: { env:: var, fs:: read_to_string, path:: PathBuf , sync:: OnceLock } ;
1017+
1018+ static MANIFEST : OnceLock < Manifest > = OnceLock :: new ( ) ;
1019+ const CHECKED_FEATURES : & str = include_str ! ( concat!( env!( "OUT_DIR" ) , "/checked_features" ) ) ;
1020+
1021+ fn get_manifest ( ) -> & ' static Manifest {
1022+ MANIFEST . get_or_init ( || {
1023+ let manifest_dir = PathBuf :: from ( var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
1024+ Manifest :: from_path ( manifest_dir. join ( "Cargo.toml" ) ) . expect ( "failed to parse Cargo manifest" )
1025+ } )
1026+ }
1027+
1028+ #[ test]
1029+ fn features_are_documented ( ) {
1030+ let manifest_dir = PathBuf :: from ( var ( "CARGO_MANIFEST_DIR" ) . unwrap ( ) ) ;
1031+ let lib_code = read_to_string ( manifest_dir. join ( "src/lib.rs" ) ) . expect ( "failed to read lib.rs" ) ;
1032+
1033+ for f in get_manifest ( ) . features . keys ( ) {
1034+ if !( f. starts_with ( "__" ) || f == "default" || lib_code. contains ( & format ! ( "*{f}**" ) ) ) {
1035+ panic ! ( "Feature {f} is not documented" ) ;
1036+ }
1037+ }
1038+ }
1039+
1040+ #[ test]
1041+ fn aliased_features_exist ( ) {
1042+ let checked_features = CHECKED_FEATURES . split ( ',' ) ;
1043+ let manifest = get_manifest ( ) ;
1044+ for checked_feature in checked_features {
1045+ if !manifest. features . iter ( ) . any ( |( f, _) | f == checked_feature) {
1046+ panic ! (
1047+ "Feature {checked_feature} was checked in the alias build step but it does not exist in core/tauri/Cargo.toml"
1048+ ) ;
1049+ }
1050+ }
1051+ }
1052+ }
1053+
10541054#[ cfg( test) ]
10551055mod test_utils {
10561056 use proptest:: prelude:: * ;
0 commit comments