mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Path migration part 4: various tests (#13373)
# Description Part 4 of replacing std::path types with nu_path types added in https://github.com/nushell/nushell/pull/13115. This PR migrates various tests throughout the code base.
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
use nu_path::Path;
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[test]
|
||||
fn cd_works_with_in_var() {
|
||||
@ -22,7 +22,7 @@ fn filesystem_change_from_current_directory_using_relative_path() {
|
||||
Playground::setup("cd_test_1", |dirs, _| {
|
||||
let actual = nu!( cwd: dirs.root(), "cd cd_test_1; $env.PWD");
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), *dirs.test());
|
||||
assert_eq!(Path::new(&actual.out), dirs.test());
|
||||
})
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ fn filesystem_change_from_current_directory_using_relative_path_with_trailing_sl
|
||||
// Intentionally not using correct path sep because this should work on Windows
|
||||
let actual = nu!( cwd: dirs.root(), "cd cd_test_1_slash/; $env.PWD");
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), *dirs.test());
|
||||
assert_eq!(Path::new(&actual.out), *dirs.test());
|
||||
})
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ fn filesystem_change_from_current_directory_using_absolute_path() {
|
||||
dirs.formats().display()
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), dirs.formats());
|
||||
assert_eq!(Path::new(&actual.out), dirs.formats());
|
||||
})
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ fn filesystem_change_from_current_directory_using_absolute_path_with_trailing_sl
|
||||
std::path::MAIN_SEPARATOR_STR,
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), dirs.formats());
|
||||
assert_eq!(Path::new(&actual.out), dirs.formats());
|
||||
})
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ fn filesystem_switch_back_to_previous_working_directory() {
|
||||
dirs.test().display()
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), dirs.test().join("odin"));
|
||||
assert_eq!(Path::new(&actual.out), dirs.test().join("odin"));
|
||||
})
|
||||
}
|
||||
|
||||
@ -101,10 +101,7 @@ fn filesystem_change_from_current_directory_using_relative_path_and_dash() {
|
||||
"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
PathBuf::from(actual.out),
|
||||
dirs.test().join("odin").join("-")
|
||||
);
|
||||
assert_eq!(Path::new(&actual.out), dirs.test().join("odin").join("-"));
|
||||
})
|
||||
}
|
||||
|
||||
@ -119,7 +116,7 @@ fn filesystem_change_current_directory_to_parent_directory() {
|
||||
"
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), *dirs.root());
|
||||
assert_eq!(Path::new(&actual.out), *dirs.root());
|
||||
})
|
||||
}
|
||||
|
||||
@ -136,7 +133,7 @@ fn filesystem_change_current_directory_to_two_parents_up_using_multiple_dots() {
|
||||
"
|
||||
);
|
||||
|
||||
assert_eq!(PathBuf::from(actual.out), *dirs.test());
|
||||
assert_eq!(Path::new(&actual.out), *dirs.test());
|
||||
})
|
||||
}
|
||||
|
||||
@ -151,7 +148,7 @@ fn filesystem_change_to_home_directory() {
|
||||
"
|
||||
);
|
||||
|
||||
assert_eq!(Some(PathBuf::from(actual.out)), dirs::home_dir());
|
||||
assert_eq!(Path::new(&actual.out), dirs::home_dir().unwrap());
|
||||
})
|
||||
}
|
||||
|
||||
@ -169,7 +166,7 @@ fn filesystem_change_to_a_directory_containing_spaces() {
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
PathBuf::from(actual.out),
|
||||
Path::new(&actual.out),
|
||||
dirs.test().join("robalino turner katz")
|
||||
);
|
||||
})
|
||||
@ -234,7 +231,7 @@ fn filesystem_change_directory_to_symlink_relative() {
|
||||
$env.PWD
|
||||
"
|
||||
);
|
||||
assert_eq!(PathBuf::from(actual.out), dirs.test().join("foo_link"));
|
||||
assert_eq!(Path::new(&actual.out), dirs.test().join("foo_link"));
|
||||
|
||||
let actual = nu!(
|
||||
cwd: dirs.test().join("boo"),
|
||||
@ -243,7 +240,7 @@ fn filesystem_change_directory_to_symlink_relative() {
|
||||
$env.PWD
|
||||
"
|
||||
);
|
||||
assert_eq!(PathBuf::from(actual.out), dirs.test().join("foo"));
|
||||
assert_eq!(Path::new(&actual.out), dirs.test().join("foo"));
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
use std::{io::Write, path::PathBuf};
|
||||
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use nu_path::AbsolutePathBuf;
|
||||
use nu_protocol::{ast::PathMember, record, Span, Value};
|
||||
use nu_test_support::{
|
||||
fs::{line_ending, Stub},
|
||||
@ -13,6 +12,7 @@ use rand::{
|
||||
rngs::StdRng,
|
||||
Rng, SeedableRng,
|
||||
};
|
||||
use std::io::Write;
|
||||
|
||||
#[test]
|
||||
fn into_sqlite_schema() {
|
||||
@ -453,7 +453,7 @@ impl Distribution<TestRow> for Standard {
|
||||
}
|
||||
}
|
||||
|
||||
fn make_sqlite_db(dirs: &Dirs, nu_table: &str) -> PathBuf {
|
||||
fn make_sqlite_db(dirs: &Dirs, nu_table: &str) -> AbsolutePathBuf {
|
||||
let testdir = dirs.test();
|
||||
let testdb_path =
|
||||
testdir.join(testdir.file_name().unwrap().to_str().unwrap().to_owned() + ".db");
|
||||
@ -465,7 +465,7 @@ fn make_sqlite_db(dirs: &Dirs, nu_table: &str) -> PathBuf {
|
||||
);
|
||||
|
||||
assert!(nucmd.status.success());
|
||||
testdb_path.into()
|
||||
testdb_path
|
||||
}
|
||||
|
||||
fn insert_test_rows(dirs: &Dirs, nu_table: &str, sql_query: Option<&str>, expected: Vec<TestRow>) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use nu_path::AbsolutePath;
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[test]
|
||||
fn creates_temp_file() {
|
||||
@ -9,7 +9,7 @@ fn creates_temp_file() {
|
||||
cwd: dirs.test(),
|
||||
"mktemp"
|
||||
);
|
||||
let loc = PathBuf::from(output.out.clone());
|
||||
let loc = AbsolutePath::try_new(&output.out).unwrap();
|
||||
println!("{:?}", loc);
|
||||
assert!(loc.exists());
|
||||
})
|
||||
@ -22,7 +22,7 @@ fn creates_temp_file_with_suffix() {
|
||||
cwd: dirs.test(),
|
||||
"mktemp --suffix .txt tempfileXXX"
|
||||
);
|
||||
let loc = PathBuf::from(output.out.clone());
|
||||
let loc = AbsolutePath::try_new(&output.out).unwrap();
|
||||
assert!(loc.exists());
|
||||
assert!(loc.is_file());
|
||||
assert!(output.out.ends_with(".txt"));
|
||||
@ -37,8 +37,7 @@ fn creates_temp_directory() {
|
||||
cwd: dirs.test(),
|
||||
"mktemp -d"
|
||||
);
|
||||
|
||||
let loc = PathBuf::from(output.out);
|
||||
let loc = AbsolutePath::try_new(&output.out).unwrap();
|
||||
assert!(loc.exists());
|
||||
assert!(loc.is_dir());
|
||||
})
|
||||
|
@ -2,7 +2,6 @@ use nu_test_support::fs::{files_exist_at, Stub::EmptyFile, Stub::FileWithContent
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
use rstest::rstest;
|
||||
use std::path::Path;
|
||||
|
||||
#[test]
|
||||
fn moves_a_file() {
|
||||
@ -96,7 +95,7 @@ fn moves_the_directory_inside_directory_if_path_to_move_is_existing_directory()
|
||||
|
||||
assert!(!original_dir.exists());
|
||||
assert!(expected.exists());
|
||||
assert!(files_exist_at(vec!["jttxt"], expected))
|
||||
assert!(files_exist_at(&["jttxt"], expected))
|
||||
})
|
||||
}
|
||||
|
||||
@ -125,7 +124,7 @@ fn moves_using_path_with_wildcard() {
|
||||
nu!(cwd: work_dir, "mv ../originals/*.ini ../expected");
|
||||
|
||||
assert!(files_exist_at(
|
||||
vec!["yehuda.ini", "jt.ini", "sample.ini", "andres.ini",],
|
||||
&["yehuda.ini", "jt.ini", "sample.ini", "andres.ini",],
|
||||
expected
|
||||
));
|
||||
})
|
||||
@ -152,7 +151,7 @@ fn moves_using_a_glob() {
|
||||
|
||||
assert!(meal_dir.exists());
|
||||
assert!(files_exist_at(
|
||||
vec!["arepa.txt", "empanada.txt", "taquiza.txt",],
|
||||
&["arepa.txt", "empanada.txt", "taquiza.txt",],
|
||||
expected
|
||||
));
|
||||
})
|
||||
@ -184,7 +183,7 @@ fn moves_a_directory_with_files() {
|
||||
assert!(!original_dir.exists());
|
||||
assert!(expected_dir.exists());
|
||||
assert!(files_exist_at(
|
||||
vec![
|
||||
&[
|
||||
"car/car1.txt",
|
||||
"car/car2.txt",
|
||||
"bicycle/bicycle1.txt",
|
||||
@ -322,7 +321,7 @@ fn move_files_using_glob_two_parents_up_using_multiple_dots() {
|
||||
"#
|
||||
);
|
||||
|
||||
let files = vec![
|
||||
let files = &[
|
||||
"yehuda.yaml",
|
||||
"jtjson",
|
||||
"andres.xml",
|
||||
@ -333,7 +332,7 @@ fn move_files_using_glob_two_parents_up_using_multiple_dots() {
|
||||
let original_dir = dirs.test().join("foo/bar");
|
||||
let destination_dir = dirs.test();
|
||||
|
||||
assert!(files_exist_at(files.clone(), destination_dir));
|
||||
assert!(files_exist_at(files, destination_dir));
|
||||
assert!(!files_exist_at(files, original_dir))
|
||||
})
|
||||
}
|
||||
@ -440,10 +439,7 @@ fn mv_change_case_of_directory() {
|
||||
);
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||
assert!(files_exist_at(
|
||||
vec!["somefile.txt",],
|
||||
dirs.test().join(new_dir)
|
||||
));
|
||||
assert!(files_exist_at(&["somefile.txt"], dirs.test().join(new_dir)));
|
||||
|
||||
#[cfg(not(any(target_os = "linux", target_os = "freebsd")))]
|
||||
_actual.err.contains("to a subdirectory of itself");
|
||||
@ -647,10 +643,10 @@ fn test_cp_inside_glob_metachars_dir() {
|
||||
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(!files_exist_at(
|
||||
vec!["test_file.txt"],
|
||||
&["test_file.txt"],
|
||||
dirs.test().join(sub_dir)
|
||||
));
|
||||
assert!(files_exist_at(vec!["test_file.txt"], dirs.test()));
|
||||
assert!(files_exist_at(&["test_file.txt"], dirs.test()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -667,19 +663,13 @@ fn mv_with_tilde() {
|
||||
// mv file
|
||||
let actual = nu!(cwd: dirs.test(), "mv '~tilde/f1.txt' ./");
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(!files_exist_at(
|
||||
vec![Path::new("f1.txt")],
|
||||
dirs.test().join("~tilde")
|
||||
));
|
||||
assert!(files_exist_at(vec![Path::new("f1.txt")], dirs.test()));
|
||||
assert!(!files_exist_at(&["f1.txt"], dirs.test().join("~tilde")));
|
||||
assert!(files_exist_at(&["f1.txt"], dirs.test()));
|
||||
|
||||
// pass variable
|
||||
let actual = nu!(cwd: dirs.test(), "let f = '~tilde/f2.txt'; mv $f ./");
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(!files_exist_at(
|
||||
vec![Path::new("f2.txt")],
|
||||
dirs.test().join("~tilde")
|
||||
));
|
||||
assert!(files_exist_at(vec![Path::new("f1.txt")], dirs.test()));
|
||||
assert!(!files_exist_at(&["f2.txt"], dirs.test().join("~tilde")));
|
||||
assert!(files_exist_at(&["f1.txt"], dirs.test()));
|
||||
})
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
use nu_path::Path;
|
||||
use nu_test_support::fs::Stub::EmptyFile;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[test]
|
||||
fn expands_path_with_dot() {
|
||||
Playground::setup("path_expand_1", |dirs, sandbox| {
|
||||
@ -18,7 +17,7 @@ fn expands_path_with_dot() {
|
||||
));
|
||||
|
||||
let expected = dirs.test.join("menu").join("spam.txt");
|
||||
assert_eq!(PathBuf::from(actual.out), expected);
|
||||
assert_eq!(Path::new(&actual.out), expected);
|
||||
})
|
||||
}
|
||||
|
||||
@ -38,7 +37,7 @@ fn expands_path_without_follow_symlink() {
|
||||
));
|
||||
|
||||
let expected = dirs.test.join("menu").join("spam_link.ln");
|
||||
assert_eq!(PathBuf::from(actual.out), expected);
|
||||
assert_eq!(Path::new(&actual.out), expected);
|
||||
})
|
||||
}
|
||||
|
||||
@ -56,7 +55,7 @@ fn expands_path_with_double_dot() {
|
||||
));
|
||||
|
||||
let expected = dirs.test.join("menu").join("spam.txt");
|
||||
assert_eq!(PathBuf::from(actual.out), expected);
|
||||
assert_eq!(Path::new(&actual.out), expected);
|
||||
})
|
||||
}
|
||||
|
||||
@ -74,7 +73,7 @@ fn const_path_expand() {
|
||||
));
|
||||
|
||||
let expected = dirs.test.join("menu").join("spam.txt");
|
||||
assert_eq!(PathBuf::from(actual.out), expected);
|
||||
assert_eq!(Path::new(&actual.out), expected);
|
||||
})
|
||||
}
|
||||
|
||||
@ -92,7 +91,7 @@ mod windows {
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(!PathBuf::from(actual.out).starts_with("~"));
|
||||
assert!(!Path::new(&actual.out).starts_with("~"));
|
||||
})
|
||||
}
|
||||
|
||||
@ -106,7 +105,7 @@ mod windows {
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(!PathBuf::from(actual.out).starts_with("~"));
|
||||
assert!(!Path::new(&actual.out).starts_with("~"));
|
||||
})
|
||||
}
|
||||
|
||||
@ -131,7 +130,7 @@ mod windows {
|
||||
));
|
||||
|
||||
let expected = dirs.test.join("menu").join("spam_link.ln");
|
||||
assert_eq!(PathBuf::from(actual.out), expected);
|
||||
assert_eq!(Path::new(&actual.out), expected);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ use nu_test_support::playground::Playground;
|
||||
use rstest::rstest;
|
||||
#[cfg(not(windows))]
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
|
||||
#[test]
|
||||
fn removes_a_file() {
|
||||
@ -50,7 +49,7 @@ fn removes_files_with_wildcard() {
|
||||
);
|
||||
|
||||
assert!(!files_exist_at(
|
||||
vec![
|
||||
&[
|
||||
"src/parser/parse/token_tree.rs",
|
||||
"src/parser/hir/baseline_parse.rs",
|
||||
"src/parser/hir/baseline_parse_tokens.rs"
|
||||
@ -91,7 +90,7 @@ fn removes_deeply_nested_directories_with_wildcard_and_recursive_flag() {
|
||||
);
|
||||
|
||||
assert!(!files_exist_at(
|
||||
vec!["src/parser/parse", "src/parser/hir"],
|
||||
&["src/parser/parse", "src/parser/hir"],
|
||||
dirs.test()
|
||||
));
|
||||
})
|
||||
@ -277,7 +276,7 @@ fn remove_files_from_two_parents_up_using_multiple_dots_and_glob() {
|
||||
);
|
||||
|
||||
assert!(!files_exist_at(
|
||||
vec!["yehuda.txt", "jttxt", "kevin.txt"],
|
||||
&["yehuda.txt", "jttxt", "kevin.txt"],
|
||||
dirs.test()
|
||||
));
|
||||
})
|
||||
@ -305,8 +304,8 @@ fn rm_wildcard_keeps_dotfiles() {
|
||||
r#"rm *"#
|
||||
);
|
||||
|
||||
assert!(!files_exist_at(vec!["foo"], dirs.test()));
|
||||
assert!(files_exist_at(vec![".bar"], dirs.test()));
|
||||
assert!(!files_exist_at(&["foo"], dirs.test()));
|
||||
assert!(files_exist_at(&[".bar"], dirs.test()));
|
||||
})
|
||||
}
|
||||
|
||||
@ -320,8 +319,8 @@ fn rm_wildcard_leading_dot_deletes_dotfiles() {
|
||||
"rm .*"
|
||||
);
|
||||
|
||||
assert!(files_exist_at(vec!["foo"], dirs.test()));
|
||||
assert!(!files_exist_at(vec![".bar"], dirs.test()));
|
||||
assert!(files_exist_at(&["foo"], dirs.test()));
|
||||
assert!(!files_exist_at(&[".bar"], dirs.test()));
|
||||
})
|
||||
}
|
||||
|
||||
@ -453,7 +452,7 @@ fn rm_prints_filenames_on_error() {
|
||||
// This rm is expected to fail, and stderr output indicating so is also expected.
|
||||
let actual = nu!(cwd: test_dir, "rm test*.txt");
|
||||
|
||||
assert!(files_exist_at(file_names.clone(), test_dir));
|
||||
assert!(files_exist_at(&file_names, test_dir));
|
||||
for file_name in file_names {
|
||||
let path = test_dir.join(file_name);
|
||||
let substr = format!("Could not delete {}", path.to_string_lossy());
|
||||
@ -482,7 +481,7 @@ fn rm_files_inside_glob_metachars_dir() {
|
||||
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(!files_exist_at(
|
||||
vec!["test_file.txt"],
|
||||
&["test_file.txt"],
|
||||
dirs.test().join(sub_dir)
|
||||
));
|
||||
});
|
||||
@ -556,22 +555,16 @@ fn rm_with_tilde() {
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), "rm '~tilde/f1.txt'");
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(!files_exist_at(
|
||||
vec![Path::new("f1.txt")],
|
||||
dirs.test().join("~tilde")
|
||||
));
|
||||
assert!(!files_exist_at(&["f1.txt"], dirs.test().join("~tilde")));
|
||||
|
||||
// pass variable
|
||||
let actual = nu!(cwd: dirs.test(), "let f = '~tilde/f2.txt'; rm $f");
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(!files_exist_at(
|
||||
vec![Path::new("f2.txt")],
|
||||
dirs.test().join("~tilde")
|
||||
));
|
||||
assert!(!files_exist_at(&["f2.txt"], dirs.test().join("~tilde")));
|
||||
|
||||
// remove directory
|
||||
let actual = nu!(cwd: dirs.test(), "let f = '~tilde'; rm -r $f");
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(!files_exist_at(vec![Path::new("~tilde")], dirs.test()));
|
||||
assert!(!files_exist_at(&["~tilde"], dirs.test()));
|
||||
})
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ use chrono::{DateTime, Local};
|
||||
use nu_test_support::fs::{files_exist_at, Stub};
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
use std::path::Path;
|
||||
|
||||
// Use 1 instead of 0 because 0 has a special meaning in Windows
|
||||
const TIME_ONE: filetime::FileTime = filetime::FileTime::from_unix_time(1, 0);
|
||||
@ -494,12 +493,12 @@ fn create_a_file_with_tilde() {
|
||||
Playground::setup("touch with tilde", |dirs, _| {
|
||||
let actual = nu!(cwd: dirs.test(), "touch '~tilde'");
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(files_exist_at(vec![Path::new("~tilde")], dirs.test()));
|
||||
assert!(files_exist_at(&["~tilde"], dirs.test()));
|
||||
|
||||
// pass variable
|
||||
let actual = nu!(cwd: dirs.test(), "let f = '~tilde2'; touch $f");
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(files_exist_at(vec![Path::new("~tilde2")], dirs.test()));
|
||||
assert!(files_exist_at(&["~tilde2"], dirs.test()));
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,6 @@ use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
|
||||
use rstest::rstest;
|
||||
use std::path::Path;
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
const PATH_SEPARATOR: &str = "/";
|
||||
@ -131,11 +130,7 @@ fn copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_with_r
|
||||
|
||||
assert!(expected_dir.exists());
|
||||
assert!(files_exist_at(
|
||||
vec![
|
||||
Path::new("yehuda.txt"),
|
||||
Path::new("jttxt"),
|
||||
Path::new("andres.txt")
|
||||
],
|
||||
&["yehuda.txt", "jttxt", "andres.txt"],
|
||||
&expected_dir
|
||||
));
|
||||
})
|
||||
@ -181,15 +176,15 @@ fn deep_copies_with_recursive_flag_impl(progress: bool) {
|
||||
|
||||
assert!(expected_dir.exists());
|
||||
assert!(files_exist_at(
|
||||
vec![Path::new("errors.txt"), Path::new("multishells.txt")],
|
||||
&["errors.txt", "multishells.txt"],
|
||||
jts_expected_copied_dir
|
||||
));
|
||||
assert!(files_exist_at(
|
||||
vec![Path::new("coverage.txt"), Path::new("commands.txt")],
|
||||
&["coverage.txt", "commands.txt"],
|
||||
andres_expected_copied_dir
|
||||
));
|
||||
assert!(files_exist_at(
|
||||
vec![Path::new("defer-evaluation.txt")],
|
||||
&["defer-evaluation.txt"],
|
||||
yehudas_expected_copied_dir
|
||||
));
|
||||
})
|
||||
@ -220,13 +215,13 @@ fn copies_using_path_with_wildcard_impl(progress: bool) {
|
||||
);
|
||||
|
||||
assert!(files_exist_at(
|
||||
vec![
|
||||
Path::new("caco3_plastics.csv"),
|
||||
Path::new("cargo_sample.toml"),
|
||||
Path::new("jt.xml"),
|
||||
Path::new("sample.ini"),
|
||||
Path::new("sgml_description.json"),
|
||||
Path::new("utf16.ini"),
|
||||
&[
|
||||
"caco3_plastics.csv",
|
||||
"cargo_sample.toml",
|
||||
"jt.xml",
|
||||
"sample.ini",
|
||||
"sgml_description.json",
|
||||
"utf16.ini",
|
||||
],
|
||||
dirs.test()
|
||||
));
|
||||
@ -265,13 +260,13 @@ fn copies_using_a_glob_impl(progress: bool) {
|
||||
);
|
||||
|
||||
assert!(files_exist_at(
|
||||
vec![
|
||||
Path::new("caco3_plastics.csv"),
|
||||
Path::new("cargo_sample.toml"),
|
||||
Path::new("jt.xml"),
|
||||
Path::new("sample.ini"),
|
||||
Path::new("sgml_description.json"),
|
||||
Path::new("utf16.ini"),
|
||||
&[
|
||||
"caco3_plastics.csv",
|
||||
"cargo_sample.toml",
|
||||
"jt.xml",
|
||||
"sample.ini",
|
||||
"sgml_description.json",
|
||||
"utf16.ini",
|
||||
],
|
||||
dirs.test()
|
||||
));
|
||||
@ -341,7 +336,7 @@ fn copy_files_using_glob_two_parents_up_using_multiple_dots_imp(progress: bool)
|
||||
);
|
||||
|
||||
assert!(files_exist_at(
|
||||
vec![
|
||||
&[
|
||||
"yehuda.yaml",
|
||||
"jtjson",
|
||||
"andres.xml",
|
||||
@ -377,7 +372,7 @@ fn copy_file_and_dir_from_two_parents_up_using_multiple_dots_to_current_dir_recu
|
||||
|
||||
let expected = dirs.test().join("foo/bar");
|
||||
|
||||
assert!(files_exist_at(vec!["hello_there", "hello_again"], expected));
|
||||
assert!(files_exist_at(&["hello_there", "hello_again"], expected));
|
||||
})
|
||||
}
|
||||
|
||||
@ -428,7 +423,7 @@ fn copy_dir_contains_symlink_ignored_impl(progress: bool) {
|
||||
|
||||
// check hello_there exists inside `tmp_dir_2`, and `dangle_symlink` don't exists inside `tmp_dir_2`.
|
||||
let expected = sandbox.cwd().join("tmp_dir_2");
|
||||
assert!(files_exist_at(vec!["hello_there"], expected));
|
||||
assert!(files_exist_at(&["hello_there"], expected));
|
||||
// GNU cp will copy the broken symlink, so following their behavior
|
||||
// thus commenting out below
|
||||
// let path = expected.join("dangle_symlink");
|
||||
@ -461,7 +456,7 @@ fn copy_dir_contains_symlink_impl(progress: bool) {
|
||||
|
||||
// check hello_there exists inside `tmp_dir_2`, and `dangle_symlink` also exists inside `tmp_dir_2`.
|
||||
let expected = sandbox.cwd().join("tmp_dir_2");
|
||||
assert!(files_exist_at(vec!["hello_there"], expected.clone()));
|
||||
assert!(files_exist_at(&["hello_there"], expected.clone()));
|
||||
let path = expected.join("dangle_symlink");
|
||||
assert!(path.is_symlink());
|
||||
});
|
||||
@ -1151,10 +1146,10 @@ fn test_cp_inside_glob_metachars_dir() {
|
||||
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(files_exist_at(
|
||||
vec!["test_file.txt"],
|
||||
&["test_file.txt"],
|
||||
dirs.test().join(sub_dir)
|
||||
));
|
||||
assert!(files_exist_at(vec!["test_file.txt"], dirs.test()));
|
||||
assert!(files_exist_at(&["test_file.txt"], dirs.test()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -1167,10 +1162,7 @@ fn test_cp_to_customized_home_directory() {
|
||||
let actual = nu!(cwd: dirs.test(), "mkdir test; cp test_file.txt ~/test/");
|
||||
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(files_exist_at(
|
||||
vec!["test_file.txt"],
|
||||
dirs.test().join("test")
|
||||
));
|
||||
assert!(files_exist_at(&["test_file.txt"], dirs.test().join("test")));
|
||||
})
|
||||
}
|
||||
|
||||
@ -1193,20 +1185,14 @@ fn cp_with_tilde() {
|
||||
// cp file
|
||||
let actual = nu!(cwd: dirs.test(), "cp '~tilde/f1.txt' ./");
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(files_exist_at(
|
||||
vec![Path::new("f1.txt")],
|
||||
dirs.test().join("~tilde")
|
||||
));
|
||||
assert!(files_exist_at(vec![Path::new("f1.txt")], dirs.test()));
|
||||
assert!(files_exist_at(&["f1.txt"], dirs.test().join("~tilde")));
|
||||
assert!(files_exist_at(&["f1.txt"], dirs.test()));
|
||||
|
||||
// pass variable
|
||||
let actual = nu!(cwd: dirs.test(), "let f = '~tilde/f2.txt'; cp $f ./");
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(files_exist_at(
|
||||
vec![Path::new("f2.txt")],
|
||||
dirs.test().join("~tilde")
|
||||
));
|
||||
assert!(files_exist_at(vec![Path::new("f1.txt")], dirs.test()));
|
||||
assert!(files_exist_at(&["f2.txt"], dirs.test().join("~tilde")));
|
||||
assert!(files_exist_at(&["f1.txt"], dirs.test()));
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
use nu_test_support::fs::files_exist_at;
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
use std::path::Path;
|
||||
|
||||
#[test]
|
||||
fn creates_directory() {
|
||||
@ -25,10 +24,7 @@ fn accepts_and_creates_directories() {
|
||||
"mkdir dir_1 dir_2 dir_3"
|
||||
);
|
||||
|
||||
assert!(files_exist_at(
|
||||
vec![Path::new("dir_1"), Path::new("dir_2"), Path::new("dir_3")],
|
||||
dirs.test()
|
||||
));
|
||||
assert!(files_exist_at(&["dir_1", "dir_2", "dir_3"], dirs.test()));
|
||||
})
|
||||
}
|
||||
|
||||
@ -70,10 +66,7 @@ fn print_created_paths() {
|
||||
pipeline("mkdir -v dir_1 dir_2 dir_3")
|
||||
);
|
||||
|
||||
assert!(files_exist_at(
|
||||
vec![Path::new("dir_1"), Path::new("dir_2"), Path::new("dir_3")],
|
||||
dirs.test()
|
||||
));
|
||||
assert!(files_exist_at(&["dir_1", "dir_2", "dir_3"], dirs.test()));
|
||||
|
||||
assert!(actual.out.contains("dir_1"));
|
||||
assert!(actual.out.contains("dir_2"));
|
||||
@ -165,11 +158,11 @@ fn mkdir_with_tilde() {
|
||||
Playground::setup("mkdir with tilde", |dirs, _| {
|
||||
let actual = nu!(cwd: dirs.test(), "mkdir '~tilde'");
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(files_exist_at(vec![Path::new("~tilde")], dirs.test()));
|
||||
assert!(files_exist_at(&["~tilde"], dirs.test()));
|
||||
|
||||
// pass variable
|
||||
let actual = nu!(cwd: dirs.test(), "let f = '~tilde2'; mkdir $f");
|
||||
assert!(actual.err.is_empty());
|
||||
assert!(files_exist_at(vec![Path::new("~tilde2")], dirs.test()));
|
||||
assert!(files_exist_at(&["~tilde2"], dirs.test()));
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user