@@ -219,23 +219,22 @@ fn test_month() {
219219#[ test]
220220fn test_signal ( ) {
221221 std:: env:: set_var ( "LOGNAME" , "root" ) ;
222+
222223 let logname = std:: env:: var ( "LOGNAME" ) . unwrap_or ( "root" . to_string ( ) ) ;
223224 #[ cfg( target_os = "linux" ) ]
224225 let file = format ! ( "/var/spool/cron/{logname}" ) ;
225226 #[ cfg( target_os = "macos" ) ]
226227 let file = format ! ( "/var/at/tabs/{logname}" ) ;
227- let mut tmp_file_created = false ;
228- let filepath = std:: path:: PathBuf :: from_str ( & file) . unwrap ( ) ;
229- if !filepath. exists ( ) {
230- std:: fs:: File :: create ( & file) . unwrap ( ) ;
231- tmp_file_created = true ;
232- }
233228
234229 let output = run_test_base ( "crond" , & vec ! [ ] , b"" ) ;
235230 assert_eq ! ( output. status. code( ) , Some ( 0 ) ) ;
236231
237232 let pids = pid:: get_pids ( "target/debug/crond" ) . unwrap ( ) ;
238- assert ! ( !pids. is_empty( ) ) ;
233+
234+ if std:: path:: PathBuf :: from_str ( & file) . unwrap ( ) . exists ( ) {
235+ assert ! ( !pids. is_empty( ) ) ;
236+ }
237+
239238 for pid in & pids {
240239 unsafe {
241240 libc:: kill ( * pid, libc:: SIGHUP ) ;
@@ -250,8 +249,4 @@ fn test_signal() {
250249 assert ! ( pids == old_pids || !pids. is_empty( ) ) ;
251250
252251 let _ = pid:: kill ( "target/debug/crond" ) . unwrap ( ) ;
253-
254- if tmp_file_created && filepath. starts_with ( "/var/at/tabs" ) {
255- let _ = std:: fs:: remove_file ( file) ;
256- }
257252}
0 commit comments