2019-12-17 19:54:39 +01:00
|
|
|
use nu_test_support::fs::Stub::EmptyFile;
|
|
|
|
use nu_test_support::playground::Playground;
|
|
|
|
use nu_test_support::{nu, pipeline};
|
2019-08-02 11:23:39 +02:00
|
|
|
|
|
|
|
#[test]
|
2019-12-15 17:15:06 +01:00
|
|
|
fn lists_regular_files() {
|
2019-08-29 02:32:42 +02:00
|
|
|
Playground::setup("ls_test_1", |dirs, sandbox| {
|
2019-09-11 16:36:50 +02:00
|
|
|
sandbox.with_files(vec![
|
2019-10-15 12:16:47 +02:00
|
|
|
EmptyFile("yehuda.txt"),
|
|
|
|
EmptyFile("jonathan.txt"),
|
|
|
|
EmptyFile("andres.txt"),
|
2019-08-29 02:32:42 +02:00
|
|
|
]);
|
2019-08-02 11:23:39 +02:00
|
|
|
|
2019-08-29 02:32:42 +02:00
|
|
|
let actual = nu!(
|
2019-12-15 17:15:06 +01:00
|
|
|
cwd: dirs.test(), pipeline(
|
2019-08-29 08:31:56 +02:00
|
|
|
r#"
|
2019-09-03 02:49:51 +02:00
|
|
|
ls
|
2019-10-15 12:16:47 +02:00
|
|
|
| count
|
2019-08-29 08:31:56 +02:00
|
|
|
| echo $it
|
|
|
|
"#
|
2019-08-29 02:32:42 +02:00
|
|
|
));
|
2019-08-02 11:23:39 +02:00
|
|
|
|
2019-10-15 12:16:47 +02:00
|
|
|
assert_eq!(actual, "3");
|
2019-08-28 19:01:16 +02:00
|
|
|
})
|
2019-08-02 11:23:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2019-12-15 17:15:06 +01:00
|
|
|
fn lists_regular_files_using_asterisk_wildcard() {
|
2019-08-29 02:32:42 +02:00
|
|
|
Playground::setup("ls_test_2", |dirs, sandbox| {
|
2019-09-11 16:36:50 +02:00
|
|
|
sandbox.with_files(vec![
|
2019-10-15 12:16:47 +02:00
|
|
|
EmptyFile("los.txt"),
|
|
|
|
EmptyFile("tres.txt"),
|
|
|
|
EmptyFile("amigos.txt"),
|
|
|
|
EmptyFile("arepas.clu"),
|
2019-08-29 02:32:42 +02:00
|
|
|
]);
|
2019-08-02 11:23:39 +02:00
|
|
|
|
2019-08-29 02:32:42 +02:00
|
|
|
let actual = nu!(
|
2019-12-15 17:15:06 +01:00
|
|
|
cwd: dirs.test(), pipeline(
|
2019-08-29 08:31:56 +02:00
|
|
|
r#"
|
2019-09-03 02:49:51 +02:00
|
|
|
ls *.txt
|
2019-10-15 12:16:47 +02:00
|
|
|
| count
|
2019-08-29 08:31:56 +02:00
|
|
|
| echo $it
|
|
|
|
"#
|
2019-08-29 02:32:42 +02:00
|
|
|
));
|
2019-08-02 11:23:39 +02:00
|
|
|
|
2019-08-29 02:32:42 +02:00
|
|
|
assert_eq!(actual, "3");
|
2019-08-28 19:01:16 +02:00
|
|
|
})
|
2019-08-02 11:23:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2019-12-15 17:15:06 +01:00
|
|
|
fn lists_regular_files_using_question_mark_wildcard() {
|
2019-08-29 02:32:42 +02:00
|
|
|
Playground::setup("ls_test_3", |dirs, sandbox| {
|
2019-09-11 16:36:50 +02:00
|
|
|
sandbox.with_files(vec![
|
|
|
|
EmptyFile("yehuda.10.txt"),
|
|
|
|
EmptyFile("jonathan.10.txt"),
|
|
|
|
EmptyFile("andres.10.txt"),
|
|
|
|
EmptyFile("chicken_not_to_be_picked_up.100.txt"),
|
2019-08-29 02:32:42 +02:00
|
|
|
]);
|
2019-08-02 11:23:39 +02:00
|
|
|
|
2019-08-29 02:32:42 +02:00
|
|
|
let actual = nu!(
|
2019-12-15 17:15:06 +01:00
|
|
|
cwd: dirs.test(), pipeline(
|
2019-08-29 08:31:56 +02:00
|
|
|
r#"
|
2019-09-03 02:49:51 +02:00
|
|
|
ls *.??.txt
|
2019-10-15 12:16:47 +02:00
|
|
|
| count
|
2019-08-29 08:31:56 +02:00
|
|
|
| echo $it
|
|
|
|
"#
|
2019-08-29 02:32:42 +02:00
|
|
|
));
|
2019-08-02 11:23:39 +02:00
|
|
|
|
2019-10-15 12:16:47 +02:00
|
|
|
assert_eq!(actual, "3");
|
2019-08-28 19:01:16 +02:00
|
|
|
})
|
2019-08-02 11:23:39 +02:00
|
|
|
}
|