|
6 | 6 |
|
7 | 7 | use std::process::Stdio; |
8 | 8 |
|
9 | | -use uutests::util::TestScenario; |
10 | | -use uutests::{at_and_ucmd, new_ucmd, util_name}; |
| 9 | +use uutests::{at_and_ucmd, new_ucmd, util::TestScenario, util_name}; |
11 | 10 |
|
12 | 11 | #[test] |
13 | 12 | fn test_invalid_arg() { |
@@ -379,42 +378,53 @@ fn test_silently_accepts_presume_input_tty2() { |
379 | 378 | fn test_interactive_never() { |
380 | 379 | let scene = TestScenario::new(util_name!()); |
381 | 380 | let at = &scene.fixtures; |
| 381 | + let file = "a"; |
382 | 382 |
|
383 | | - let file_2 = "test_rm_interactive"; |
| 383 | + for arg in ["never", "no", "none"] { |
| 384 | + at.touch(file); |
| 385 | + #[cfg(feature = "chmod")] |
| 386 | + scene.ccmd("chmod").arg("0").arg(file).succeeds(); |
384 | 387 |
|
385 | | - at.touch(file_2); |
386 | | - #[cfg(feature = "chmod")] |
387 | | - scene.ccmd("chmod").arg("0").arg(file_2).succeeds(); |
388 | | - |
389 | | - scene |
390 | | - .ucmd() |
391 | | - .arg("--interactive=never") |
392 | | - .arg(file_2) |
393 | | - .succeeds() |
394 | | - .stdout_is(""); |
| 388 | + scene |
| 389 | + .ucmd() |
| 390 | + .arg(format!("--interactive={arg}")) |
| 391 | + .arg(file) |
| 392 | + .succeeds() |
| 393 | + .no_output(); |
395 | 394 |
|
396 | | - assert!(!at.file_exists(file_2)); |
| 395 | + assert!(!at.file_exists(file)); |
| 396 | + } |
397 | 397 | } |
398 | 398 |
|
399 | 399 | #[test] |
400 | | -fn test_interactive_missing_value() { |
401 | | - // `--interactive` is equivalent to `--interactive=always` or `-i` |
402 | | - let (at, mut ucmd) = at_and_ucmd!(); |
403 | | - |
404 | | - let file1 = "test_rm_interactive_missing_value_file1"; |
405 | | - let file2 = "test_rm_interactive_missing_value_file2"; |
406 | | - |
407 | | - at.touch(file1); |
408 | | - at.touch(file2); |
409 | | - |
410 | | - ucmd.arg("--interactive") |
411 | | - .arg(file1) |
412 | | - .arg(file2) |
413 | | - .pipe_in("y\ny") |
414 | | - .succeeds(); |
| 400 | +fn test_interactive_always() { |
| 401 | + let scene = TestScenario::new(util_name!()); |
| 402 | + let at = &scene.fixtures; |
415 | 403 |
|
416 | | - assert!(!at.file_exists(file1)); |
417 | | - assert!(!at.file_exists(file2)); |
| 404 | + let file_a = "a"; |
| 405 | + let file_b = "b"; |
| 406 | + |
| 407 | + for arg in [ |
| 408 | + "-i", |
| 409 | + "--interactive", |
| 410 | + "--interactive=always", |
| 411 | + "--interactive=yes", |
| 412 | + ] { |
| 413 | + at.touch(file_a); |
| 414 | + at.touch(file_b); |
| 415 | + |
| 416 | + scene |
| 417 | + .ucmd() |
| 418 | + .arg(arg) |
| 419 | + .arg(file_a) |
| 420 | + .arg(file_b) |
| 421 | + .pipe_in("y\ny") |
| 422 | + .succeeds() |
| 423 | + .no_stdout(); |
| 424 | + |
| 425 | + assert!(!at.file_exists(file_a)); |
| 426 | + assert!(!at.file_exists(file_b)); |
| 427 | + } |
418 | 428 | } |
419 | 429 |
|
420 | 430 | #[test] |
|
0 commit comments