aboutsummaryrefslogtreecommitdiff
path: root/tests/cli.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cli.rs')
-rw-r--r--tests/cli.rs160
1 files changed, 70 insertions, 90 deletions
diff --git a/tests/cli.rs b/tests/cli.rs
index deaa3f0..ed6a30f 100644
--- a/tests/cli.rs
+++ b/tests/cli.rs
@@ -36,15 +36,11 @@ fn test_run_missing_command() {
36 let temp_dir = TempDir::new().unwrap(); 36 let temp_dir = TempDir::new().unwrap();
37 37
38 let mut cmd = Command::cargo_bin("demon").unwrap(); 38 let mut cmd = Command::cargo_bin("demon").unwrap();
39 cmd.args(&[ 39 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
40 "run", 40 .args(&["run", "test"])
41 "--root-dir", 41 .assert()
42 temp_dir.path().to_str().unwrap(), 42 .failure()
43 "test", 43 .stderr(predicate::str::contains("Command cannot be empty"));
44 ])
45 .assert()
46 .failure()
47 .stderr(predicate::str::contains("Command cannot be empty"));
48} 44}
49 45
50#[test] 46#[test]
@@ -52,17 +48,11 @@ fn test_run_creates_files() {
52 let temp_dir = TempDir::new().unwrap(); 48 let temp_dir = TempDir::new().unwrap();
53 49
54 let mut cmd = Command::cargo_bin("demon").unwrap(); 50 let mut cmd = Command::cargo_bin("demon").unwrap();
55 cmd.args(&[ 51 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
56 "run", 52 .args(&["run", "test", "echo", "hello"])
57 "--root-dir", 53 .assert()
58 temp_dir.path().to_str().unwrap(), 54 .success()
59 "test", 55 .stdout(predicate::str::contains("Started daemon 'test'"));
60 "echo",
61 "hello",
62 ])
63 .assert()
64 .success()
65 .stdout(predicate::str::contains("Started daemon 'test'"));
66 56
67 // Verify files were created 57 // Verify files were created
68 assert!(temp_dir.path().join("test.pid").exists()); 58 assert!(temp_dir.path().join("test.pid").exists());
@@ -83,20 +73,14 @@ fn test_run_duplicate_process() {
83 73
84 // Start a long-running process 74 // Start a long-running process
85 let mut cmd = Command::cargo_bin("demon").unwrap(); 75 let mut cmd = Command::cargo_bin("demon").unwrap();
86 cmd.args(&[ 76 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
87 "run", 77 .args(&["run", "long", "sleep", "30"])
88 "--root-dir", 78 .assert()
89 temp_dir.path().to_str().unwrap(), 79 .success();
90 "long",
91 "sleep",
92 "30",
93 ])
94 .assert()
95 .success();
96 80
97 // Try to start another with the same ID 81 // Try to start another with the same ID
98 let mut cmd = Command::cargo_bin("demon").unwrap(); 82 let mut cmd = Command::cargo_bin("demon").unwrap();
99 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 83 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
100 .args(&["run", "long", "sleep", "5"]) 84 .args(&["run", "long", "sleep", "5"])
101 .assert() 85 .assert()
102 .failure() 86 .failure()
@@ -104,7 +88,7 @@ fn test_run_duplicate_process() {
104 88
105 // Clean up the running process 89 // Clean up the running process
106 let mut cmd = Command::cargo_bin("demon").unwrap(); 90 let mut cmd = Command::cargo_bin("demon").unwrap();
107 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 91 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
108 .args(&["stop", "long"]) 92 .args(&["stop", "long"])
109 .assert() 93 .assert()
110 .success(); 94 .success();
@@ -115,7 +99,8 @@ fn test_list_empty() {
115 let temp_dir = TempDir::new().unwrap(); 99 let temp_dir = TempDir::new().unwrap();
116 100
117 let mut cmd = Command::cargo_bin("demon").unwrap(); 101 let mut cmd = Command::cargo_bin("demon").unwrap();
118 cmd.args(&["list", "--root-dir", temp_dir.path().to_str().unwrap()]) 102 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
103 .args(&["list"])
119 .assert() 104 .assert()
120 .success() 105 .success()
121 .stdout(predicate::str::contains("ID")) 106 .stdout(predicate::str::contains("ID"))
@@ -130,14 +115,14 @@ fn test_list_with_processes() {
130 115
131 // Start a process 116 // Start a process
132 let mut cmd = Command::cargo_bin("demon").unwrap(); 117 let mut cmd = Command::cargo_bin("demon").unwrap();
133 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 118 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
134 .args(&["run", "test", "echo", "done"]) 119 .args(&["run", "test", "echo", "done"])
135 .assert() 120 .assert()
136 .success(); 121 .success();
137 122
138 // List processes 123 // List processes
139 let mut cmd = Command::cargo_bin("demon").unwrap(); 124 let mut cmd = Command::cargo_bin("demon").unwrap();
140 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 125 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
141 .args(&["list"]) 126 .args(&["list"])
142 .assert() 127 .assert()
143 .success() 128 .success()
@@ -151,7 +136,7 @@ fn test_cat_output() {
151 136
152 // Create a process with output 137 // Create a process with output
153 let mut cmd = Command::cargo_bin("demon").unwrap(); 138 let mut cmd = Command::cargo_bin("demon").unwrap();
154 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 139 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
155 .args(&[ 140 .args(&[
156 "run", 141 "run",
157 "test", 142 "test",
@@ -165,7 +150,7 @@ fn test_cat_output() {
165 150
166 // Cat the output 151 // Cat the output
167 let mut cmd = Command::cargo_bin("demon").unwrap(); 152 let mut cmd = Command::cargo_bin("demon").unwrap();
168 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 153 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
169 .args(&["cat", "test"]) 154 .args(&["cat", "test"])
170 .assert() 155 .assert()
171 .success() 156 .success()
@@ -179,7 +164,7 @@ fn test_cat_stdout_only() {
179 164
180 // Create a process with output 165 // Create a process with output
181 let mut cmd = Command::cargo_bin("demon").unwrap(); 166 let mut cmd = Command::cargo_bin("demon").unwrap();
182 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 167 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
183 .args(&[ 168 .args(&[
184 "run", 169 "run",
185 "test", 170 "test",
@@ -193,7 +178,7 @@ fn test_cat_stdout_only() {
193 178
194 // Cat only stdout 179 // Cat only stdout
195 let mut cmd = Command::cargo_bin("demon").unwrap(); 180 let mut cmd = Command::cargo_bin("demon").unwrap();
196 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 181 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
197 .args(&["cat", "test", "--stdout"]) 182 .args(&["cat", "test", "--stdout"])
198 .assert() 183 .assert()
199 .success() 184 .success()
@@ -206,7 +191,7 @@ fn test_status_nonexistent() {
206 let temp_dir = TempDir::new().unwrap(); 191 let temp_dir = TempDir::new().unwrap();
207 192
208 let mut cmd = Command::cargo_bin("demon").unwrap(); 193 let mut cmd = Command::cargo_bin("demon").unwrap();
209 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 194 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
210 .args(&["status", "nonexistent"]) 195 .args(&["status", "nonexistent"])
211 .assert() 196 .assert()
212 .success() 197 .success()
@@ -219,14 +204,14 @@ fn test_status_dead_process() {
219 204
220 // Create a short-lived process 205 // Create a short-lived process
221 let mut cmd = Command::cargo_bin("demon").unwrap(); 206 let mut cmd = Command::cargo_bin("demon").unwrap();
222 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 207 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
223 .args(&["run", "dead", "echo", "hello"]) 208 .args(&["run", "dead", "echo", "hello"])
224 .assert() 209 .assert()
225 .success(); 210 .success();
226 211
227 // Check its status (should be dead) 212 // Check its status (should be dead)
228 let mut cmd = Command::cargo_bin("demon").unwrap(); 213 let mut cmd = Command::cargo_bin("demon").unwrap();
229 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 214 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
230 .args(&["status", "dead"]) 215 .args(&["status", "dead"])
231 .assert() 216 .assert()
232 .success() 217 .success()
@@ -238,7 +223,7 @@ fn test_stop_nonexistent() {
238 let temp_dir = TempDir::new().unwrap(); 223 let temp_dir = TempDir::new().unwrap();
239 224
240 let mut cmd = Command::cargo_bin("demon").unwrap(); 225 let mut cmd = Command::cargo_bin("demon").unwrap();
241 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 226 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
242 .args(&["stop", "nonexistent"]) 227 .args(&["stop", "nonexistent"])
243 .assert() 228 .assert()
244 .success() 229 .success()
@@ -251,14 +236,14 @@ fn test_stop_process() {
251 236
252 // Start a long-running process 237 // Start a long-running process
253 let mut cmd = Command::cargo_bin("demon").unwrap(); 238 let mut cmd = Command::cargo_bin("demon").unwrap();
254 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 239 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
255 .args(&["run", "long", "sleep", "10"]) 240 .args(&["run", "long", "sleep", "10"])
256 .assert() 241 .assert()
257 .success(); 242 .success();
258 243
259 // Stop it 244 // Stop it
260 let mut cmd = Command::cargo_bin("demon").unwrap(); 245 let mut cmd = Command::cargo_bin("demon").unwrap();
261 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 246 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
262 .args(&["stop", "long"]) 247 .args(&["stop", "long"])
263 .assert() 248 .assert()
264 .success() 249 .success()
@@ -273,7 +258,7 @@ fn test_clean_no_orphans() {
273 let temp_dir = TempDir::new().unwrap(); 258 let temp_dir = TempDir::new().unwrap();
274 259
275 let mut cmd = Command::cargo_bin("demon").unwrap(); 260 let mut cmd = Command::cargo_bin("demon").unwrap();
276 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 261 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
277 .args(&["clean"]) 262 .args(&["clean"])
278 .assert() 263 .assert()
279 .success() 264 .success()
@@ -286,16 +271,10 @@ fn test_clean_with_orphans() {
286 271
287 // Create a dead process 272 // Create a dead process
288 let mut cmd = Command::cargo_bin("demon").unwrap(); 273 let mut cmd = Command::cargo_bin("demon").unwrap();
289 cmd.args(&[ 274 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
290 "run", 275 .args(&["run", "dead", "echo", "hello"])
291 "--root-dir", 276 .assert()
292 temp_dir.path().to_str().unwrap(), 277 .success();
293 "dead",
294 "echo",
295 "hello",
296 ])
297 .assert()
298 .success();
299 278
300 // Wait for process to complete 279 // Wait for process to complete
301 std::thread::sleep(Duration::from_millis(100)); 280 std::thread::sleep(Duration::from_millis(100));
@@ -307,7 +286,8 @@ fn test_clean_with_orphans() {
307 286
308 // Clean up orphaned files 287 // Clean up orphaned files
309 let mut cmd = Command::cargo_bin("demon").unwrap(); 288 let mut cmd = Command::cargo_bin("demon").unwrap();
310 cmd.args(&["clean", "--root-dir", temp_dir.path().to_str().unwrap()]) 289 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
290 .args(&["clean"])
311 .assert() 291 .assert()
312 .success() 292 .success()
313 .stdout(predicate::str::contains("Cleaned up")) 293 .stdout(predicate::str::contains("Cleaned up"))
@@ -325,18 +305,17 @@ fn test_clean_removes_stdout_stderr_files() {
325 305
326 // Create a process that outputs to both stdout and stderr 306 // Create a process that outputs to both stdout and stderr
327 let mut cmd = Command::cargo_bin("demon").unwrap(); 307 let mut cmd = Command::cargo_bin("demon").unwrap();
328 cmd.args(&[ 308 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
329 "run", 309 .args(&[
330 "--root-dir", 310 "run",
331 temp_dir.path().to_str().unwrap(), 311 "test_output",
332 "test_output", 312 "--",
333 "--", 313 "sh",
334 "sh", 314 "-c",
335 "-c", 315 "echo 'stdout content'; echo 'stderr content' >&2",
336 "echo 'stdout content'; echo 'stderr content' >&2", 316 ])
337 ]) 317 .assert()
338 .assert() 318 .success();
339 .success();
340 319
341 // Wait for process to complete 320 // Wait for process to complete
342 std::thread::sleep(Duration::from_millis(100)); 321 std::thread::sleep(Duration::from_millis(100));
@@ -353,7 +332,8 @@ fn test_clean_removes_stdout_stderr_files() {
353 332
354 // Clean up orphaned files 333 // Clean up orphaned files
355 let mut cmd = Command::cargo_bin("demon").unwrap(); 334 let mut cmd = Command::cargo_bin("demon").unwrap();
356 cmd.args(&["clean", "--root-dir", temp_dir.path().to_str().unwrap()]) 335 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
336 .args(&["clean"])
357 .assert() 337 .assert()
358 .success() 338 .success()
359 .stdout(predicate::str::contains("Cleaned up")) 339 .stdout(predicate::str::contains("Cleaned up"))
@@ -416,7 +396,7 @@ fn test_run_with_complex_command() {
416 let temp_dir = TempDir::new().unwrap(); 396 let temp_dir = TempDir::new().unwrap();
417 397
418 let mut cmd = Command::cargo_bin("demon").unwrap(); 398 let mut cmd = Command::cargo_bin("demon").unwrap();
419 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 399 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
420 .args(&[ 400 .args(&[
421 "run", 401 "run",
422 "complex", 402 "complex",
@@ -444,14 +424,14 @@ fn test_timeout_configuration() {
444 424
445 // Start a process 425 // Start a process
446 let mut cmd = Command::cargo_bin("demon").unwrap(); 426 let mut cmd = Command::cargo_bin("demon").unwrap();
447 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 427 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
448 .args(&["run", "timeout-test", "sleep", "5"]) 428 .args(&["run", "timeout-test", "sleep", "5"])
449 .assert() 429 .assert()
450 .success(); 430 .success();
451 431
452 // Stop with custom timeout (should work normally since sleep responds to SIGTERM) 432 // Stop with custom timeout (should work normally since sleep responds to SIGTERM)
453 let mut cmd = Command::cargo_bin("demon").unwrap(); 433 let mut cmd = Command::cargo_bin("demon").unwrap();
454 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 434 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
455 .args(&["stop", "timeout-test", "--timeout", "2"]) 435 .args(&["stop", "timeout-test", "--timeout", "2"])
456 .assert() 436 .assert()
457 .success() 437 .success()
@@ -467,7 +447,7 @@ fn test_invalid_process_id() {
467 447
468 // Status should handle it gracefully 448 // Status should handle it gracefully
469 let mut cmd = Command::cargo_bin("demon").unwrap(); 449 let mut cmd = Command::cargo_bin("demon").unwrap();
470 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 450 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
471 .args(&["status", "invalid"]) 451 .args(&["status", "invalid"])
472 .assert() 452 .assert()
473 .success() 453 .success()
@@ -475,7 +455,7 @@ fn test_invalid_process_id() {
475 455
476 // Clean should remove it 456 // Clean should remove it
477 let mut cmd = Command::cargo_bin("demon").unwrap(); 457 let mut cmd = Command::cargo_bin("demon").unwrap();
478 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 458 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
479 .args(&["clean"]) 459 .args(&["clean"])
480 .assert() 460 .assert()
481 .success() 461 .success()
@@ -488,7 +468,7 @@ fn test_list_quiet_mode() {
488 468
489 // Test quiet mode with no processes 469 // Test quiet mode with no processes
490 let mut cmd = Command::cargo_bin("demon").unwrap(); 470 let mut cmd = Command::cargo_bin("demon").unwrap();
491 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 471 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
492 .args(&["list", "--quiet"]) 472 .args(&["list", "--quiet"])
493 .assert() 473 .assert()
494 .success() 474 .success()
@@ -496,14 +476,14 @@ fn test_list_quiet_mode() {
496 476
497 // Create a process 477 // Create a process
498 let mut cmd = Command::cargo_bin("demon").unwrap(); 478 let mut cmd = Command::cargo_bin("demon").unwrap();
499 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 479 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
500 .args(&["run", "quiet-test", "echo", "done"]) 480 .args(&["run", "quiet-test", "echo", "done"])
501 .assert() 481 .assert()
502 .success(); 482 .success();
503 483
504 // Test quiet mode with process - should output colon-separated format 484 // Test quiet mode with process - should output colon-separated format
505 let mut cmd = Command::cargo_bin("demon").unwrap(); 485 let mut cmd = Command::cargo_bin("demon").unwrap();
506 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 486 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
507 .args(&["list", "-q"]) 487 .args(&["list", "-q"])
508 .assert() 488 .assert()
509 .success() 489 .success()
@@ -543,7 +523,7 @@ fn test_wait_nonexistent_process() {
543 let temp_dir = TempDir::new().unwrap(); 523 let temp_dir = TempDir::new().unwrap();
544 524
545 let mut cmd = Command::cargo_bin("demon").unwrap(); 525 let mut cmd = Command::cargo_bin("demon").unwrap();
546 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 526 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
547 .args(&["wait", "nonexistent"]) 527 .args(&["wait", "nonexistent"])
548 .assert() 528 .assert()
549 .failure() 529 .failure()
@@ -556,7 +536,7 @@ fn test_wait_already_dead_process() {
556 536
557 // Create a short-lived process 537 // Create a short-lived process
558 let mut cmd = Command::cargo_bin("demon").unwrap(); 538 let mut cmd = Command::cargo_bin("demon").unwrap();
559 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 539 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
560 .args(&["run", "dead", "echo", "hello"]) 540 .args(&["run", "dead", "echo", "hello"])
561 .assert() 541 .assert()
562 .success(); 542 .success();
@@ -566,7 +546,7 @@ fn test_wait_already_dead_process() {
566 546
567 // Try to wait for it (should fail since it's already dead) 547 // Try to wait for it (should fail since it's already dead)
568 let mut cmd = Command::cargo_bin("demon").unwrap(); 548 let mut cmd = Command::cargo_bin("demon").unwrap();
569 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 549 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
570 .args(&["wait", "dead"]) 550 .args(&["wait", "dead"])
571 .assert() 551 .assert()
572 .failure() 552 .failure()
@@ -579,14 +559,14 @@ fn test_wait_process_terminates() {
579 559
580 // Start a process that will run for 2 seconds 560 // Start a process that will run for 2 seconds
581 let mut cmd = Command::cargo_bin("demon").unwrap(); 561 let mut cmd = Command::cargo_bin("demon").unwrap();
582 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 562 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
583 .args(&["run", "short", "sleep", "2"]) 563 .args(&["run", "short", "sleep", "2"])
584 .assert() 564 .assert()
585 .success(); 565 .success();
586 566
587 // Wait for it with a 5-second timeout (should succeed) 567 // Wait for it with a 5-second timeout (should succeed)
588 let mut cmd = Command::cargo_bin("demon").unwrap(); 568 let mut cmd = Command::cargo_bin("demon").unwrap();
589 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 569 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
590 .args(&["wait", "short", "--timeout", "5"]) 570 .args(&["wait", "short", "--timeout", "5"])
591 .assert() 571 .assert()
592 .success(); 572 .success();
@@ -598,14 +578,14 @@ fn test_wait_timeout() {
598 578
599 // Start a long-running process 579 // Start a long-running process
600 let mut cmd = Command::cargo_bin("demon").unwrap(); 580 let mut cmd = Command::cargo_bin("demon").unwrap();
601 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 581 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
602 .args(&["run", "long", "sleep", "10"]) 582 .args(&["run", "long", "sleep", "10"])
603 .assert() 583 .assert()
604 .success(); 584 .success();
605 585
606 // Wait with a very short timeout (should fail) 586 // Wait with a very short timeout (should fail)
607 let mut cmd = Command::cargo_bin("demon").unwrap(); 587 let mut cmd = Command::cargo_bin("demon").unwrap();
608 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 588 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
609 .args(&["wait", "long", "--timeout", "2"]) 589 .args(&["wait", "long", "--timeout", "2"])
610 .assert() 590 .assert()
611 .failure() 591 .failure()
@@ -613,7 +593,7 @@ fn test_wait_timeout() {
613 593
614 // Clean up the still-running process 594 // Clean up the still-running process
615 let mut cmd = Command::cargo_bin("demon").unwrap(); 595 let mut cmd = Command::cargo_bin("demon").unwrap();
616 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 596 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
617 .args(&["stop", "long"]) 597 .args(&["stop", "long"])
618 .assert() 598 .assert()
619 .success(); 599 .success();
@@ -625,14 +605,14 @@ fn test_wait_infinite_timeout() {
625 605
626 // Start a short process that will finish quickly 606 // Start a short process that will finish quickly
627 let mut cmd = Command::cargo_bin("demon").unwrap(); 607 let mut cmd = Command::cargo_bin("demon").unwrap();
628 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 608 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
629 .args(&["run", "quick", "sleep", "1"]) 609 .args(&["run", "quick", "sleep", "1"])
630 .assert() 610 .assert()
631 .success(); 611 .success();
632 612
633 // Wait with infinite timeout (should succeed quickly) 613 // Wait with infinite timeout (should succeed quickly)
634 let mut cmd = Command::cargo_bin("demon").unwrap(); 614 let mut cmd = Command::cargo_bin("demon").unwrap();
635 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 615 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
636 .args(&["wait", "quick", "--timeout", "0"]) 616 .args(&["wait", "quick", "--timeout", "0"])
637 .assert() 617 .assert()
638 .success(); 618 .success();
@@ -644,14 +624,14 @@ fn test_wait_custom_interval() {
644 624
645 // Start a short process 625 // Start a short process
646 let mut cmd = Command::cargo_bin("demon").unwrap(); 626 let mut cmd = Command::cargo_bin("demon").unwrap();
647 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 627 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
648 .args(&["run", "interval-test", "sleep", "2"]) 628 .args(&["run", "interval-test", "sleep", "2"])
649 .assert() 629 .assert()
650 .success(); 630 .success();
651 631
652 // Wait with custom interval (should still succeed) 632 // Wait with custom interval (should still succeed)
653 let mut cmd = Command::cargo_bin("demon").unwrap(); 633 let mut cmd = Command::cargo_bin("demon").unwrap();
654 cmd.args(["--root-dir", temp_dir.path().to_str().unwrap()]) 634 cmd.env("DEMON_ROOT_DIR", temp_dir.path())
655 .args(&["wait", "interval-test", "--timeout", "5", "--interval", "2"]) 635 .args(&["wait", "interval-test", "--timeout", "5", "--interval", "2"])
656 .assert() 636 .assert()
657 .success(); 637 .success();