mirror of
https://github.com/nushell/nushell.git
synced 2025-08-15 22:07:53 +02:00
This reverts commit 3cf3329e49
.
This commit is contained in:
@ -8,7 +8,6 @@ use reedline::{Completer, Suggestion};
|
||||
const SEP: char = std::path::MAIN_SEPARATOR;
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn file_completions() {
|
||||
// Create a new engine
|
||||
let (dir, dir_str, engine) = new_engine();
|
||||
@ -24,11 +23,12 @@ fn file_completions() {
|
||||
|
||||
// Create the expected values
|
||||
let expected_paths: Vec<String> = vec![
|
||||
folder(dir.clone().join("test_a")),
|
||||
folder(dir.clone().join("test_b")),
|
||||
folder(dir.clone().join("another")),
|
||||
file(dir.clone().join(".hidden_file")),
|
||||
folder(dir.clone().join(".hidden_folder")),
|
||||
file(dir.join("nushell")),
|
||||
folder(dir.join("test_a")),
|
||||
folder(dir.join("test_b")),
|
||||
folder(dir.join("another")),
|
||||
file(dir.join(".hidden_file")),
|
||||
folder(dir.join(".hidden_folder")),
|
||||
];
|
||||
|
||||
// Match the results
|
||||
@ -46,7 +46,6 @@ fn file_completions() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn folder_completions() {
|
||||
// Create a new engine
|
||||
let (dir, dir_str, engine) = new_engine();
|
||||
@ -88,26 +87,9 @@ pub fn new_engine() -> (PathBuf, String, EngineState) {
|
||||
}
|
||||
|
||||
// match a list of suggestions with the expected values
|
||||
// skipping the order (for now) due to some issue with sorting behaving
|
||||
// differently for each OS
|
||||
fn match_suggestions(expected: Vec<String>, suggestions: Vec<Suggestion>) {
|
||||
suggestions.into_iter().for_each(|it| {
|
||||
let items = expected.clone();
|
||||
let result = items.into_iter().find(|x| {
|
||||
let mut current_item = x.clone();
|
||||
|
||||
// For windows the expected should also escape "\"
|
||||
if cfg!(windows) {
|
||||
current_item = current_item.replace("\\", "\\\\");
|
||||
}
|
||||
|
||||
¤t_item == &it.value
|
||||
});
|
||||
|
||||
match result {
|
||||
Some(val) => assert_eq!(val, it.value),
|
||||
None => panic!("the path {} is not expected", it.value),
|
||||
}
|
||||
pub fn match_suggestions(expected: Vec<String>, suggestions: Vec<Suggestion>) {
|
||||
expected.iter().zip(suggestions).for_each(|it| {
|
||||
assert_eq!(it.0, &it.1.value);
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user