|
8 | 8 | use crate::common::util::expected_result; |
9 | 9 | use crate::common::util::TestScenario; |
10 | 10 | use ::env::native_int_str::{Convert, NCvt}; |
| 11 | +use regex::Regex; |
11 | 12 | use std::env; |
12 | 13 | use std::path::Path; |
13 | 14 | use tempfile::tempdir; |
@@ -55,6 +56,83 @@ fn test_if_windows_batch_files_can_be_executed() { |
55 | 56 | assert!(result.stdout_str().contains("Hello Windows World!")); |
56 | 57 | } |
57 | 58 |
|
| 59 | +#[test] |
| 60 | +fn test_debug_1() { |
| 61 | + let ts = TestScenario::new(util_name!()); |
| 62 | + let result = ts |
| 63 | + .ucmd() |
| 64 | + .arg("-v") |
| 65 | + .arg(&ts.bin_path) |
| 66 | + .args(&["sleep", "0.1"]) |
| 67 | + .succeeds(); |
| 68 | + result.stderr_matches( |
| 69 | + &Regex::new(concat!( |
| 70 | + r"executing: [^\n]+/coreutils(.exe)?\n arg\[0\]= '[^\n]+/coreutils(.exe)?'\n", |
| 71 | + r" arg\[1\]= 'sleep'\n arg\[2\]= '0.1'" |
| 72 | + )) |
| 73 | + .unwrap(), |
| 74 | + ); |
| 75 | +} |
| 76 | + |
| 77 | +#[test] |
| 78 | +fn test_debug_2() { |
| 79 | + let ts = TestScenario::new(util_name!()); |
| 80 | + let result = ts |
| 81 | + .ucmd() |
| 82 | + .arg("-vv") |
| 83 | + .arg(ts.bin_path) |
| 84 | + .args(&["sleep", "0.1"]) |
| 85 | + .succeeds(); |
| 86 | + result.stderr_matches( |
| 87 | + &Regex::new(concat!( |
| 88 | + r"input args:\narg\[0\]: 'env'\narg\[1\]: '-vv'\n", |
| 89 | + r"arg\[2\]: '[^\n]+\/coreutils(.exe)?'\narg\[3\]: 'sleep'\narg\[4\]: '0.1'\n", |
| 90 | + r"executing: [^\n]+\/coreutils(.exe)?\n arg\[0\]= '[^\n]+\/coreutils(.exe)?'\n", |
| 91 | + r" arg\[1\]= 'sleep'\n arg\[2\]= '0.1'" |
| 92 | + )) |
| 93 | + .unwrap(), |
| 94 | + ); |
| 95 | +} |
| 96 | + |
| 97 | +#[test] |
| 98 | +fn test_debug1_part_of_string_arg() { |
| 99 | + let ts = TestScenario::new(util_name!()); |
| 100 | + |
| 101 | + let result = ts |
| 102 | + .ucmd() |
| 103 | + .arg("-vS FOO=BAR") |
| 104 | + .arg(ts.bin_path) |
| 105 | + .args(&["sleep", "0.1"]) |
| 106 | + .succeeds(); |
| 107 | + result.stderr_matches( |
| 108 | + &Regex::new(concat!( |
| 109 | + r"executing: [^\n]+/coreutils(.exe)?\n arg\[0\]= '[^\n]+/coreutils(.exe)?'\n", |
| 110 | + r" arg\[1\]= 'sleep'\n arg\[2\]= '0.1'" |
| 111 | + )) |
| 112 | + .unwrap(), |
| 113 | + ); |
| 114 | +} |
| 115 | + |
| 116 | +#[test] |
| 117 | +fn test_debug2_part_of_string_arg() { |
| 118 | + let ts = TestScenario::new(util_name!()); |
| 119 | + let result = ts |
| 120 | + .ucmd() |
| 121 | + .arg("-vvS FOO=BAR") |
| 122 | + .arg(ts.bin_path) |
| 123 | + .args(&["sleep", "0.1"]) |
| 124 | + .succeeds(); |
| 125 | + result.stderr_matches( |
| 126 | + &Regex::new(concat!( |
| 127 | + r"input args:\narg\[0\]: 'env'\narg\[1\]: '-vvS FOO=BAR'\n", |
| 128 | + r"arg\[2\]: '[^\n]+\/coreutils(.exe)?'\narg\[3\]: 'sleep'\narg\[4\]: '0.1'\n", |
| 129 | + r"executing: [^\n]+\/coreutils(.exe)?\n arg\[0\]= '[^\n]+\/coreutils(.exe)?'\n", |
| 130 | + r" arg\[1\]= 'sleep'\n arg\[2\]= '0.1'" |
| 131 | + )) |
| 132 | + .unwrap(), |
| 133 | + ); |
| 134 | +} |
| 135 | + |
58 | 136 | #[test] |
59 | 137 | fn test_file_option() { |
60 | 138 | let out = new_ucmd!() |
|
0 commit comments