@@ -219,23 +219,22 @@ fn test_month() {
219
219
#[ test]
220
220
fn test_signal ( ) {
221
221
std:: env:: set_var ( "LOGNAME" , "root" ) ;
222
+
222
223
let logname = std:: env:: var ( "LOGNAME" ) . unwrap_or ( "root" . to_string ( ) ) ;
223
224
#[ cfg( target_os = "linux" ) ]
224
225
let file = format ! ( "/var/spool/cron/{logname}" ) ;
225
226
#[ cfg( target_os = "macos" ) ]
226
227
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
- }
233
228
234
229
let output = run_test_base ( "crond" , & vec ! [ ] , b"" ) ;
235
230
assert_eq ! ( output. status. code( ) , Some ( 0 ) ) ;
236
231
237
232
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
+
239
238
for pid in & pids {
240
239
unsafe {
241
240
libc:: kill ( * pid, libc:: SIGHUP ) ;
@@ -250,8 +249,4 @@ fn test_signal() {
250
249
assert ! ( pids == old_pids || !pids. is_empty( ) ) ;
251
250
252
251
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
- }
257
252
}
0 commit comments