| 1 | // Copyright (C) 2020 Francois Marier |
| 2 | // |
| 3 | // This program is free software: you can redistribute it and/or modify |
| 4 | // it under the terms of the GNU General Public License as published by |
| 5 | // the Free Software Foundation, either version 3 of the License, or |
| 6 | // (at your option) any later version. |
| 7 | // |
| 8 | // This program is distributed in the hope that it will be useful, |
| 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | // GNU General Public License for more details. |
| 12 | // |
| 13 | // You should have received a copy of the GNU General Public License |
| 14 | // along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 15 | |
| 16 | #[cfg(test)] |
| 17 | mod testsrust-analyzer cargo safe-rm 1.1.0 main_test/tests/ { |
| 18 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#; |
| 19 | use 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/::{selfrust-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#}; |
| 20 | 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/::{selfrust-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#}; |
| 21 | use 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#, PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#}; |
| 22 | use tempfilerust-analyzer cargo tempfile 3.1.0 crate/::tempdirrust-analyzer cargo tempfile 3.1.0 dir/tempdir().; |
| 23 | |
| 24 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 25 | fn read_configrust-analyzer cargo safe-rm 1.1.0 main_test/tests/read_config().() { |
| 26 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::read_configrust-analyzer cargo safe-rm 1.1.0 read_config().; |
| 27 | |
| 28 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::unixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/::PermissionsExtrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/PermissionsExt#; |
| 29 | |
| 30 | let dir = tempdirrust-analyzer cargo tempfile 3.1.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 31 | let file_path = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("oneline"); |
| 32 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&file_path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "/home").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 33 | let paths = read_configrust-analyzer cargo safe-rm 1.1.0 read_config().(&file_path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 34 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paths.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), 1); |
| 35 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(paths, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/home")]); |
| 36 | |
| 37 | // Make the file unreadable and check for an error. |
| 38 | let mut perms = fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::metadatarust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/metadata().(&file_path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().permissionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[Metadata]permissions().(); |
| 39 | perms.set_moderust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/impl#[Permissions][PermissionsExt]set_mode().(0o200); // not readable by anyone |
| 40 | fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::set_permissionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/set_permissions().(&file_path, perms).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 41 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(read_configrust-analyzer cargo safe-rm 1.1.0 read_config().(&file_path).is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 42 | } |
| 43 | |
| 44 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 45 | fn read_config_missing_filerust-analyzer cargo safe-rm 1.1.0 main_test/tests/read_config_missing_file().() { |
| 46 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::read_configrust-analyzer cargo safe-rm 1.1.0 read_config().; |
| 47 | |
| 48 | let dir = tempdirrust-analyzer cargo tempfile 3.1.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 49 | let paths = read_configrust-analyzer cargo safe-rm 1.1.0 read_config().(dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("missing")).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 50 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(paths.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()); |
| 51 | } |
| 52 | |
| 53 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 54 | fn read_config_empty_filerust-analyzer cargo safe-rm 1.1.0 main_test/tests/read_config_empty_file().() { |
| 55 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::read_configrust-analyzer cargo safe-rm 1.1.0 read_config().; |
| 56 | |
| 57 | let dir = tempdirrust-analyzer cargo tempfile 3.1.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 58 | let file_path = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("empty"); |
| 59 | Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&file_path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 60 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(read_configrust-analyzer cargo safe-rm 1.1.0 read_config().(&file_path).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()); |
| 61 | } |
| 62 | |
| 63 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 64 | fn parse_linerust-analyzer cargo safe-rm 1.1.0 main_test/tests/parse_line().() { |
| 65 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::parse_linerust-analyzer cargo safe-rm 1.1.0 parse_line().; |
| 66 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::MAX_GLOB_EXPANSIONrust-analyzer cargo safe-rm 1.1.0 MAX_GLOB_EXPANSION.; |
| 67 | |
| 68 | let filename = 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().("/"); |
| 69 | |
| 70 | // Invalid lines |
| 71 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo safe-rm 1.1.0 parse_line().(filename.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("/�".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())) |
| 72 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 73 | .is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().()); |
| 74 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo safe-rm 1.1.0 parse_line().( |
| 75 | filename.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), |
| 76 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#, "")) |
| 77 | ) |
| 78 | .is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 79 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(parse_linerust-analyzer cargo safe-rm 1.1.0 parse_line().(filename.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("/usr/***/bin".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())).is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()); |
| 80 | |
| 81 | // Valid lines |
| 82 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 83 | parse_linerust-analyzer cargo safe-rm 1.1.0 parse_line().(filename.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("/".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 84 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/")] |
| 85 | ); |
| 86 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 87 | parse_linerust-analyzer cargo safe-rm 1.1.0 parse_line().(filename.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("/tmp/".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), |
| 88 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/tmp")] |
| 89 | ); |
| 90 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 91 | parse_linerust-analyzer cargo safe-rm 1.1.0 parse_line().(filename.displayrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]display().(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#("/**".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())) |
| 92 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 93 | .lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), |
| 94 | MAX_GLOB_EXPANSIONrust-analyzer cargo safe-rm 1.1.0 MAX_GLOB_EXPANSION. |
| 95 | ); |
| 96 | } |
| 97 | |
| 98 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 99 | fn symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 main_test/tests/symlink_canonicalize().() { |
| 100 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 symlink_canonicalize().; |
| 101 | |
| 102 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 103 | symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 symlink_canonicalize().(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().("/usr/bin")), |
| 104 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/usr/bin")) |
| 105 | ); |
| 106 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 107 | symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 symlink_canonicalize().(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().("/usr/bin/../bin/sh")), |
| 108 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/usr/bin/sh")) |
| 109 | ); |
| 110 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 111 | symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 symlink_canonicalize().(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().("/usr/")), |
| 112 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/usr")) |
| 113 | ); |
| 114 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 115 | symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 symlink_canonicalize().(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().("/usr/.")), |
| 116 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/usr")) |
| 117 | ); |
| 118 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 119 | symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 symlink_canonicalize().(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().("/usr/bin/./.././local")), |
| 120 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/usr/local")) |
| 121 | ); |
| 122 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 123 | symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 symlink_canonicalize().(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().("/usr/..")), |
| 124 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/")) |
| 125 | ); |
| 126 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 127 | symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 symlink_canonicalize().(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().("/")), |
| 128 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/")) |
| 129 | ); |
| 130 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 131 | symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 symlink_canonicalize().(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().("/..")), |
| 132 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/")) |
| 133 | ); |
| 134 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 135 | symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 symlink_canonicalize().(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().("/usr/bin")), |
| 136 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/usr/bin")) |
| 137 | ); |
| 138 | |
| 139 | // Relative path |
| 140 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 symlink_canonicalize().(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().("Cargo.toml")) |
| 141 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 142 | .is_absoluterust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]is_absolute().()); |
| 143 | |
| 144 | // Non-existent path |
| 145 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 146 | symlink_canonicalizerust-analyzer cargo safe-rm 1.1.0 symlink_canonicalize().(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().("/non/existent/path/to/file")), |
| 147 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 148 | ); |
| 149 | } |
| 150 | |
| 151 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 152 | fn normalize_pathrust-analyzer cargo safe-rm 1.1.0 main_test/tests/normalize_path().() { |
| 153 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::normalize_pathrust-analyzer cargo safe-rm 1.1.0 normalize_path().; |
| 154 | |
| 155 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(normalize_pathrust-analyzer cargo safe-rm 1.1.0 normalize_path().(&OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), "/"); |
| 156 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(normalize_pathrust-analyzer cargo safe-rm 1.1.0 normalize_path().(&OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/../.".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), "/"); |
| 157 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(normalize_pathrust-analyzer cargo safe-rm 1.1.0 normalize_path().(&OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/usr".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), "/usr"); |
| 158 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(normalize_pathrust-analyzer cargo safe-rm 1.1.0 normalize_path().(&OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/usr/".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), "/usr"); |
| 159 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 160 | normalize_pathrust-analyzer cargo safe-rm 1.1.0 normalize_path().(&OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/home/../usr".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 161 | "/usr" |
| 162 | ); |
| 163 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(normalize_pathrust-analyzer cargo safe-rm 1.1.0 normalize_path().(&OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), ""); |
| 164 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(normalize_pathrust-analyzer cargo safe-rm 1.1.0 normalize_path().(&OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("foo".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), "foo"); |
| 165 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 166 | normalize_pathrust-analyzer cargo safe-rm 1.1.0 normalize_path().(&OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/tmp/�/".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())), |
| 167 | "/tmp/�/" |
| 168 | ); |
| 169 | } |
| 170 | |
| 171 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 172 | fn filter_argumentsrust-analyzer cargo safe-rm 1.1.0 main_test/tests/filter_arguments().() { |
| 173 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::filter_argumentsrust-analyzer cargo safe-rm 1.1.0 filter_arguments().; |
| 174 | |
| 175 | // Simple cases |
| 176 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 177 | filter_argumentsrust-analyzer cargo safe-rm 1.1.0 filter_arguments().( |
| 178 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/safe".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 179 | &vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/safe")] |
| 180 | ), |
| 181 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().() |
| 182 | ); |
| 183 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 184 | filter_argumentsrust-analyzer cargo safe-rm 1.1.0 filter_arguments().( |
| 185 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 186 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/safe".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 187 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/unsafe".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 188 | ] |
| 189 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 190 | &vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/safe")] |
| 191 | ), |
| 192 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/unsafe".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())] |
| 193 | ); |
| 194 | |
| 195 | // Degenerate cases |
| 196 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 197 | filter_argumentsrust-analyzer cargo safe-rm 1.1.0 filter_arguments().(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().().into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), &Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().()), |
| 198 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().() |
| 199 | ); |
| 200 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 201 | filter_argumentsrust-analyzer cargo safe-rm 1.1.0 filter_arguments().( |
| 202 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 203 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/safe".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 204 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/unsafe".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 205 | ] |
| 206 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 207 | &Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().() |
| 208 | ), |
| 209 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 210 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/safe".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 211 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/unsafe".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 212 | ] |
| 213 | ); |
| 214 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 215 | filter_argumentsrust-analyzer cargo safe-rm 1.1.0 filter_arguments().( |
| 216 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().().into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 217 | &vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/safe")] |
| 218 | ), |
| 219 | Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::<OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#>::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().() |
| 220 | ); |
| 221 | |
| 222 | // Relative path |
| 223 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 224 | filter_argumentsrust-analyzer cargo safe-rm 1.1.0 filter_arguments().( |
| 225 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 226 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/../".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()), |
| 227 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/unsafe".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 228 | ] |
| 229 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 230 | &vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/")] |
| 231 | ), |
| 232 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/unsafe".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())] |
| 233 | ); |
| 234 | } |
| 235 | |
| 236 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 237 | fn filter_arguments_symlinksrust-analyzer cargo safe-rm 1.1.0 main_test/tests/filter_arguments_symlinks().() { |
| 238 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::filter_argumentsrust-analyzer cargo safe-rm 1.1.0 filter_arguments().; |
| 239 | |
| 240 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::unixrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/; |
| 241 | |
| 242 | let dir = tempdirrust-analyzer cargo tempfile 3.1.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 243 | let empty_file = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("empty"); |
| 244 | Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&empty_file).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 245 | |
| 246 | // Normal symlinks should not be protected. |
| 247 | let unprotected_symlink = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("unprotected_symlink"); |
| 248 | fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/::symlinkrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/symlink().(&empty_file, &unprotected_symlink).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 249 | |
| 250 | // A symlink explicitly listed in a config file should be protected. |
| 251 | let protected_symlink = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("protected_symlink"); |
| 252 | fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/::symlinkrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/symlink().(&empty_file, &protected_symlink).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 253 | |
| 254 | // A symlink to a protected file should not be protected itself. |
| 255 | let symlink_to_protected_file = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("usr"); |
| 256 | fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/::symlinkrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/unix/fs/symlink().("/usr", &symlink_to_protected_file).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 257 | |
| 258 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 259 | filter_argumentsrust-analyzer cargo safe-rm 1.1.0 filter_arguments().( |
| 260 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 261 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<&T>`]from().(&empty_file), |
| 262 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<&T>`]from().(&unprotected_symlink), |
| 263 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<&T>`]from().(&protected_symlink), |
| 264 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<&T>`]from().(&symlink_to_protected_file), |
| 265 | ] |
| 266 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 267 | &vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/usr"), PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().(&protected_symlink)] |
| 268 | ), |
| 269 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![empty_file, unprotected_symlink, symlink_to_protected_file] |
| 270 | ); |
| 271 | } |
| 272 | |
| 273 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 274 | fn read_config_filesrust-analyzer cargo safe-rm 1.1.0 main_test/tests/read_config_files().() { |
| 275 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::read_config_filesrust-analyzer cargo safe-rm 1.1.0 read_config_files().; |
| 276 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::DEFAULT_PATHSrust-analyzer cargo safe-rm 1.1.0 DEFAULT_PATHS.; |
| 277 | |
| 278 | 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#; |
| 279 | use tempfilerust-analyzer cargo tempfile 3.1.0 crate/::tempdirrust-analyzer cargo tempfile 3.1.0 dir/tempdir().; |
| 280 | |
| 281 | let dir = tempdirrust-analyzer cargo tempfile 3.1.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 282 | let file_path1 = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("home"); |
| 283 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&file_path1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "/home").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 284 | let file_path2 = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("tmp"); |
| 285 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!(Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&file_path2).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), "/tmp").unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 286 | |
| 287 | // Empty config |
| 288 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(read_config_filesrust-analyzer cargo safe-rm 1.1.0 read_config_files().(&[], &[]).lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), DEFAULT_PATHSrust-analyzer cargo safe-rm 1.1.0 DEFAULT_PATHS..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()); |
| 289 | |
| 290 | // Sorted |
| 291 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 292 | read_config_filesrust-analyzer cargo safe-rm 1.1.0 read_config_files().( |
| 293 | &[file_path2.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), file_path1.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()], |
| 294 | &[] |
| 295 | ), |
| 296 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/home"), PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/tmp")] |
| 297 | ); |
| 298 | |
| 299 | // Duplicate lines |
| 300 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 301 | read_config_filesrust-analyzer cargo safe-rm 1.1.0 read_config_files().( |
| 302 | &[file_path1.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(), file_path1.to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()], |
| 303 | &[] |
| 304 | ), |
| 305 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[PathBuf][`From<&T>`]from().("/home")] |
| 306 | ); |
| 307 | } |
| 308 | |
| 309 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 310 | fn runrust-analyzer cargo safe-rm 1.1.0 main_test/tests/run().() { |
| 311 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::runrust-analyzer cargo safe-rm 1.1.0 run().; |
| 312 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::REAL_RMrust-analyzer cargo safe-rm 1.1.0 REAL_RM.; |
| 313 | |
| 314 | 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#; |
| 315 | use tempfilerust-analyzer cargo tempfile 3.1.0 crate/::tempdirrust-analyzer cargo tempfile 3.1.0 dir/tempdir().; |
| 316 | |
| 317 | let dir = tempdirrust-analyzer cargo tempfile 3.1.0 dir/tempdir().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 318 | let empty_file = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("empty").to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 319 | Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&empty_file).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 320 | let missing_file = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("missing").to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 321 | let file1 = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("file1").to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 322 | let file2 = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("file2").to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 323 | Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&file1).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 324 | Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&file2).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 325 | |
| 326 | // Trying to delete a directory without "-r" should fail. |
| 327 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 328 | runrust-analyzer cargo safe-rm 1.1.0 run().( |
| 329 | REAL_RMrust-analyzer cargo safe-rm 1.1.0 REAL_RM., |
| 330 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<&T>`]from().(dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().())].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 331 | &[], |
| 332 | &[] |
| 333 | ), |
| 334 | 1 |
| 335 | ); |
| 336 | |
| 337 | // One file to delete, one directory to ignore. |
| 338 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(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().(&empty_file).existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().(), true); |
| 339 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 340 | runrust-analyzer cargo safe-rm 1.1.0 run().( |
| 341 | REAL_RMrust-analyzer cargo safe-rm 1.1.0 REAL_RM., |
| 342 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 343 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<&T>`]from().(&empty_file), |
| 344 | OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("/usr".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()) |
| 345 | ] |
| 346 | .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 347 | &[], |
| 348 | &[] |
| 349 | ), |
| 350 | 0 |
| 351 | ); |
| 352 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(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().(&empty_file).existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().(), false); |
| 353 | |
| 354 | // When the real rm can't be found, run() fails. |
| 355 | Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&empty_file).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 356 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(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().(&empty_file).existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().(), true); |
| 357 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 358 | runrust-analyzer cargo safe-rm 1.1.0 run().( |
| 359 | &missing_file, |
| 360 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<&T>`]from().(&empty_file)].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 361 | &[], |
| 362 | &[] |
| 363 | ), |
| 364 | 1 |
| 365 | ); |
| 366 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(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().(&empty_file).existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().(), true); |
| 367 | |
| 368 | // Trying to delete a missing file should fail. |
| 369 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 370 | runrust-analyzer cargo safe-rm 1.1.0 run().( |
| 371 | REAL_RMrust-analyzer cargo safe-rm 1.1.0 REAL_RM., |
| 372 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<&T>`]from().(&missing_file)].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 373 | &[], |
| 374 | &[] |
| 375 | ), |
| 376 | 1 |
| 377 | ); |
| 378 | |
| 379 | // The "--help" option should work. |
| 380 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 381 | runrust-analyzer cargo safe-rm 1.1.0 run().( |
| 382 | REAL_RMrust-analyzer cargo safe-rm 1.1.0 REAL_RM., |
| 383 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<String>`]from().("--help".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 384 | &[], |
| 385 | &[] |
| 386 | ), |
| 387 | 0 |
| 388 | ); |
| 389 | |
| 390 | // The contents of a directory can be protected using a wildcard. |
| 391 | let config_file = dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("config").to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(); |
| 392 | writelnrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/writeln!!( |
| 393 | Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::createrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]create().(&config_file).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), |
| 394 | "{}", |
| 395 | dir.pathrust-analyzer cargo tempfile 3.1.0 dir/impl#[TempDir]path().().joinrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]join().("*").to_strrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]to_str().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() |
| 396 | ) |
| 397 | .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 398 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!( |
| 399 | runrust-analyzer cargo safe-rm 1.1.0 run().( |
| 400 | REAL_RMrust-analyzer cargo safe-rm 1.1.0 REAL_RM., |
| 401 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<&T>`]from().(&file1), OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#::fromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsString][`From<&T>`]from().(&file2)].into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().(), |
| 402 | &[&config_file], |
| 403 | &[] |
| 404 | ), |
| 405 | 1 |
| 406 | ); |
| 407 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(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().(&file1).existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().(), true); |
| 408 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(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().(&file2).existsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/impl#[Path]exists().(), true); |
| 409 | } |
| 410 | |
| 411 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 412 | fn ensure_real_rm_is_callablerust-analyzer cargo safe-rm 1.1.0 main_test/tests/ensure_real_rm_is_callable().() { |
| 413 | use superrust-analyzer cargo safe-rm 1.1.0 main_test/::superrust-analyzer cargo safe-rm 1.1.0 crate/::ensure_real_rm_is_callablerust-analyzer cargo safe-rm 1.1.0 ensure_real_rm_is_callable().; |
| 414 | |
| 415 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(ensure_real_rm_is_callablerust-analyzer cargo safe-rm 1.1.0 ensure_real_rm_is_callable().().is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()); |
| 416 | } |
| 417 | } |