mirror of
https://github.com/nushell/nushell.git
synced 2024-12-22 15:13:01 +01:00
Yo quiero Playground taconushell.
This commit is contained in:
parent
f82cc4291f
commit
55fb1f8dda
@ -4,8 +4,8 @@ use helpers::in_directory as cwd;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cd_directory_not_found() {
|
fn cd_directory_not_found() {
|
||||||
let output = nu_error!(cwd("tests/fixtures"), "cd dir_that_does_not_exist");
|
let actual = nu_error!(cwd("tests/fixtures"), "cd dir_that_does_not_exist");
|
||||||
|
|
||||||
assert!(output.contains("dir_that_does_not_exist"));
|
assert!(actual.contains("dir_that_does_not_exist"));
|
||||||
assert!(output.contains("directory not found"));
|
assert!(actual.contains("directory not found"));
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
mod helpers;
|
mod helpers;
|
||||||
|
|
||||||
use helpers::{dir_exists_at, file_exists_at, files_exist_at, Playground, Stub::*};
|
use helpers::{in_directory as cwd, dir_exists_at, file_exists_at, files_exist_at, Playground, Stub::*};
|
||||||
|
|
||||||
use nu::AbsoluteFile;
|
use nu::AbsoluteFile;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
@ -9,7 +8,7 @@ use std::path::{Path, PathBuf};
|
|||||||
fn copies_a_file() {
|
fn copies_a_file() {
|
||||||
Playground::setup("cp_test_1", |dirs, _| {
|
Playground::setup("cp_test_1", |dirs, _| {
|
||||||
nu!(
|
nu!(
|
||||||
dirs.root(),
|
cwd(dirs.root()),
|
||||||
"cp {} cp_test_1/sample.ini",
|
"cp {} cp_test_1/sample.ini",
|
||||||
dirs.formats().join("sample.ini")
|
dirs.formats().join("sample.ini")
|
||||||
);
|
);
|
||||||
@ -24,7 +23,7 @@ fn copies_the_file_inside_directory_if_path_to_copy_is_directory() {
|
|||||||
let expected_file = AbsoluteFile::new(dirs.test().join("sample.ini"));
|
let expected_file = AbsoluteFile::new(dirs.test().join("sample.ini"));
|
||||||
|
|
||||||
nu!(
|
nu!(
|
||||||
dirs.formats(),
|
cwd(dirs.formats()),
|
||||||
"cp ../formats/sample.ini {}",
|
"cp ../formats/sample.ini {}",
|
||||||
expected_file.dir()
|
expected_file.dir()
|
||||||
);
|
);
|
||||||
@ -36,17 +35,17 @@ fn copies_the_file_inside_directory_if_path_to_copy_is_directory() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn error_if_attempting_to_copy_a_directory_to_another_directory() {
|
fn error_if_attempting_to_copy_a_directory_to_another_directory() {
|
||||||
Playground::setup("cp_test_3", |dirs, _| {
|
Playground::setup("cp_test_3", |dirs, _| {
|
||||||
let output = nu_error!(dirs.formats(), "cp ../formats {}", dirs.test());
|
let actual = nu_error!(dirs.formats(), "cp ../formats {}", dirs.test());
|
||||||
|
|
||||||
assert!(output.contains("../formats"));
|
assert!(actual.contains("../formats"));
|
||||||
assert!(output.contains("is a directory (not copied)"));
|
assert!(actual.contains("is a directory (not copied)"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_with_recursive_flag() {
|
fn copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_with_recursive_flag() {
|
||||||
Playground::setup("cp_test_4", |dirs, playground| {
|
Playground::setup("cp_test_4", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.within("originals")
|
.within("originals")
|
||||||
.with_files(vec![
|
.with_files(vec![
|
||||||
EmptyFile("yehuda.txt"),
|
EmptyFile("yehuda.txt"),
|
||||||
@ -57,7 +56,7 @@ fn copies_the_directory_inside_directory_if_path_to_copy_is_directory_and_with_r
|
|||||||
|
|
||||||
let expected_dir = dirs.test().join("expected").join("originals");
|
let expected_dir = dirs.test().join("expected").join("originals");
|
||||||
|
|
||||||
nu!(dirs.test(), "cp originals expected --recursive");
|
nu!(cwd(dirs.test()), "cp originals expected --recursive");
|
||||||
|
|
||||||
assert!(dir_exists_at(PathBuf::from(&expected_dir)));
|
assert!(dir_exists_at(PathBuf::from(&expected_dir)));
|
||||||
assert!(files_exist_at(
|
assert!(files_exist_at(
|
||||||
@ -91,8 +90,8 @@ fn deep_copies_with_recursive_flag() {
|
|||||||
originals/contributors/yehuda/defer-evaluation.txt
|
originals/contributors/yehuda/defer-evaluation.txt
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
Playground::setup("cp_test_5", |dirs, playground| {
|
Playground::setup("cp_test_5", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.within("originals")
|
.within("originals")
|
||||||
.with_files(vec![EmptyFile("manifest.txt")])
|
.with_files(vec![EmptyFile("manifest.txt")])
|
||||||
.within("originals/contributors")
|
.within("originals/contributors")
|
||||||
@ -115,7 +114,7 @@ fn deep_copies_with_recursive_flag() {
|
|||||||
let andres_expected_copied_dir = expected_dir.join("contributors").join("andres");
|
let andres_expected_copied_dir = expected_dir.join("contributors").join("andres");
|
||||||
let yehudas_expected_copied_dir = expected_dir.join("contributors").join("yehuda");
|
let yehudas_expected_copied_dir = expected_dir.join("contributors").join("yehuda");
|
||||||
|
|
||||||
nu!(dirs.test(), "cp originals expected --recursive");
|
nu!(cwd(dirs.test()), "cp originals expected --recursive");
|
||||||
|
|
||||||
assert!(dir_exists_at(PathBuf::from(&expected_dir)));
|
assert!(dir_exists_at(PathBuf::from(&expected_dir)));
|
||||||
assert!(files_exist_at(
|
assert!(files_exist_at(
|
||||||
@ -136,7 +135,7 @@ fn deep_copies_with_recursive_flag() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn copies_using_path_with_wildcard() {
|
fn copies_using_path_with_wildcard() {
|
||||||
Playground::setup("cp_test_6", |dirs, _| {
|
Playground::setup("cp_test_6", |dirs, _| {
|
||||||
nu!(dirs.formats(), "cp ../formats/* {}", dirs.test());
|
nu!(cwd(dirs.formats()), "cp ../formats/* {}", dirs.test());
|
||||||
|
|
||||||
assert!(files_exist_at(
|
assert!(files_exist_at(
|
||||||
vec![
|
vec![
|
||||||
@ -155,7 +154,7 @@ fn copies_using_path_with_wildcard() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn copies_using_a_glob() {
|
fn copies_using_a_glob() {
|
||||||
Playground::setup("cp_test_7", |dirs, _| {
|
Playground::setup("cp_test_7", |dirs, _| {
|
||||||
nu!(dirs.formats(), "cp * {}", dirs.test());
|
nu!(cwd(dirs.formats()), "cp * {}", dirs.test());
|
||||||
|
|
||||||
assert!(files_exist_at(
|
assert!(files_exist_at(
|
||||||
vec![
|
vec![
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
mod helpers;
|
mod helpers;
|
||||||
|
|
||||||
use h::{Playground, Stub::*};
|
use h::{in_directory as cwd, Playground, Stub::*};
|
||||||
use helpers as h;
|
use helpers as h;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn knows_the_filesystems_entered() {
|
fn knows_the_filesystems_entered() {
|
||||||
Playground::setup("enter_filesystem_sessions_test", |dirs, playground| {
|
Playground::setup("enter_test_1", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.within("red_pill")
|
.within("red_pill")
|
||||||
.with_files(vec![
|
.with_files(vec![
|
||||||
EmptyFile("andres.nu"),
|
EmptyFile("andres.nu"),
|
||||||
@ -20,8 +20,7 @@ fn knows_the_filesystems_entered() {
|
|||||||
EmptyFile("korn.nxt"),
|
EmptyFile("korn.nxt"),
|
||||||
EmptyFile("powedsh.nxt"),
|
EmptyFile("powedsh.nxt"),
|
||||||
])
|
])
|
||||||
.mkdir("expected")
|
.mkdir("expected");
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
let red_pill_dir = dirs.test().join("red_pill");
|
let red_pill_dir = dirs.test().join("red_pill");
|
||||||
let blue_pill_dir = dirs.test().join("blue_pill");
|
let blue_pill_dir = dirs.test().join("blue_pill");
|
||||||
@ -29,7 +28,7 @@ fn knows_the_filesystems_entered() {
|
|||||||
let expected_recycled = expected.join("recycled");
|
let expected_recycled = expected.join("recycled");
|
||||||
|
|
||||||
nu!(
|
nu!(
|
||||||
dirs.test(),
|
cwd(dirs.test()),
|
||||||
r#"
|
r#"
|
||||||
enter expected
|
enter expected
|
||||||
mkdir recycled
|
mkdir recycled
|
||||||
|
@ -5,62 +5,86 @@ use helpers as h;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ls_lists_regular_files() {
|
fn ls_lists_regular_files() {
|
||||||
Playground::setup("ls_lists_files_test", |dirs, playground| {
|
Playground::setup("ls_test_1", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.with_files(vec![
|
.with_files(vec![
|
||||||
EmptyFile("yehuda.10.txt"),
|
EmptyFile("yehuda.10.txt"),
|
||||||
EmptyFile("jonathan.10.txt"),
|
EmptyFile("jonathan.10.txt"),
|
||||||
EmptyFile("andres.10.txt"),
|
EmptyFile("andres.10.txt"),
|
||||||
])
|
]);
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
dirs.test(),
|
cwd(dirs.test()), h::pipeline(
|
||||||
r#"ls | get name | lines | split-column "." | get Column2 | str --to-int | sum | echo $it"#
|
r#"
|
||||||
);
|
ls
|
||||||
|
| get name
|
||||||
|
| lines
|
||||||
|
| split-column "."
|
||||||
|
| get Column2
|
||||||
|
| str --to-int
|
||||||
|
| sum
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "30");
|
assert_eq!(actual, "30");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ls_lists_regular_files_using_asterisk_wildcard() {
|
fn ls_lists_regular_files_using_asterisk_wildcard() {
|
||||||
Playground::setup("ls_asterisk_wildcard_test", |dirs, playground| {
|
Playground::setup("ls_test_2", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.with_files(vec![
|
.with_files(vec![
|
||||||
EmptyFile("los.1.txt"),
|
EmptyFile("los.1.txt"),
|
||||||
EmptyFile("tres.1.txt"),
|
EmptyFile("tres.1.txt"),
|
||||||
EmptyFile("amigos.1.txt"),
|
EmptyFile("amigos.1.txt"),
|
||||||
EmptyFile("arepas.1.clu"),
|
EmptyFile("arepas.1.clu"),
|
||||||
])
|
]);
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
dirs.test(),
|
cwd(dirs.test()), h::pipeline(
|
||||||
r#"ls *.txt | get name | lines| split-column "." | get Column2 | str --to-int | sum | echo $it"#
|
r#"
|
||||||
);
|
ls *.txt
|
||||||
|
| get name
|
||||||
|
| lines
|
||||||
|
| split-column "."
|
||||||
|
| get Column2
|
||||||
|
| str --to-int
|
||||||
|
| sum
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "3");
|
assert_eq!(actual, "3");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ls_lists_regular_files_using_question_mark_wildcard() {
|
fn ls_lists_regular_files_using_question_mark_wildcard() {
|
||||||
Playground::setup("ls_question_mark_wildcard_test", |dirs, playground| {
|
Playground::setup("ls_test_3", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.with_files(vec![
|
.with_files(vec![
|
||||||
EmptyFile("yehuda.10.txt"),
|
EmptyFile("yehuda.10.txt"),
|
||||||
EmptyFile("jonathan.10.txt"),
|
EmptyFile("jonathan.10.txt"),
|
||||||
EmptyFile("andres.10.txt"),
|
EmptyFile("andres.10.txt"),
|
||||||
EmptyFile("chicken_not_to_be_picked_up.100.txt"),
|
EmptyFile("chicken_not_to_be_picked_up.100.txt"),
|
||||||
])
|
]);
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
dirs.test(),
|
cwd(dirs.test()), h::pipeline(
|
||||||
r#"ls *.??.txt | get name | lines| split-column "." | get Column2 | str --to-int | sum | echo $it"#
|
r#"
|
||||||
);
|
ls *.??.txt
|
||||||
|
| get name
|
||||||
|
| lines
|
||||||
|
| split-column "."
|
||||||
|
| get Column2
|
||||||
|
| str --to-int
|
||||||
|
| sum
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "30");
|
assert_eq!(actual, "30");
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
mod helpers;
|
mod helpers;
|
||||||
|
|
||||||
use h::Playground;
|
use h::{in_directory as cwd, Playground};
|
||||||
use helpers as h;
|
use helpers as h;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn creates_directory() {
|
fn creates_directory() {
|
||||||
Playground::setup("mkdir_test_1", |dirs, _| {
|
Playground::setup("mkdir_test_1", |dirs, _| {
|
||||||
nu!(dirs.test(), "mkdir my_new_directory");
|
nu!(cwd(dirs.test()), "mkdir my_new_directory");
|
||||||
|
|
||||||
let expected = dirs.test().join("my_new_directory");
|
let expected = dirs.test().join("my_new_directory");
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ fn creates_directory() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn accepts_and_creates_directories() {
|
fn accepts_and_creates_directories() {
|
||||||
Playground::setup("mkdir_test_2", |dirs, _| {
|
Playground::setup("mkdir_test_2", |dirs, _| {
|
||||||
nu!(dirs.test(), "mkdir dir_1 dir_2 dir_3");
|
nu!(cwd(dirs.test()), "mkdir dir_1 dir_2 dir_3");
|
||||||
|
|
||||||
assert!(h::files_exist_at(
|
assert!(h::files_exist_at(
|
||||||
vec![Path::new("dir_1"), Path::new("dir_2"), Path::new("dir_3")],
|
vec![Path::new("dir_1"), Path::new("dir_2"), Path::new("dir_3")],
|
||||||
@ -30,7 +30,7 @@ fn accepts_and_creates_directories() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn creates_intermediary_directories() {
|
fn creates_intermediary_directories() {
|
||||||
Playground::setup("mkdir_test_3", |dirs, _| {
|
Playground::setup("mkdir_test_3", |dirs, _| {
|
||||||
nu!(dirs.test(), "mkdir some_folder/another/deeper_one");
|
nu!(cwd(dirs.test()), "mkdir some_folder/another/deeper_one");
|
||||||
|
|
||||||
let mut expected = PathBuf::from(dirs.test());
|
let mut expected = PathBuf::from(dirs.test());
|
||||||
expected.push("some_folder/another/deeper_one");
|
expected.push("some_folder/another/deeper_one");
|
||||||
|
@ -3,20 +3,17 @@ mod helpers;
|
|||||||
use h::{in_directory as cwd, Playground, Stub::*};
|
use h::{in_directory as cwd, Playground, Stub::*};
|
||||||
use helpers as h;
|
use helpers as h;
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn moves_a_file() {
|
fn moves_a_file() {
|
||||||
Playground::setup("mv_test_1", |dirs, playground| {
|
Playground::setup("mv_test_1", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.with_files(vec![EmptyFile("andres.txt")])
|
.with_files(vec![EmptyFile("andres.txt")])
|
||||||
.mkdir("expected")
|
.mkdir("expected");
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
let original = dirs.test().join("andres.txt");
|
let original = dirs.test().join("andres.txt");
|
||||||
let expected = dirs.test().join("expected/yehuda.txt");
|
let expected = dirs.test().join("expected/yehuda.txt");
|
||||||
|
|
||||||
nu!(dirs.test(), "mv andres.txt expected/yehuda.txt");
|
nu!(cwd(dirs.test()), "mv andres.txt expected/yehuda.txt");
|
||||||
|
|
||||||
assert!(!h::file_exists_at(original));
|
assert!(!h::file_exists_at(original));
|
||||||
assert!(h::file_exists_at(expected));
|
assert!(h::file_exists_at(expected));
|
||||||
@ -25,15 +22,17 @@ fn moves_a_file() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn overwrites_if_moving_to_existing_file() {
|
fn overwrites_if_moving_to_existing_file() {
|
||||||
Playground::setup("mv_test_2", |dirs, playground| {
|
Playground::setup("mv_test_2", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.with_files(vec![EmptyFile("andres.txt"), EmptyFile("jonathan.txt")])
|
.with_files(vec![
|
||||||
.test_dir_name();
|
EmptyFile("andres.txt"),
|
||||||
|
EmptyFile("jonathan.txt")
|
||||||
|
]);
|
||||||
|
|
||||||
let original = dirs.test().join("andres.txt");
|
let original = dirs.test().join("andres.txt");
|
||||||
let expected = dirs.test().join("jonathan.txt");
|
let expected = dirs.test().join("jonathan.txt");
|
||||||
|
|
||||||
nu!(dirs.test(), "mv andres.txt jonathan.txt");
|
nu!(cwd(dirs.test()), "mv andres.txt jonathan.txt");
|
||||||
|
|
||||||
assert!(!h::file_exists_at(original));
|
assert!(!h::file_exists_at(original));
|
||||||
assert!(h::file_exists_at(expected));
|
assert!(h::file_exists_at(expected));
|
||||||
@ -42,13 +41,13 @@ fn overwrites_if_moving_to_existing_file() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn moves_a_directory() {
|
fn moves_a_directory() {
|
||||||
Playground::setup("mv_test_3", |dirs, playground| {
|
Playground::setup("mv_test_3", |dirs, sandbox| {
|
||||||
playground.mkdir("empty_dir");
|
sandbox.mkdir("empty_dir");
|
||||||
|
|
||||||
let original_dir = dirs.test().join("empty_dir");
|
let original_dir = dirs.test().join("empty_dir");
|
||||||
let expected = dirs.test().join("renamed_dir");
|
let expected = dirs.test().join("renamed_dir");
|
||||||
|
|
||||||
nu!(dirs.test(), "mv empty_dir renamed_dir");
|
nu!(cwd(dirs.test()), "mv empty_dir renamed_dir");
|
||||||
|
|
||||||
assert!(!h::dir_exists_at(original_dir));
|
assert!(!h::dir_exists_at(original_dir));
|
||||||
assert!(h::dir_exists_at(expected));
|
assert!(h::dir_exists_at(expected));
|
||||||
@ -57,11 +56,10 @@ fn moves_a_directory() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn moves_the_file_inside_directory_if_path_to_move_is_existing_directory() {
|
fn moves_the_file_inside_directory_if_path_to_move_is_existing_directory() {
|
||||||
Playground::setup("mv_test_4", |dirs, playground| {
|
Playground::setup("mv_test_4", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.with_files(vec![EmptyFile("jonathan.txt")])
|
.with_files(vec![EmptyFile("jonathan.txt")])
|
||||||
.mkdir("expected")
|
.mkdir("expected");
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
let original_dir = dirs.test().join("jonathan.txt");
|
let original_dir = dirs.test().join("jonathan.txt");
|
||||||
let expected = dirs.test().join("expected/jonathan.txt");
|
let expected = dirs.test().join("expected/jonathan.txt");
|
||||||
@ -75,12 +73,11 @@ fn moves_the_file_inside_directory_if_path_to_move_is_existing_directory() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn moves_the_directory_inside_directory_if_path_to_move_is_existing_directory() {
|
fn moves_the_directory_inside_directory_if_path_to_move_is_existing_directory() {
|
||||||
Playground::setup("mv_test_5", |dirs, playground| {
|
Playground::setup("mv_test_5", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.within("contributors")
|
.within("contributors")
|
||||||
.with_files(vec![EmptyFile("jonathan.txt")])
|
.with_files(vec![EmptyFile("jonathan.txt")])
|
||||||
.mkdir("expected")
|
.mkdir("expected");
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
let original_dir = dirs.test().join("contributors");
|
let original_dir = dirs.test().join("contributors");
|
||||||
let expected = dirs.test().join("expected/contributors");
|
let expected = dirs.test().join("expected/contributors");
|
||||||
@ -94,17 +91,16 @@ fn moves_the_directory_inside_directory_if_path_to_move_is_existing_directory()
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn moves_the_directory_inside_directory_if_path_to_move_is_nonexistent_directory() {
|
fn moves_the_directory_inside_directory_if_path_to_move_is_nonexistent_directory() {
|
||||||
Playground::setup("mv_test_6", |dirs, playground| {
|
Playground::setup("mv_test_6", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.within("contributors")
|
.within("contributors")
|
||||||
.with_files(vec![EmptyFile("jonathan.txt")])
|
.with_files(vec![EmptyFile("jonathan.txt")])
|
||||||
.mkdir("expected")
|
.mkdir("expected");
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
let original_dir = dirs.test().join("contributors");
|
let original_dir = dirs.test().join("contributors");
|
||||||
|
|
||||||
nu!(
|
nu!(
|
||||||
dirs.test(),
|
cwd(dirs.test()),
|
||||||
"mv contributors expected/this_dir_exists_now/los_tres_amigos"
|
"mv contributors expected/this_dir_exists_now/los_tres_amigos"
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -119,8 +115,8 @@ fn moves_the_directory_inside_directory_if_path_to_move_is_nonexistent_directory
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn moves_using_path_with_wildcard() {
|
fn moves_using_path_with_wildcard() {
|
||||||
Playground::setup("mv_test_7", |dirs, playground| {
|
Playground::setup("mv_test_7", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.within("originals")
|
.within("originals")
|
||||||
.with_files(vec![
|
.with_files(vec![
|
||||||
EmptyFile("andres.ini"),
|
EmptyFile("andres.ini"),
|
||||||
@ -131,16 +127,15 @@ fn moves_using_path_with_wildcard() {
|
|||||||
EmptyFile("sgml_description.json"),
|
EmptyFile("sgml_description.json"),
|
||||||
EmptyFile("sample.ini"),
|
EmptyFile("sample.ini"),
|
||||||
EmptyFile("utf16.ini"),
|
EmptyFile("utf16.ini"),
|
||||||
EmptyFile("yehuda.ini"),
|
EmptyFile("yehuda.ini")
|
||||||
])
|
])
|
||||||
.mkdir("work_dir")
|
.mkdir("work_dir")
|
||||||
.mkdir("expected")
|
.mkdir("expected");
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
let work_dir = dirs.test().join("work_dir");
|
let work_dir = dirs.test().join("work_dir");
|
||||||
let expected = dirs.test().join("expected");
|
let expected = dirs.test().join("expected");
|
||||||
|
|
||||||
nu!(work_dir, "mv ../originals/*.ini ../expected");
|
nu!(cwd(work_dir), "mv ../originals/*.ini ../expected");
|
||||||
|
|
||||||
assert!(h::files_exist_at(
|
assert!(h::files_exist_at(
|
||||||
vec!["yehuda.ini", "jonathan.ini", "sample.ini", "andres.ini",],
|
vec!["yehuda.ini", "jonathan.ini", "sample.ini", "andres.ini",],
|
||||||
@ -151,23 +146,22 @@ fn moves_using_path_with_wildcard() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn moves_using_a_glob() {
|
fn moves_using_a_glob() {
|
||||||
Playground::setup("mv_test_8", |dirs, playground| {
|
Playground::setup("mv_test_8", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.within("meals")
|
.within("meals")
|
||||||
.with_files(vec![
|
.with_files(vec![
|
||||||
EmptyFile("arepa.txt"),
|
EmptyFile("arepa.txt"),
|
||||||
EmptyFile("empanada.txt"),
|
EmptyFile("empanada.txt"),
|
||||||
EmptyFile("taquiza.txt"),
|
EmptyFile("taquiza.txt")
|
||||||
])
|
])
|
||||||
.mkdir("work_dir")
|
.mkdir("work_dir")
|
||||||
.mkdir("expected")
|
.mkdir("expected");
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
let meal_dir = dirs.test().join("meals");
|
let meal_dir = dirs.test().join("meals");
|
||||||
let work_dir = dirs.test().join("work_dir");
|
let work_dir = dirs.test().join("work_dir");
|
||||||
let expected = dirs.test().join("expected");
|
let expected = dirs.test().join("expected");
|
||||||
|
|
||||||
nu!(work_dir, "mv ../meals/* ../expected");
|
nu!(cwd(work_dir), "mv ../meals/* ../expected");
|
||||||
|
|
||||||
assert!(h::dir_exists_at(meal_dir));
|
assert!(h::dir_exists_at(meal_dir));
|
||||||
assert!(h::files_exist_at(
|
assert!(h::files_exist_at(
|
||||||
|
@ -1,106 +1,126 @@
|
|||||||
mod helpers;
|
mod helpers;
|
||||||
|
|
||||||
use helpers::{in_directory as cwd, Playground, Stub::*};
|
use helpers::{in_directory as cwd, Playground, Stub::*};
|
||||||
|
use helpers as h;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn recognizes_csv() {
|
fn recognizes_csv() {
|
||||||
Playground::setup_for("open_recognizes_csv_test").with_files(vec![FileWithContentToBeTrimmed(
|
Playground::setup("open_test_1", |dirs, sandbox| {
|
||||||
"nu.zion.csv",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContentToBeTrimmed(
|
||||||
author,lang,source
|
"nu.zion.csv",
|
||||||
Jonathan Turner,Rust,New Zealand
|
r#"
|
||||||
Andres N. Robalino,Rust,Ecuador
|
author,lang,source
|
||||||
Yehuda Katz,Rust,Estados Unidos
|
Jonathan Turner,Rust,New Zealand
|
||||||
"#,
|
Andres N. Robalino,Rust,Ecuador
|
||||||
)]);
|
Yehuda Katz,Rust,Estados Unidos
|
||||||
|
"#
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/open_recognizes_csv_test"),
|
cwd(dirs.test()), h::pipeline(
|
||||||
r#"open nu.zion.csv | where author == "Andres N. Robalino" | get source | echo $it"#
|
r#"
|
||||||
);
|
open nu.zion.csv
|
||||||
|
| where author == "Andres N. Robalino"
|
||||||
|
| get source
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "Ecuador");
|
assert_eq!(actual, "Ecuador");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn open_can_parse_bson_1() {
|
fn open_can_parse_bson_1() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open sample.bson | get root | nth 0 | get b | echo $it"
|
"open sample.bson | get root | nth 0 | get b | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "hello");
|
assert_eq!(actual, "hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn open_can_parse_bson_2() {
|
fn open_can_parse_bson_2() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"), h::pipeline(
|
||||||
"open sample.bson | get root | nth 6 | get b | get '$binary_subtype' | echo $it "
|
r#"
|
||||||
);
|
open sample.bson
|
||||||
|
| get root
|
||||||
|
| nth 6
|
||||||
|
| get b
|
||||||
|
| get '$binary_subtype'
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "function");
|
assert_eq!(actual, "function");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn open_can_parse_toml() {
|
fn open_can_parse_toml() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open cargo_sample.toml | get package.edition | echo $it"
|
"open cargo_sample.toml | get package.edition | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "2018");
|
assert_eq!(actual, "2018");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn open_can_parse_json() {
|
fn open_can_parse_json() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"), h::pipeline(
|
||||||
"open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it"
|
r#"
|
||||||
);
|
open sgml_description.json
|
||||||
|
| get glossary.GlossDiv.GlossList.GlossEntry.GlossSee
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "markup")
|
assert_eq!(actual, "markup")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn open_can_parse_xml() {
|
fn open_can_parse_xml() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open jonathan.xml | get rss.channel.item.link | echo $it"
|
"open jonathan.xml | get rss.channel.item.link | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
output,
|
actual,
|
||||||
"http://www.jonathanturner.org/2015/10/off-to-new-adventures.html"
|
"http://www.jonathanturner.org/2015/10/off-to-new-adventures.html"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn open_can_parse_ini() {
|
fn open_can_parse_ini() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open sample.ini | get SectionOne.integer | echo $it"
|
"open sample.ini | get SectionOne.integer | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "1234")
|
assert_eq!(actual, "1234")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn open_can_parse_utf16_ini() {
|
fn open_can_parse_utf16_ini() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open utf16.ini | get .ShellClassInfo | get IconIndex | echo $it"
|
"open utf16.ini | get .ShellClassInfo | get IconIndex | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "-236")
|
assert_eq!(actual, "-236")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn errors_if_file_not_found() {
|
fn errors_if_file_not_found() {
|
||||||
let output = nu_error!(
|
let actual = nu_error!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open i_dont_exist.txt | echo $it"
|
"open i_dont_exist.txt | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(output.contains("File could not be opened"));
|
assert!(actual.contains("File could not be opened"));
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,15 @@ mod helpers;
|
|||||||
|
|
||||||
use h::{in_directory as cwd, Playground, Stub::*};
|
use h::{in_directory as cwd, Playground, Stub::*};
|
||||||
use helpers as h;
|
use helpers as h;
|
||||||
use std::path::{Path, PathBuf};
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rm_removes_a_file() {
|
fn rm_removes_a_file() {
|
||||||
Playground::setup("rm_regular_file_test", |dirs, playground| {
|
Playground::setup("rm_test_1", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.with_files(vec![EmptyFile("i_will_be_deleted.txt")])
|
.with_files(vec![EmptyFile("i_will_be_deleted.txt")
|
||||||
.test_dir_name();
|
]);
|
||||||
|
|
||||||
nu!(dirs.root(), "rm rm_regular_file_test/i_will_be_deleted.txt");
|
nu!(cwd(dirs.root()), "rm rm_test_1/i_will_be_deleted.txt");
|
||||||
|
|
||||||
let path = dirs.test().join("i_will_be_deleted.txt");
|
let path = dirs.test().join("i_will_be_deleted.txt");
|
||||||
|
|
||||||
@ -21,13 +20,13 @@ fn rm_removes_a_file() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rm_removes_files_with_wildcard() {
|
fn rm_removes_files_with_wildcard() {
|
||||||
Playground::setup("rm_wildcard_test_1", |dirs, playground| {
|
Playground::setup("rm_test_2", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.within("src")
|
.within("src")
|
||||||
.with_files(vec![
|
.with_files(vec![
|
||||||
EmptyFile("cli.rs"),
|
EmptyFile("cli.rs"),
|
||||||
EmptyFile("lib.rs"),
|
EmptyFile("lib.rs"),
|
||||||
EmptyFile("prelude.rs"),
|
EmptyFile("prelude.rs")
|
||||||
])
|
])
|
||||||
.within("src/parser")
|
.within("src/parser")
|
||||||
.with_files(vec![EmptyFile("parse.rs"), EmptyFile("parser.rs")])
|
.with_files(vec![EmptyFile("parse.rs"), EmptyFile("parser.rs")])
|
||||||
@ -36,11 +35,10 @@ fn rm_removes_files_with_wildcard() {
|
|||||||
.within("src/parser/hir")
|
.within("src/parser/hir")
|
||||||
.with_files(vec![
|
.with_files(vec![
|
||||||
EmptyFile("baseline_parse.rs"),
|
EmptyFile("baseline_parse.rs"),
|
||||||
EmptyFile("baseline_parse_tokens.rs"),
|
EmptyFile("baseline_parse_tokens.rs")
|
||||||
])
|
]);
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
nu!(dirs.test(), r#"rm "src/*/*/*.rs""#);
|
nu!(cwd(dirs.test()), r#"rm "src/*/*/*.rs""#);
|
||||||
|
|
||||||
assert!(!h::files_exist_at(
|
assert!(!h::files_exist_at(
|
||||||
vec![
|
vec![
|
||||||
@ -53,20 +51,20 @@ fn rm_removes_files_with_wildcard() {
|
|||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Playground::glob_vec(&format!("{}/src/*/*/*.rs", dirs.test().display())),
|
Playground::glob_vec(&format!("{}/src/*/*/*.rs", dirs.test().display())),
|
||||||
Vec::<PathBuf>::new()
|
Vec::<std::path::PathBuf>::new()
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rm_removes_deeply_nested_directories_with_wildcard_and_recursive_flag() {
|
fn rm_removes_deeply_nested_directories_with_wildcard_and_recursive_flag() {
|
||||||
Playground::setup("rm_wildcard_test_2", |dirs, playground| {
|
Playground::setup("rm_test_3", |dirs, sandbox| {
|
||||||
playground
|
sandbox
|
||||||
.within("src")
|
.within("src")
|
||||||
.with_files(vec![
|
.with_files(vec![
|
||||||
EmptyFile("cli.rs"),
|
EmptyFile("cli.rs"),
|
||||||
EmptyFile("lib.rs"),
|
EmptyFile("lib.rs"),
|
||||||
EmptyFile("prelude.rs"),
|
EmptyFile("prelude.rs")
|
||||||
])
|
])
|
||||||
.within("src/parser")
|
.within("src/parser")
|
||||||
.with_files(vec![EmptyFile("parse.rs"), EmptyFile("parser.rs")])
|
.with_files(vec![EmptyFile("parse.rs"), EmptyFile("parser.rs")])
|
||||||
@ -75,11 +73,10 @@ fn rm_removes_deeply_nested_directories_with_wildcard_and_recursive_flag() {
|
|||||||
.within("src/parser/hir")
|
.within("src/parser/hir")
|
||||||
.with_files(vec![
|
.with_files(vec![
|
||||||
EmptyFile("baseline_parse.rs"),
|
EmptyFile("baseline_parse.rs"),
|
||||||
EmptyFile("baseline_parse_tokens.rs"),
|
EmptyFile("baseline_parse_tokens.rs")
|
||||||
])
|
]);
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
nu!(dirs.test(), "rm src/* --recursive");
|
nu!(cwd(dirs.test()), "rm src/* --recursive");
|
||||||
|
|
||||||
assert!(!h::files_exist_at(
|
assert!(!h::files_exist_at(
|
||||||
vec!["src/parser/parse", "src/parser/hir"],
|
vec!["src/parser/parse", "src/parser/hir"],
|
||||||
@ -90,8 +87,8 @@ fn rm_removes_deeply_nested_directories_with_wildcard_and_recursive_flag() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rm_removes_directory_contents_without_recursive_flag_if_empty() {
|
fn rm_removes_directory_contents_without_recursive_flag_if_empty() {
|
||||||
Playground::setup("rm_directory_removal_recursively_test_1", |dirs, _| {
|
Playground::setup("rm_test_4", |dirs, _| {
|
||||||
nu!(dirs.root(), "rm rm_directory_removal_recursively_test_1");
|
nu!(cwd(dirs.root()), "rm rm_test_4");
|
||||||
|
|
||||||
assert!(!h::file_exists_at(dirs.test()));
|
assert!(!h::file_exists_at(dirs.test()));
|
||||||
})
|
})
|
||||||
@ -99,67 +96,51 @@ fn rm_removes_directory_contents_without_recursive_flag_if_empty() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rm_removes_directory_contents_with_recursive_flag() {
|
fn rm_removes_directory_contents_with_recursive_flag() {
|
||||||
Playground::setup(
|
Playground::setup("rm_test_5", |dirs, sandbox| {
|
||||||
"rm_directory_removal_recursively_test_2",
|
sandbox
|
||||||
|dirs, playground| {
|
.with_files(vec![
|
||||||
playground
|
EmptyFile("yehuda.txt"),
|
||||||
.with_files(vec![
|
EmptyFile("jonathan.txt"),
|
||||||
EmptyFile("yehuda.txt"),
|
EmptyFile("andres.txt")
|
||||||
EmptyFile("jonathan.txt"),
|
]);
|
||||||
EmptyFile("andres.txt"),
|
|
||||||
])
|
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
nu!(
|
nu!(cwd(dirs.root()), "rm rm_test_5 --recursive");
|
||||||
dirs.root(),
|
|
||||||
"rm rm_directory_removal_recursively_test_2 --recursive"
|
|
||||||
);
|
|
||||||
|
|
||||||
assert!(!h::file_exists_at(dirs.test()));
|
assert!(!h::file_exists_at(dirs.test()));
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rm_errors_if_attempting_to_delete_a_directory_with_content_without_recursive_flag() {
|
fn rm_errors_if_attempting_to_delete_a_directory_with_content_without_recursive_flag() {
|
||||||
Playground::setup(
|
Playground::setup("rm_test_6", |dirs, sandbox| {
|
||||||
"rm_prevent_directory_removal_without_flag_test",
|
sandbox
|
||||||
|dirs, playground| {
|
.with_files(vec![EmptyFile("some_empty_file.txt")
|
||||||
playground
|
]);
|
||||||
.with_files(vec![EmptyFile("some_empty_file.txt")])
|
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
let output = nu_error!(
|
let actual = nu_error!(
|
||||||
dirs.root(),
|
cwd(dirs.root()),
|
||||||
"rm rm_prevent_directory_removal_without_flag_test"
|
"rm rm_test_6"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(h::file_exists_at(dirs.test()));
|
assert!(h::file_exists_at(dirs.test()));
|
||||||
assert!(output.contains("is a directory"));
|
assert!(actual.contains("is a directory"));
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rm_errors_if_attempting_to_delete_single_dot_as_argument() {
|
fn rm_errors_if_attempting_to_delete_single_dot_as_argument() {
|
||||||
Playground::setup(
|
Playground::setup("rm_test_7", |dirs, _| {
|
||||||
"rm_errors_if_attempting_to_delete_single_dot_as_argument",
|
let actual = nu_error!(cwd(dirs.root()), "rm .");
|
||||||
|dirs, _| {
|
|
||||||
let output = nu_error!(dirs.root(), "rm .");
|
|
||||||
|
|
||||||
assert!(output.contains("may not be removed"));
|
assert!(actual.contains("may not be removed"));
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn rm_errors_if_attempting_to_delete_two_dot_as_argument() {
|
fn rm_errors_if_attempting_to_delete_two_dot_as_argument() {
|
||||||
Playground::setup(
|
Playground::setup("rm_test_8", |dirs, _| {
|
||||||
"rm_errors_if_attempting_to_delete_single_dot_as_argument",
|
let actual = nu_error!(cwd(dirs.root()), "rm ..");
|
||||||
|dirs, _| {
|
|
||||||
let output = nu_error!(dirs.root(), "rm ..");
|
|
||||||
|
|
||||||
assert!(output.contains("may not be removed"));
|
assert!(actual.contains("may not be removed"));
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
@ -5,21 +5,20 @@ use helpers as h;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn lines() {
|
fn lines() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
r#"open cargo_sample.toml --raw | lines | skip-while $it != "[dependencies]" | skip 1 | first 1 | split-column "=" | get Column1 | trim | echo $it"#
|
r#"open cargo_sample.toml --raw | lines | skip-while $it != "[dependencies]" | skip 1 | first 1 | split-column "=" | get Column1 | trim | echo $it"#
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "rustyline");
|
assert_eq!(actual, "rustyline");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn save_figures_out_intelligently_where_to_write_out_with_metadata() {
|
fn save_figures_out_intelligently_where_to_write_out_with_metadata() {
|
||||||
Playground::setup("save_smart_test", |dirs, playground| {
|
Playground::setup("save_test_1", |dirs, sandbox| {
|
||||||
playground
|
sandbox.with_files(vec![FileWithContent(
|
||||||
.with_files(vec![FileWithContent(
|
"cargo_sample.toml",
|
||||||
"cargo_sample.toml",
|
r#"
|
||||||
r#"
|
|
||||||
[package]
|
[package]
|
||||||
name = "nu"
|
name = "nu"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
@ -27,15 +26,14 @@ fn save_figures_out_intelligently_where_to_write_out_with_metadata() {
|
|||||||
description = "A shell for the GitHub era"
|
description = "A shell for the GitHub era"
|
||||||
license = "ISC"
|
license = "ISC"
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
"#,
|
"#)
|
||||||
)])
|
]);
|
||||||
.test_dir_name();
|
|
||||||
|
|
||||||
let subject_file = dirs.test().join("cargo_sample.toml");
|
let subject_file = dirs.test().join("cargo_sample.toml");
|
||||||
|
|
||||||
nu!(
|
nu!(
|
||||||
dirs.root(),
|
cwd(dirs.root()),
|
||||||
"open save_smart_test/cargo_sample.toml | inc package.version --minor | save"
|
"open save_test_1/cargo_sample.toml | inc package.version --minor | save"
|
||||||
);
|
);
|
||||||
|
|
||||||
let actual = h::file_contents(&subject_file);
|
let actual = h::file_contents(&subject_file);
|
||||||
@ -45,12 +43,12 @@ fn save_figures_out_intelligently_where_to_write_out_with_metadata() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn save_can_write_out_csv() {
|
fn save_can_write_out_csv() {
|
||||||
Playground::setup("save_writes_out_csv_test", |dirs, playground| {
|
Playground::setup("save_test_2", |dirs, _| {
|
||||||
let expected_file = dirs.test().join("cargo_sample.csv");
|
let expected_file = dirs.test().join("cargo_sample.csv");
|
||||||
|
|
||||||
nu!(
|
nu!(
|
||||||
dirs.root(),
|
dirs.root(),
|
||||||
"open {}/cargo_sample.toml | inc package.version --minor | get package | save save_writes_out_csv_test/cargo_sample.csv",
|
"open {}/cargo_sample.toml | inc package.version --minor | get package | save save_test_2/cargo_sample.csv",
|
||||||
dirs.formats()
|
dirs.formats()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use helpers::in_directory as cwd;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn external_command() {
|
fn external_command() {
|
||||||
let output = nu!(cwd("tests/fixtures"), "echo 1");
|
let actual = nu!(cwd("tests/fixtures"), "echo 1");
|
||||||
|
|
||||||
assert!(output.contains("1"));
|
assert!(actual.contains("1"));
|
||||||
}
|
}
|
||||||
|
@ -5,124 +5,136 @@ use helpers as h;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_only_apply_one() {
|
fn can_only_apply_one() {
|
||||||
let output = nu_error!(
|
let actual = nu_error!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open cargo_sample.toml | first 1 | inc package.version --major --minor"
|
"open cargo_sample.toml | first 1 | inc package.version --major --minor"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(output.contains("Usage: inc field [--major|--minor|--patch]"));
|
assert!(actual.contains("Usage: inc field [--major|--minor|--patch]"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn by_one_with_field_passed() {
|
fn by_one_with_field_passed() {
|
||||||
Playground::setup_for("plugin_inc_by_one_with_field_passed_test").with_files(vec![
|
Playground::setup("plugin_inc_test_1", |dirs, sandbox| {
|
||||||
FileWithContent(
|
sandbox
|
||||||
"sample.toml",
|
.with_files(vec![FileWithContent(
|
||||||
r#"
|
"sample.toml",
|
||||||
[package]
|
r#"
|
||||||
edition = "2018"
|
[package]
|
||||||
"#,
|
edition = "2018"
|
||||||
),
|
"#
|
||||||
]);
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/plugin_inc_by_one_with_field_passed_test"),
|
cwd(dirs.test()),
|
||||||
"open sample.toml | inc package.edition | get package.edition | echo $it"
|
"open sample.toml | inc package.edition | get package.edition | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "2019");
|
assert_eq!(actual, "2019");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn by_one_with_no_field_passed() {
|
fn by_one_with_no_field_passed() {
|
||||||
Playground::setup_for("plugin_inc_by_one_with_no_field_passed_test").with_files(vec![
|
Playground::setup("plugin_inc_test_2", |dirs, sandbox| {
|
||||||
FileWithContent(
|
sandbox
|
||||||
"sample.toml",
|
.with_files(vec![FileWithContent(
|
||||||
r#"
|
"sample.toml",
|
||||||
[package]
|
r#"
|
||||||
contributors = "2"
|
[package]
|
||||||
"#,
|
contributors = "2"
|
||||||
),
|
"#
|
||||||
]);
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/plugin_inc_by_one_with_no_field_passed_test"),
|
cwd(dirs.test()),
|
||||||
"open sample.toml | get package.contributors | inc | echo $it"
|
"open sample.toml | get package.contributors | inc | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "3");
|
assert_eq!(actual, "3");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn semversion_major_inc() {
|
fn semversion_major_inc() {
|
||||||
Playground::setup_for("plugin_inc_major_semversion_test").with_files(vec![FileWithContent(
|
Playground::setup("plugin_inc_test_3", |dirs, sandbox| {
|
||||||
"sample.toml",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContent(
|
||||||
[package]
|
"sample.toml",
|
||||||
version = "0.1.3"
|
r#"
|
||||||
"#,
|
[package]
|
||||||
)]);
|
version = "0.1.3"
|
||||||
|
"#
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/plugin_inc_major_semversion_test"),
|
cwd(dirs.test()),
|
||||||
"open sample.toml | inc package.version --major | get package.version | echo $it"
|
"open sample.toml | inc package.version --major | get package.version | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "1.0.0");
|
assert_eq!(actual, "1.0.0");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn semversion_minor_inc() {
|
fn semversion_minor_inc() {
|
||||||
Playground::setup_for("plugin_inc_minor_semversion_test").with_files(vec![FileWithContent(
|
Playground::setup("plugin_inc_test_4", |dirs, sandbox| {
|
||||||
"sample.toml",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContent(
|
||||||
[package]
|
"sample.toml",
|
||||||
version = "0.1.3"
|
r#"
|
||||||
"#,
|
[package]
|
||||||
)]);
|
version = "0.1.3"
|
||||||
|
"#
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/plugin_inc_minor_semversion_test"),
|
cwd(dirs.test()),
|
||||||
"open sample.toml | inc package.version --minor | get package.version | echo $it"
|
"open sample.toml | inc package.version --minor | get package.version | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "0.2.0");
|
assert_eq!(actual, "0.2.0");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn semversion_patch_inc() {
|
fn semversion_patch_inc() {
|
||||||
Playground::setup_for("plugin_inc_patch_semversion_test").with_files(vec![FileWithContent(
|
Playground::setup("plugin_inc_test_5", |dirs, sandbox| {
|
||||||
"sample.toml",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContent(
|
||||||
[package]
|
"sample.toml",
|
||||||
version = "0.1.3"
|
r#"
|
||||||
"#,
|
[package]
|
||||||
)]);
|
version = "0.1.3"
|
||||||
|
"#
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/plugin_inc_patch_semversion_test"),
|
cwd(dirs.test()),
|
||||||
"open sample.toml | inc package.version --patch | get package.version | echo $it"
|
"open sample.toml | inc package.version --patch | get package.version | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "0.1.4");
|
assert_eq!(actual, "0.1.4");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn semversion_without_passing_field() {
|
fn semversion_without_passing_field() {
|
||||||
Playground::setup_for("plugin_inc_semversion_without_passing_field_test").with_files(vec![
|
Playground::setup("plugin_inc_test_6", |dirs, sandbox| {
|
||||||
FileWithContent(
|
sandbox
|
||||||
"sample.toml",
|
.with_files(vec![FileWithContent(
|
||||||
r#"
|
"sample.toml",
|
||||||
[package]
|
r#"
|
||||||
version = "0.1.3"
|
[package]
|
||||||
"#,
|
version = "0.1.3"
|
||||||
),
|
"#
|
||||||
]);
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/plugin_inc_semversion_without_passing_field_test"),
|
cwd(dirs.test()),
|
||||||
"open sample.toml | get package.version | inc --patch | echo $it"
|
"open sample.toml | get package.version | inc --patch | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "0.1.4");
|
assert_eq!(actual, "0.1.4");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,135 +5,170 @@ use helpers as h;
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_only_apply_one() {
|
fn can_only_apply_one() {
|
||||||
let output = nu_error!(
|
let actual = nu_error!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open caco3_plastics.csv | first 1 | str origin --downcase --upcase"
|
"open caco3_plastics.csv | first 1 | str origin --downcase --upcase"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
output.contains("Usage: str field [--downcase|--upcase|--to-int|--replace|--find-replace]")
|
actual.contains("Usage: str field [--downcase|--upcase|--to-int|--replace|--find-replace]")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn acts_without_passing_field() {
|
fn acts_without_passing_field() {
|
||||||
Playground::setup_for("plugin_str_acts_without_passing_field_test").with_files(vec![
|
Playground::setup("plugin_str_test_1", |dirs, sandbox| {
|
||||||
FileWithContent(
|
sandbox.with_files(vec![FileWithContent(
|
||||||
"sample.yml",
|
"sample.yml",
|
||||||
r#"
|
r#"
|
||||||
environment:
|
environment:
|
||||||
global:
|
global:
|
||||||
PROJECT_NAME: nushell
|
PROJECT_NAME: nushell
|
||||||
"#,
|
"#,
|
||||||
),
|
)]);
|
||||||
]);
|
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/plugin_str_acts_without_passing_field_test"),
|
cwd(dirs.test()),
|
||||||
"open sample.yml | get environment.global.PROJECT_NAME | str --upcase | echo $it"
|
"open sample.yml | get environment.global.PROJECT_NAME | str --upcase | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "NUSHELL");
|
assert_eq!(actual, "NUSHELL");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn downcases() {
|
fn downcases() {
|
||||||
Playground::setup_for("plugin_str_downcases_test").with_files(vec![FileWithContent(
|
Playground::setup("plugin_str_test_2", |dirs, sandbox| {
|
||||||
"sample.toml",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContent(
|
||||||
[dependency]
|
"sample.toml",
|
||||||
name = "LIGHT"
|
r#"
|
||||||
"#,
|
[dependency]
|
||||||
)]);
|
name = "LIGHT"
|
||||||
|
"#,
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/plugin_str_downcases_test"),
|
cwd(dirs.test()),
|
||||||
"open sample.toml | str dependency.name --downcase | get dependency.name | echo $it"
|
"open sample.toml | str dependency.name --downcase | get dependency.name | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "light");
|
assert_eq!(actual, "light");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn upcases() {
|
fn upcases() {
|
||||||
Playground::setup_for("plugin_str_upcases_test").with_files(vec![FileWithContent(
|
Playground::setup("plugin_str_test_3", |dirs, sandbox| {
|
||||||
"sample.toml",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContent(
|
||||||
[package]
|
"sample.toml",
|
||||||
name = "nushell"
|
r#"
|
||||||
"#,
|
[package]
|
||||||
)]);
|
name = "nushell"
|
||||||
|
"#,
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/plugin_str_upcases_test"),
|
cwd(dirs.test()),
|
||||||
"open sample.toml | str package.name --upcase | get package.name | echo $it"
|
"open sample.toml | str package.name --upcase | get package.name | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "NUSHELL");
|
assert_eq!(actual, "NUSHELL");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn converts_to_int() {
|
fn converts_to_int() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"), h::pipeline(
|
||||||
"open caco3_plastics.csv | first 1 | str tariff_item --to-int | where tariff_item == 2509000000 | get tariff_item | echo $it"
|
r#"
|
||||||
);
|
open caco3_plastics.csv
|
||||||
|
| first 1
|
||||||
|
| str tariff_item --to-int
|
||||||
|
| where tariff_item == 2509000000
|
||||||
|
| get tariff_item
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "2509000000");
|
assert_eq!(actual, "2509000000");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn replaces() {
|
fn replaces() {
|
||||||
Playground::setup_for("plugin_str_replaces_test").with_files(vec![FileWithContent(
|
Playground::setup("plugin_str_test_4", |dirs, sandbox| {
|
||||||
"sample.toml",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContent(
|
||||||
[package]
|
"sample.toml",
|
||||||
name = "nushell"
|
r#"
|
||||||
"#,
|
[package]
|
||||||
)]);
|
name = "nushell"
|
||||||
|
"#,
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/plugin_str_replaces_test"),
|
cwd(dirs.test()), h::pipeline(
|
||||||
"open sample.toml | str package.name --replace wykittenshell | get package.name | echo $it"
|
r#"
|
||||||
);
|
open sample.toml
|
||||||
|
| str package.name --replace wykittenshell
|
||||||
|
| get package.name
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "wykittenshell");
|
assert_eq!(actual, "wykittenshell");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn find_and_replaces() {
|
fn find_and_replaces() {
|
||||||
Playground::setup_for("plugin_str_find_and_replaces_test").with_files(vec![FileWithContent(
|
Playground::setup("plugin_str_test_5", |dirs, sandbox| {
|
||||||
"sample.toml",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContent(
|
||||||
[fortune.teller]
|
"sample.toml",
|
||||||
phone = "1-800-KATZ"
|
r#"
|
||||||
"#,
|
[fortune.teller]
|
||||||
)]);
|
phone = "1-800-KATZ"
|
||||||
|
"#,
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/plugin_str_find_and_replaces_test"),
|
cwd(dirs.test()), h::pipeline(
|
||||||
r#"open sample.toml | str fortune.teller.phone --find-replace KATZ "5289" | get fortune.teller.phone | echo $it"#
|
r#"
|
||||||
);
|
open sample.toml
|
||||||
|
| str fortune.teller.phone --find-replace KATZ "5289"
|
||||||
|
| get fortune.teller.phone
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "1-800-5289");
|
assert_eq!(actual, "1-800-5289");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn find_and_replaces_without_passing_field() {
|
fn find_and_replaces_without_passing_field() {
|
||||||
Playground::setup_for("plugin_str_find_and_replaces_without_passing_field_test").with_files(
|
Playground::setup("plugin_str_test_6", |dirs, sandbox| {
|
||||||
vec![FileWithContent(
|
sandbox
|
||||||
|
.with_files(vec![FileWithContent(
|
||||||
"sample.toml",
|
"sample.toml",
|
||||||
|
r#"
|
||||||
|
[fortune.teller]
|
||||||
|
phone = "1-800-KATZ"
|
||||||
|
"#,
|
||||||
|
)]);
|
||||||
|
|
||||||
|
let actual = nu!(
|
||||||
|
cwd(dirs.test()), h::pipeline(
|
||||||
r#"
|
r#"
|
||||||
[fortune.teller]
|
open sample.toml
|
||||||
phone = "1-800-KATZ"
|
| get fortune.teller.phone
|
||||||
"#,
|
| str --find-replace KATZ "5289"
|
||||||
)],
|
| echo $it
|
||||||
);
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
let output = nu!(
|
assert_eq!(actual, "1-800-5289");
|
||||||
cwd("tests/fixtures/nuplayground/plugin_str_find_and_replaces_without_passing_field_test"),
|
})
|
||||||
r#"open sample.toml | get fortune.teller.phone | str --find-replace KATZ "5289" | echo $it"#
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(output, "1-800-5289");
|
|
||||||
}
|
}
|
||||||
|
@ -1,263 +1,360 @@
|
|||||||
mod helpers;
|
mod helpers;
|
||||||
|
|
||||||
use helpers::{in_directory as cwd, Playground, Stub::*};
|
use helpers::{in_directory as cwd, Playground, Stub::*};
|
||||||
|
use helpers as h;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_convert_table_to_csv_text_and_from_csv_text_back_into_table() {
|
fn can_convert_table_to_csv_text_and_from_csv_text_back_into_table() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open caco3_plastics.csv | to-csv | from-csv | first 1 | get origin | echo $it"
|
"open caco3_plastics.csv | to-csv | from-csv | first 1 | get origin | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "SPAIN");
|
assert_eq!(actual, "SPAIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn converts_structured_table_to_csv_text() {
|
fn converts_structured_table_to_csv_text() {
|
||||||
Playground::setup_for("filter_to_csv_test_1").with_files(vec![FileWithContentToBeTrimmed(
|
Playground::setup("filter_to_csv_test_1", |dirs, sandbox| {
|
||||||
"sample.txt",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContentToBeTrimmed(
|
||||||
importer,shipper,tariff_item,name,origin
|
"csv_text_sample.txt",
|
||||||
Plasticos Rival,Reverte,2509000000,Calcium carbonate,Spain
|
r#"
|
||||||
Tigre Ecuador,OMYA Andina,3824909999,Calcium carbonate,Colombia
|
importer,shipper,tariff_item,name,origin
|
||||||
"#,
|
Plasticos Rival,Reverte,2509000000,Calcium carbonate,Spain
|
||||||
)]);
|
Tigre Ecuador,OMYA Andina,3824909999,Calcium carbonate,Colombia
|
||||||
|
"#
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/filter_to_csv_test_1"),
|
cwd(dirs.test()), h::pipeline(
|
||||||
r#"open sample.txt | lines | split-column "," a b c d origin | last 1 | to-csv | lines | nth 1 | echo "$it""#
|
r#"
|
||||||
);
|
open csv_text_sample.txt
|
||||||
|
| lines
|
||||||
|
| split-column "," a b c d origin
|
||||||
|
| last 1
|
||||||
|
| to-csv
|
||||||
|
| lines
|
||||||
|
| nth 1
|
||||||
|
| echo "$it"
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert!(output.contains("Tigre Ecuador,OMYA Andina,3824909999,Calcium carbonate,Colombia"));
|
assert!(actual.contains("Tigre Ecuador,OMYA Andina,3824909999,Calcium carbonate,Colombia"));
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn converts_structured_table_to_csv_text_skipping_headers_after_conversion() {
|
fn converts_structured_table_to_csv_text_skipping_headers_after_conversion() {
|
||||||
Playground::setup_for("filter_to_csv_test_2").with_files(vec![FileWithContentToBeTrimmed(
|
Playground::setup("filter_to_csv_test_2", |dirs, sandbox| {
|
||||||
"sample.txt",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContentToBeTrimmed(
|
||||||
importer,shipper,tariff_item,name,origin
|
"csv_text_sample.txt",
|
||||||
Plasticos Rival,Reverte,2509000000,Calcium carbonate,Spain
|
r#"
|
||||||
Tigre Ecuador,OMYA Andina,3824909999,Calcium carbonate,Colombia
|
importer,shipper,tariff_item,name,origin
|
||||||
"#,
|
Plasticos Rival,Reverte,2509000000,Calcium carbonate,Spain
|
||||||
)]);
|
Tigre Ecuador,OMYA Andina,3824909999,Calcium carbonate,Colombia
|
||||||
|
"#
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/filter_to_csv_test_2"),
|
cwd(dirs.test()), h::pipeline(
|
||||||
r#"open sample.txt | lines | split-column "," a b c d origin | last 1 | to-csv --headerless | echo "$it""#
|
r#"
|
||||||
);
|
open csv_text_sample.txt
|
||||||
|
| lines
|
||||||
|
| split-column "," a b c d origin
|
||||||
|
| last 1
|
||||||
|
| to-csv --headerless
|
||||||
|
| echo "$it"
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert!(output.contains("Tigre Ecuador,OMYA Andina,3824909999,Calcium carbonate,Colombia"));
|
assert!(actual.contains("Tigre Ecuador,OMYA Andina,3824909999,Calcium carbonate,Colombia"));
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn converts_from_csv_text_to_structured_table() {
|
fn converts_from_csv_text_to_structured_table() {
|
||||||
Playground::setup_for("filter_from_csv_test_1").with_files(vec![FileWithContentToBeTrimmed(
|
Playground::setup("filter_from_csv_test_1", |dirs, sandbox| {
|
||||||
"los_tres_amigos.txt",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContentToBeTrimmed(
|
||||||
first_name,last_name,rusty_luck
|
"los_tres_amigos.txt",
|
||||||
Andrés,Robalino,1
|
r#"
|
||||||
Jonathan,Turner,1
|
first_name,last_name,rusty_luck
|
||||||
Yehuda,Katz,1
|
Andrés,Robalino,1
|
||||||
"#,
|
Jonathan,Turner,1
|
||||||
)]);
|
Yehuda,Katz,1
|
||||||
|
"#,
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/filter_from_csv_test_1"),
|
cwd(dirs.test()), h::pipeline(
|
||||||
"open los_tres_amigos.txt | from-csv | get rusty_luck | str --to-int | sum | echo $it"
|
r#"
|
||||||
);
|
open los_tres_amigos.txt
|
||||||
|
| from-csv
|
||||||
|
| get rusty_luck
|
||||||
|
| str --to-int
|
||||||
|
| sum
|
||||||
|
| echo "$it"
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "3");
|
assert_eq!(actual, "3");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn converts_from_csv_text_skipping_headers_to_structured_table() {
|
fn converts_from_csv_text_skipping_headers_to_structured_table() {
|
||||||
Playground::setup_for("filter_from_csv_test_2").with_files(vec![FileWithContentToBeTrimmed(
|
Playground::setup("filter_from_csv_test_2", |dirs, sandbox| {
|
||||||
"los_tres_amigos.txt",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContentToBeTrimmed(
|
||||||
first_name,last_name,rusty_luck
|
"los_tres_amigos.txt",
|
||||||
Andrés,Robalino,1
|
r#"
|
||||||
Jonathan,Turner,1
|
first_name,last_name,rusty_luck
|
||||||
Yehuda,Katz,1
|
Andrés,Robalino,1
|
||||||
"#,
|
Jonathan,Turner,1
|
||||||
)]);
|
Yehuda,Katz,1
|
||||||
|
"#,
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/filter_from_csv_test_2"),
|
cwd(dirs.test()), h::pipeline(
|
||||||
"open los_tres_amigos.txt | from-csv --headerless | get Column3 | str --to-int | sum | echo $it"
|
r#"
|
||||||
);
|
open los_tres_amigos.txt
|
||||||
|
| from-csv --headerless
|
||||||
|
| get Column3
|
||||||
|
| str --to-int
|
||||||
|
| sum
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "3");
|
assert_eq!(actual, "3");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_convert_table_to_json_text_and_from_json_text_back_into_table() {
|
fn can_convert_table_to_json_text_and_from_json_text_back_into_table() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"), h::pipeline(
|
||||||
"open sgml_description.json | to-json | from-json | get glossary.GlossDiv.GlossList.GlossEntry.GlossSee | echo $it"
|
r#"
|
||||||
);
|
open sgml_description.json
|
||||||
|
| to-json
|
||||||
|
| from-json
|
||||||
|
| get glossary.GlossDiv.GlossList.GlossEntry.GlossSee
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "markup");
|
assert_eq!(actual, "markup");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn converts_from_json_text_to_structured_table() {
|
fn converts_from_json_text_to_structured_table() {
|
||||||
Playground::setup_for("filter_from_json_test_1").with_files(vec![FileWithContentToBeTrimmed(
|
Playground::setup("filter_from_json_test_1", |dirs, sandbox| {
|
||||||
"katz.txt",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContentToBeTrimmed(
|
||||||
{
|
"katz.txt",
|
||||||
"katz": [
|
r#"
|
||||||
{"name": "Yehuda", "rusty_luck": 1},
|
{
|
||||||
{"name": "Jonathan", "rusty_luck": 1},
|
"katz": [
|
||||||
{"name": "Andres", "rusty_luck": 1},
|
{"name": "Yehuda", "rusty_luck": 1},
|
||||||
{"name":"GorbyPuff", "rusty_luck": 1}
|
{"name": "Jonathan", "rusty_luck": 1},
|
||||||
]
|
{"name": "Andres", "rusty_luck": 1},
|
||||||
}
|
{"name":"GorbyPuff", "rusty_luck": 1}
|
||||||
"#,
|
]
|
||||||
)]);
|
}
|
||||||
|
"#,
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/filter_from_json_test_1"),
|
cwd(dirs.test()),
|
||||||
"open katz.txt | from-json | get katz | get rusty_luck | sum | echo $it"
|
"open katz.txt | from-json | get katz | get rusty_luck | sum | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "4");
|
assert_eq!(actual, "4");
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn converts_from_json_text_recognizing_objects_independendtly_to_structured_table() {
|
fn converts_from_json_text_recognizing_objects_independendtly_to_structured_table() {
|
||||||
Playground::setup_for("filter_from_json_test_2").with_files(vec![FileWithContentToBeTrimmed(
|
Playground::setup("filter_from_json_test_2", |dirs, sandbox| {
|
||||||
"katz.txt",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContentToBeTrimmed(
|
||||||
{"name": "Yehuda", "rusty_luck": 1}
|
"katz.txt",
|
||||||
{"name": "Jonathan", "rusty_luck": 1}
|
r#"
|
||||||
{"name": "Andres", "rusty_luck": 1}
|
{"name": "Yehuda", "rusty_luck": 1}
|
||||||
{"name":"GorbyPuff", "rusty_luck": 3}
|
{"name": "Jonathan", "rusty_luck": 1}
|
||||||
"#,
|
{"name": "Andres", "rusty_luck": 1}
|
||||||
)]);
|
{"name":"GorbyPuff", "rusty_luck": 3}
|
||||||
|
"#,
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/filter_from_json_test_2"),
|
cwd(dirs.test()), h::pipeline(
|
||||||
r#"open katz.txt | from-json --objects | where name == "GorbyPuff" | get rusty_luck | echo $it"#
|
r#"
|
||||||
);
|
open katz.txt
|
||||||
|
| from-json --objects
|
||||||
|
| where name == "GorbyPuff"
|
||||||
|
| get rusty_luck
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "3");
|
assert_eq!(actual, "3");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn converts_structured_table_to_json_text() {
|
fn converts_structured_table_to_json_text() {
|
||||||
Playground::setup_for("filter_to_json_test_1").with_files(vec![FileWithContentToBeTrimmed(
|
Playground::setup("filter_to_json_test", |dirs, sandbox| {
|
||||||
"sample.txt",
|
sandbox
|
||||||
r#"
|
.with_files(vec![FileWithContentToBeTrimmed(
|
||||||
JonAndrehudaTZ,3
|
"sample.txt",
|
||||||
GorbyPuff,100
|
r#"
|
||||||
"#,
|
JonAndrehudaTZ,3
|
||||||
)]);
|
GorbyPuff,100
|
||||||
|
"#,
|
||||||
|
)]);
|
||||||
|
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/nuplayground/filter_to_json_test_1"),
|
cwd(dirs.test()), h::pipeline(
|
||||||
r#"open sample.txt | lines | split-column "," name luck | pick name | to-json | nth 0 | from-json | get name | echo $it"#
|
r#"
|
||||||
);
|
open sample.txt
|
||||||
|
| lines
|
||||||
|
| split-column "," name luck
|
||||||
|
| pick name
|
||||||
|
| to-json
|
||||||
|
| nth 0
|
||||||
|
| from-json
|
||||||
|
| get name
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "JonAndrehudaTZ");
|
assert_eq!(actual, "JonAndrehudaTZ");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_convert_json_text_to_bson_and_back_into_table() {
|
fn can_convert_json_text_to_bson_and_back_into_table() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open sample.bson | to-bson | from-bson | get root | nth 1 | get b | echo $it"
|
"open sample.bson | to-bson | from-bson | get root | nth 1 | get b | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "whel");
|
assert_eq!(actual, "whel");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_convert_table_to_toml_text_and_from_toml_text_back_into_table() {
|
fn can_convert_table_to_toml_text_and_from_toml_text_back_into_table() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"open cargo_sample.toml | to-toml | from-toml | get package.name | echo $it"
|
"open cargo_sample.toml | to-toml | from-toml | get package.name | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "nu");
|
assert_eq!(actual, "nu");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_convert_table_to_yaml_text_and_from_yaml_text_back_into_table() {
|
fn can_convert_table_to_yaml_text_and_from_yaml_text_back_into_table() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"), h::pipeline(
|
||||||
"open appveyor.yml | to-yaml | from-yaml | get environment.global.PROJECT_NAME | echo $it"
|
r#"
|
||||||
);
|
open appveyor.yml
|
||||||
|
| to-yaml
|
||||||
|
| from-yaml
|
||||||
|
| get environment.global.PROJECT_NAME
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "nushell");
|
assert_eq!(actual, "nushell");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_sort_by_column() {
|
fn can_sort_by_column() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"), h::pipeline(
|
||||||
r#"open cargo_sample.toml --raw | lines | skip 1 | first 4 | split-column "=" | sort-by Column1 | skip 1 | first 1 | get Column1 | trim | echo $it"#
|
r#"
|
||||||
);
|
open cargo_sample.toml --raw
|
||||||
|
| lines
|
||||||
|
| skip 1
|
||||||
|
| first 4
|
||||||
|
| split-column "="
|
||||||
|
| sort-by Column1
|
||||||
|
| skip 1
|
||||||
|
| first 1
|
||||||
|
| get Column1
|
||||||
|
| trim
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "description");
|
assert_eq!(actual, "description");
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn can_sort_by_column_reverse() {
|
|
||||||
let output = nu!(
|
|
||||||
cwd("tests/fixtures/formats"),
|
|
||||||
r#"open cargo_sample.toml --raw | lines | skip 1 | first 4 | split-column "=" | sort-by Column1 --reverse | skip 1 | first 1 | get Column1 | trim | echo $it"#
|
|
||||||
);
|
|
||||||
|
|
||||||
assert_eq!(output, "name");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_split_by_column() {
|
fn can_split_by_column() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"), h::pipeline(
|
||||||
r#"open cargo_sample.toml --raw | lines | skip 1 | first 1 | split-column "=" | get Column1 | trim | echo $it"#
|
r#"
|
||||||
);
|
open cargo_sample.toml --raw
|
||||||
|
| lines
|
||||||
|
| skip 1
|
||||||
|
| first 1
|
||||||
|
| split-column "="
|
||||||
|
| get Column1
|
||||||
|
| trim
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "name");
|
assert_eq!(actual, "name");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_sum() {
|
fn can_sum() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"), h::pipeline(
|
||||||
"open sgml_description.json | get glossary.GlossDiv.GlossList.GlossEntry.Sections | sum | echo $it"
|
r#"
|
||||||
);
|
open sgml_description.json
|
||||||
|
| get glossary.GlossDiv.GlossList.GlossEntry.Sections
|
||||||
|
| sum
|
||||||
|
| echo $it
|
||||||
|
"#
|
||||||
|
));
|
||||||
|
|
||||||
assert_eq!(output, "203")
|
assert_eq!(actual, "203")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_filter_by_unit_size_comparison() {
|
fn can_filter_by_unit_size_comparison() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"ls | where size > 1kb | sort-by size | get name | skip 1 | trim | echo $it"
|
"ls | where size > 1kb | sort-by size | get name | skip 1 | trim | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "caco3_plastics.csv");
|
assert_eq!(actual, "caco3_plastics.csv");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_get_last() {
|
fn can_get_last() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"ls | sort-by name | last 1 | get name | trim | echo $it"
|
"ls | sort-by name | last 1 | get name | trim | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "utf16.ini");
|
assert_eq!(actual, "utf16.ini");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn can_get_reverse_first() {
|
fn can_get_reverse_first() {
|
||||||
let output = nu!(
|
let actual = nu!(
|
||||||
cwd("tests/fixtures/formats"),
|
cwd("tests/fixtures/formats"),
|
||||||
"ls | sort-by name | reverse | first 1 | get name | trim | echo $it"
|
"ls | sort-by name | reverse | first 1 | get name | trim | echo $it"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(output, "utf16.ini");
|
assert_eq!(actual, "utf16.ini");
|
||||||
}
|
}
|
||||||
|
@ -176,17 +176,26 @@ impl Playground {
|
|||||||
self.root.path()
|
self.root.path()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn test_dir_name(&self) -> String {
|
|
||||||
self.tests.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn back_to_playground(&mut self) -> &mut Self {
|
pub fn back_to_playground(&mut self) -> &mut Self {
|
||||||
self.cwd = PathBuf::from(self.root()).join(self.tests.clone());
|
self.cwd = PathBuf::from(self.root()).join(self.tests.clone());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setup(topic: &str, block: impl FnOnce(Dirs, &mut Playground)) {
|
pub fn setup(topic: &str, block: impl FnOnce(Dirs, &mut Playground)) {
|
||||||
let mut playground = Playground::setup_for(topic);
|
let root = tempdir().expect("Couldn't create a tempdir");
|
||||||
|
let nuplay_dir = root.path().join(topic);
|
||||||
|
|
||||||
|
if PathBuf::from(&nuplay_dir).exists() {
|
||||||
|
std::fs::remove_dir_all(PathBuf::from(&nuplay_dir)).expect("can not remove directory");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::fs::create_dir(PathBuf::from(&nuplay_dir)).expect("can not create directory");
|
||||||
|
|
||||||
|
let mut playground = Playground {
|
||||||
|
root: root,
|
||||||
|
tests: topic.to_string(),
|
||||||
|
cwd: nuplay_dir,
|
||||||
|
};
|
||||||
|
|
||||||
let project_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
let project_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
||||||
let playground_root = playground.root.path();
|
let playground_root = playground.root.path();
|
||||||
@ -219,23 +228,6 @@ impl Playground {
|
|||||||
block(dirs, &mut playground);
|
block(dirs, &mut playground);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setup_for(topic: &str) -> Playground {
|
|
||||||
let root = tempdir().expect("Couldn't create a tempdir");
|
|
||||||
let nuplay_dir = root.path().join(topic);
|
|
||||||
|
|
||||||
if PathBuf::from(&nuplay_dir).exists() {
|
|
||||||
std::fs::remove_dir_all(PathBuf::from(&nuplay_dir)).expect("can not remove directory");
|
|
||||||
}
|
|
||||||
|
|
||||||
std::fs::create_dir(PathBuf::from(&nuplay_dir)).expect("can not create directory");
|
|
||||||
|
|
||||||
Playground {
|
|
||||||
root: root,
|
|
||||||
tests: topic.to_string(),
|
|
||||||
cwd: nuplay_dir,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn mkdir(&mut self, directory: &str) -> &mut Self {
|
pub fn mkdir(&mut self, directory: &str) -> &mut Self {
|
||||||
self.cwd.push(directory);
|
self.cwd.push(directory);
|
||||||
std::fs::create_dir_all(&self.cwd).expect("can not create directory");
|
std::fs::create_dir_all(&self.cwd).expect("can not create directory");
|
||||||
@ -376,3 +368,10 @@ pub fn executable_path() -> PathBuf {
|
|||||||
pub fn in_directory(str: impl AsRef<Path>) -> String {
|
pub fn in_directory(str: impl AsRef<Path>) -> String {
|
||||||
str.as_ref().display().to_string()
|
str.as_ref().display().to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn pipeline(commands: &str) -> String {
|
||||||
|
commands.lines()
|
||||||
|
.skip(1)
|
||||||
|
.collect::<Vec<&str>>()
|
||||||
|
.concat()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user