Skip to content

Commit 9fbec12

Browse files
authored
Merge pull request #106 from vadimb892/cron-fix
READY: [cron] fix
2 parents 822b9d5 + 755d262 commit 9fbec12

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ regex = "1.10"
4646
gettext-rs = { path = "./gettext-rs" }
4747
errno = "0.3"
4848
tempfile = "3.14"
49-
chrono-tz = "0.10"
5049

5150
[workspace.lints]
5251

cron/tests/crond/mod.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -219,23 +219,22 @@ fn test_month() {
219219
#[test]
220220
fn 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

Comments
 (0)