| 1 | //! Tests config files that have sometimes caused issues despite being valid. |
| 2 | |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, processrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/::Stdiorust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Stdio#, threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/, timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#}; |
| 4 | #[cfg(feature = "default")] |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#, pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#}; |
| 6 | |
| 7 | use predicatesrust-analyzer cargo predicates 3.1.4 crate/::preluderust-analyzer cargo predicates 3.1.4 prelude/::*; |
| 8 | |
| 9 | use craterust-analyzer cargo bottom 0.14.9 crate/::utilrust-analyzer cargo bottom 0.14.9 util/::{btm_commandrust-analyzer cargo bottom 0.14.9 util/btm_command()., spawn_btm_in_ptyrust-analyzer cargo bottom 0.14.9 util/spawn_btm_in_pty().}; |
| 10 | |
| 11 | fn reader_to_stringrust-analyzer cargo bottom 0.14.9 valid_config_tests/reader_to_string().(mut reader: Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#>) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# { |
| 12 | let mut buf = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::defaultrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Default]default().(); |
| 13 | reader.read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/impls/impl#[`Box<R>`][Read]read_to_string().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 14 | |
| 15 | buf |
| 16 | } |
| 17 | |
| 18 | fn run_and_killrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill().(args: &[&str]) { |
| 19 | let (master, mut handle) = spawn_btm_in_ptyrust-analyzer cargo bottom 0.14.9 util/spawn_btm_in_pty().(args); |
| 20 | let reader = master.try_clone_readerrust-analyzer cargo portable-pty 0.9.0 MasterPty#try_clone_reader().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 21 | let _ = master.take_writerrust-analyzer cargo portable-pty 0.9.0 MasterPty#take_writer().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 22 | |
| 23 | const TIMES_CHECKEDrust-analyzer cargo bottom 0.14.9 valid_config_tests/TIMES_CHECKED.: u64 = 6; // Check 6 times, once every 500ms, for 3 seconds total. |
| 24 | |
| 25 | for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#TIMES_CHECKEDrust-analyzer cargo bottom 0.14.9 valid_config_tests/TIMES_CHECKED. { |
| 26 | threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::sleeprust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/sleep().(Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(500)); |
| 27 | match handle.try_waitrust-analyzer cargo portable-pty 0.9.0 Child#try_wait().() { |
| 28 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(exit)) => { |
| 29 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("output: {}", reader_to_stringrust-analyzer cargo bottom 0.14.9 valid_config_tests/reader_to_string().(reader)); |
| 30 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("program terminated unexpectedly (exit status: {exit:?})"); |
| 31 | } |
| 32 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(e) => { |
| 33 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("output: {}", reader_to_stringrust-analyzer cargo bottom 0.14.9 valid_config_tests/reader_to_string().(reader)); |
| 34 | panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("error while trying to wait: {e}") |
| 35 | } |
| 36 | _ => {} |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | handle.killrust-analyzer cargo portable-pty 0.9.0 ChildKiller#kill().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 41 | } |
| 42 | |
| 43 | fn run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().(path: &str) { |
| 44 | run_and_killrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill().(&["-C", path]); |
| 45 | } |
| 46 | |
| 47 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 48 | fn test_basicrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_basic().() { |
| 49 | run_and_killrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill().(&[]); |
| 50 | } |
| 51 | |
| 52 | /// A test to ensure that a bad config will fail the `run_and_kill` function. |
| 53 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 54 | #[should_panic] |
| 55 | fn test_bad_basicrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_bad_basic().() { |
| 56 | run_and_killrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill().(&["--this_does_not_exist"]); |
| 57 | } |
| 58 | |
| 59 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 60 | fn test_emptyrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_empty().() { |
| 61 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/empty_config.toml"); |
| 62 | } |
| 63 | |
| 64 | #[cfg(feature = "default")] |
| 65 | fn test_uncommented_default_configrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_uncommented_default_config().(original: &Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, test_name: &str) { |
| 66 | use regexrust-analyzer cargo regex 1.13.1 crate/::Regexrust-analyzer cargo regex 1.13.1 regex/string/Regex#; |
| 67 | |
| 68 | // Take the default config file and uncomment everything. |
| 69 | let default_config = match stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().(original) { |
| 70 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(mut default_config_file) => { |
| 71 | let mut buf = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(); |
| 72 | default_config_file |
| 73 | .read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File][Read]read_to_string().(&mut buf) |
| 74 | .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("can read file"); |
| 75 | |
| 76 | buf |
| 77 | } |
| 78 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 79 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Could not open default config, skipping {test_name}. Error: {err:?}"); |
| 80 | return; |
| 81 | } |
| 82 | }; |
| 83 | |
| 84 | let default_config = Regexrust-analyzer cargo regex 1.13.1 regex/string/Regex#::newrust-analyzer cargo regex 1.13.1 regex/string/impl#[Regex]new().(r"(?m)^#([a-zA-Z\[])") |
| 85 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 86 | .replace_allrust-analyzer cargo regex 1.13.1 regex/string/impl#[Regex]replace_all().(&default_config, "$1"); |
| 87 | |
| 88 | let default_config = Regexrust-analyzer cargo regex 1.13.1 regex/string/Regex#::newrust-analyzer cargo regex 1.13.1 regex/string/impl#[Regex]new().(r"(?m)^#(\s\s+)([a-zA-Z\[])") |
| 89 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 90 | .replace_allrust-analyzer cargo regex 1.13.1 regex/string/impl#[Regex]replace_all().(&default_config, "$2"); |
| 91 | |
| 92 | let mut uncommented_config = match tempfilerust-analyzer cargo tempfile 3.27.0 crate/::NamedTempFilerust-analyzer cargo tempfile 3.27.0 file/NamedTempFile#::newrust-analyzer cargo tempfile 3.27.0 file/impl#[NamedTempFile]new().() { |
| 93 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(tf) => tf, |
| 94 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 95 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Could not create a temp file, skipping {test_name}. Error: {err:?}"); |
| 96 | return; |
| 97 | } |
| 98 | }; |
| 99 | |
| 100 | if let Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) = uncommented_config.write_allrust-analyzer cargo tempfile 3.27.0 file/impl#[`NamedTempFile<F>`][Write]write_all().(default_config.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().()) { |
| 101 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Could not write to temp file, skipping {test_name}. Error: {err:?}"); |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | run_and_killrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill().(&["-C", &uncommented_config.pathrust-analyzer cargo tempfile 3.27.0 file/impl#[`NamedTempFile<F>`]path().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_string_lossy().()]); |
| 106 | |
| 107 | uncommented_config.closerust-analyzer cargo tempfile 3.27.0 file/impl#[`NamedTempFile<F>`]close().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 108 | } |
| 109 | |
| 110 | #[cfg(feature = "default")] |
| 111 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 112 | fn test_defaultrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_default().() { |
| 113 | test_uncommented_default_configrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_uncommented_default_config().( |
| 114 | Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().("./sample_configs/default_config.toml"), |
| 115 | "test_default", |
| 116 | ); |
| 117 | } |
| 118 | |
| 119 | #[cfg(feature = "default")] |
| 120 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 121 | fn test_new_defaultrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_new_default().() { |
| 122 | use tempfilerust-analyzer cargo tempfile 3.27.0 crate/::TempPathrust-analyzer cargo tempfile 3.27.0 file/TempPath#; |
| 123 | |
| 124 | let new_temp_default_path = match tempfilerust-analyzer cargo tempfile 3.27.0 crate/::NamedTempFilerust-analyzer cargo tempfile 3.27.0 file/NamedTempFile#::newrust-analyzer cargo tempfile 3.27.0 file/impl#[NamedTempFile]new().() { |
| 125 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(temp_file) => temp_file.into_temp_pathrust-analyzer cargo tempfile 3.27.0 file/impl#[`NamedTempFile<F>`]into_temp_path().(), |
| 126 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(err) => { |
| 127 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Could not create a temp file, skipping test_new_default. Error: {err:?}"); |
| 128 | return; |
| 129 | } |
| 130 | }; |
| 131 | |
| 132 | // This is a hack because we need a temp file that doesn't exist. |
| 133 | let actual_temp_default_path = new_temp_default_path.to_path_bufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_path_buf().(); |
| 134 | new_temp_default_path.closerust-analyzer cargo tempfile 3.27.0 file/impl#[TempPath]close().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 135 | |
| 136 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().actual_temp_default_path.existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().() { |
| 137 | run_and_killrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill().(&["-C", &(actual_temp_default_path.to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_string_lossy().())]); |
| 138 | |
| 139 | // Re-take control over the temp path to ensure it gets deleted. |
| 140 | let actual_temp_default_path = |
| 141 | TempPathrust-analyzer cargo tempfile 3.27.0 file/TempPath#::try_from_pathrust-analyzer cargo tempfile 3.27.0 file/impl#[TempPath]try_from_path().(actual_temp_default_path).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("temp path exists"); |
| 142 | test_uncommented_default_configrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_uncommented_default_config().(&actual_temp_default_path, "test_new_default"); |
| 143 | |
| 144 | actual_temp_default_path.closerust-analyzer cargo tempfile 3.27.0 file/impl#[TempPath]close().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 145 | } else { |
| 146 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("temp path we want to check exists, skip test_new_default test."); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 151 | fn test_demorust-analyzer cargo bottom 0.14.9 valid_config_tests/test_demo().() { |
| 152 | let path: &str = "./sample_configs/demo_config.toml"; |
| 153 | if stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]new().(path).existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().() { |
| 154 | run_and_killrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill().(&["-C", path]); |
| 155 | } else { |
| 156 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("Could not read demo config."); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 161 | fn test_many_procrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_many_proc().() { |
| 162 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/many_proc.toml"); |
| 163 | } |
| 164 | |
| 165 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 166 | fn test_all_procrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_all_proc().() { |
| 167 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/all_proc.toml"); |
| 168 | } |
| 169 | |
| 170 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 171 | fn test_cpu_doughnutrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_cpu_doughnut().() { |
| 172 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/cpu_doughnut.toml"); |
| 173 | } |
| 174 | |
| 175 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 176 | fn test_themerust-analyzer cargo bottom 0.14.9 valid_config_tests/test_theme().() { |
| 177 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/theme.toml"); |
| 178 | } |
| 179 | |
| 180 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 181 | fn test_styling_sanity_checkrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_styling_sanity_check().() { |
| 182 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/styling.toml"); |
| 183 | } |
| 184 | |
| 185 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 186 | fn test_styling_sanity_check_2rust-analyzer cargo bottom 0.14.9 valid_config_tests/test_styling_sanity_check_2().() { |
| 187 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/all_styling.toml"); |
| 188 | } |
| 189 | |
| 190 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 191 | fn test_color_spelling_is_validrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_color_spelling_is_valid().() { |
| 192 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/all_styling_color.toml"); |
| 193 | } |
| 194 | |
| 195 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 196 | fn test_filteringrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_filtering().() { |
| 197 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/filtering.toml"); |
| 198 | } |
| 199 | |
| 200 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 201 | fn test_proc_columnsrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_proc_columns().() { |
| 202 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/proc_columns.toml"); |
| 203 | } |
| 204 | |
| 205 | #[cfg(target_os = "linux")] |
| 206 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 207 | fn test_linux_onlyrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_linux_only().() { |
| 208 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/os_specific/linux.toml"); |
| 209 | } |
| 210 | |
| 211 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 212 | fn test_temp_disk_sort_columnsrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_temp_disk_sort_columns().() { |
| 213 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/temp_disk_sort_columns.toml"); |
| 214 | } |
| 215 | |
| 216 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 217 | fn test_proc_default_sortrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_proc_default_sort().() { |
| 218 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/proc_default_sort.toml"); |
| 219 | } |
| 220 | |
| 221 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 222 | fn test_newer_memoryrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_newer_memory().() { |
| 223 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/widget/memory.toml"); |
| 224 | } |
| 225 | |
| 226 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 227 | fn test_newer_cpurust-analyzer cargo bottom 0.14.9 valid_config_tests/test_newer_cpu().() { |
| 228 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/widget/cpu.toml"); |
| 229 | } |
| 230 | |
| 231 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 232 | fn test_newer_processesrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_newer_processes().() { |
| 233 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/widget/processes.toml"); |
| 234 | } |
| 235 | |
| 236 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 237 | fn test_newer_networkrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_newer_network().() { |
| 238 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/widget/network.toml"); |
| 239 | } |
| 240 | |
| 241 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 242 | fn test_network_aliasrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_network_alias().() { |
| 243 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/network_alias.toml"); |
| 244 | } |
| 245 | |
| 246 | /// This uses deprecated network settings - once they are removed, this test file should be moved to invalid configs. |
| 247 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 248 | fn test_deprecated_networkrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_deprecated_network().() { |
| 249 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/deprecated/network.toml"); |
| 250 | } |
| 251 | |
| 252 | /// This uses deprecated process settings - once they are removed, this test file should be moved to invalid configs. |
| 253 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 254 | fn test_deprecated_processesrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_deprecated_processes().() { |
| 255 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/deprecated/processes.toml"); |
| 256 | } |
| 257 | |
| 258 | /// This uses deprecated CPU settings - once they are removed, this test file should be moved to invalid configs. |
| 259 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 260 | fn test_deprecated_cpurust-analyzer cargo bottom 0.14.9 valid_config_tests/test_deprecated_cpu().() { |
| 261 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/deprecated/cpu.toml"); |
| 262 | } |
| 263 | |
| 264 | /// This uses deprecated memory settings - once they are removed, this test file should be moved to invalid configs. |
| 265 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 266 | fn test_deprecated_memoryrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_deprecated_memory().() { |
| 267 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/deprecated/memory.toml"); |
| 268 | } |
| 269 | |
| 270 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 271 | fn test_newer_temperaturerust-analyzer cargo bottom 0.14.9 valid_config_tests/test_newer_temperature().() { |
| 272 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/widget/temperature.toml"); |
| 273 | } |
| 274 | |
| 275 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 276 | fn test_disk_io_graphrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_disk_io_graph().() { |
| 277 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/widget/disk_io_graph.toml"); |
| 278 | } |
| 279 | |
| 280 | /// This uses deprecated temperature settings - once they are removed, this test file should be moved to invalid configs. |
| 281 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 282 | fn test_deprecated_temperaturerust-analyzer cargo bottom 0.14.9 valid_config_tests/test_deprecated_temperature().() { |
| 283 | run_and_kill_cfgrust-analyzer cargo bottom 0.14.9 valid_config_tests/run_and_kill_cfg().("./tests/valid_configs/deprecated/temperature.toml"); |
| 284 | } |
| 285 | |
| 286 | /// Test that deprecated warnings are not shown for config options that are not actually set, |
| 287 | /// even when a `[flags]` section is present. |
| 288 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 289 | fn test_no_spurious_deprecated_warningsrust-analyzer cargo bottom 0.14.9 valid_config_tests/test_no_spurious_deprecated_warnings().() { |
| 290 | let mut child = btm_commandrust-analyzer cargo bottom 0.14.9 util/btm_command().(&["-C", "./tests/valid_configs/empty_flags.toml"]) |
| 291 | .stdoutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]stdout().(Stdiorust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Stdio#::pipedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Stdio]piped().()) |
| 292 | .stderrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]stderr().(Stdiorust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Stdio#::pipedrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Stdio]piped().()) |
| 293 | .spawnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Command]spawn().() |
| 294 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 295 | |
| 296 | threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::sleeprust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/sleep().(Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_secsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_secs().(1)); |
| 297 | child.killrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Child]kill().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 298 | child.waitrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/impl#[Child]wait().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 299 | |
| 300 | let stderr_str = { |
| 301 | let mut stderr = child.stderrrust-analyzer cargo std https://github.com/rust-lang/rust/library/std process/Child#stderr..takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]take().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 302 | let mut buf = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(); |
| 303 | |
| 304 | stderr.read_to_stringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#read_to_string().(&mut buf).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 305 | buf |
| 306 | }; |
| 307 | |
| 308 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!( |
| 309 | predicaterust-analyzer cargo predicates 3.1.4 prelude/predicate/::strrust-analyzer cargo predicates 3.1.4 prelude/predicate/str/::containsrust-analyzer cargo predicates 3.1.4 str/basics/contains().("deprecated") |
| 310 | .notrust-analyzer cargo predicates 3.1.4 boolean/PredicateBooleanExt#not().() |
| 311 | .evalrust-analyzer cargo predicates 3.1.4 boolean/impl#[`NotPredicate<M, Item>`][`Predicate<Item>`]eval().(&stderr_str), |
| 312 | "Expected no deprecated warnings, but got: {stderr_str}" |
| 313 | ); |
| 314 | } |