mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 07:16:05 +02:00
Rust 1.85, edition=2024 (#15741)
This commit is contained in:
@ -62,9 +62,11 @@ fn concat_assign_type_mismatch() {
|
||||
$a ++= 'str'
|
||||
"#);
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("nu::parser::operator_incompatible_types"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("nu::parser::operator_incompatible_types")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -74,7 +76,9 @@ fn concat_assign_runtime_type_mismatch() {
|
||||
$a ++= if true { 'str' }
|
||||
"#);
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("nu::shell::operator_incompatible_types"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("nu::shell::operator_incompatible_types")
|
||||
);
|
||||
}
|
||||
|
@ -262,11 +262,12 @@ fn test_change_windows_drive() {
|
||||
subst Z: /d
|
||||
"#
|
||||
);
|
||||
assert!(dirs
|
||||
.test()
|
||||
.join("test_folder")
|
||||
.join("test_file.txt")
|
||||
.exists());
|
||||
assert!(
|
||||
dirs.test()
|
||||
.join("test_folder")
|
||||
.join("test_file.txt")
|
||||
.exists()
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,9 @@ fn list_stream() {
|
||||
|
||||
#[test]
|
||||
fn table_stream() {
|
||||
let actual = nu!("([[foo bar]; [0 1] [2 3] [4 5]] | every 1 | chunks 2) == ([[foo bar]; [0 1] [2 3] [4 5]] | chunks 2)");
|
||||
let actual = nu!(
|
||||
"([[foo bar]; [0 1] [2 3] [4 5]] | every 1 | chunks 2) == ([[foo bar]; [0 1] [2 3] [4 5]] | chunks 2)"
|
||||
);
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,9 @@ fn capture_error_with_both_stdout_stderr_messages_not_hang_nushell() {
|
||||
|
||||
#[test]
|
||||
fn combined_pipe_redirection() {
|
||||
let actual = nu!("$env.FOO = 'hello'; $env.BAR = 'world'; nu --testbin echo_env_mixed out-err FOO BAR o+e>| complete | get stdout");
|
||||
let actual = nu!(
|
||||
"$env.FOO = 'hello'; $env.BAR = 'world'; nu --testbin echo_env_mixed out-err FOO BAR o+e>| complete | get stdout"
|
||||
);
|
||||
assert_eq!(actual.out, "helloworld");
|
||||
}
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
use chrono::{DateTime, FixedOffset};
|
||||
use nu_path::AbsolutePathBuf;
|
||||
use nu_protocol::{ast::PathMember, engine::EngineState, record, Span, Value};
|
||||
use nu_protocol::{Span, Value, ast::PathMember, engine::EngineState, record};
|
||||
use nu_test_support::{
|
||||
fs::{line_ending, Stub},
|
||||
fs::{Stub, line_ending},
|
||||
nu, pipeline,
|
||||
playground::{Dirs, Playground},
|
||||
};
|
||||
use rand::{
|
||||
Rng, SeedableRng,
|
||||
distr::{Alphanumeric, SampleString, StandardUniform},
|
||||
prelude::Distribution,
|
||||
random_range,
|
||||
rngs::StdRng,
|
||||
Rng, SeedableRng,
|
||||
};
|
||||
use std::io::Write;
|
||||
|
||||
|
@ -8,7 +8,9 @@ fn timeit_show_stdout() {
|
||||
|
||||
#[test]
|
||||
fn timeit_show_stderr() {
|
||||
let actual = nu!(" with-env {FOO: bar, FOO2: baz} { let t = timeit { nu --testbin echo_env_mixed out-err FOO FOO2 } }");
|
||||
let actual = nu!(
|
||||
" with-env {FOO: bar, FOO2: baz} { let t = timeit { nu --testbin echo_env_mixed out-err FOO FOO2 } }"
|
||||
);
|
||||
assert!(actual.out.contains("bar"));
|
||||
assert!(actual.err.contains("baz"));
|
||||
}
|
||||
|
@ -218,9 +218,11 @@ fn def_wrapped_from_module() {
|
||||
spam my-echo foo -b -as -9 --abc -- -Dxmy=AKOO - bar
|
||||
"#);
|
||||
|
||||
assert!(actual
|
||||
.out
|
||||
.contains("foo -b -as -9 --abc -- -Dxmy=AKOO - bar"));
|
||||
assert!(
|
||||
actual
|
||||
.out
|
||||
.contains("foo -b -as -9 --abc -- -Dxmy=AKOO - bar")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -10,9 +10,11 @@ fn test_du_flag_min_size() {
|
||||
du -m -1
|
||||
"#
|
||||
));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Negative value passed when positive one is required"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Negative value passed when positive one is required")
|
||||
);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
@ -31,9 +33,11 @@ fn test_du_flag_max_depth() {
|
||||
du -d -2
|
||||
"#
|
||||
));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Negative value passed when positive one is required"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Negative value passed when positive one is required")
|
||||
);
|
||||
|
||||
let actual = nu!(
|
||||
cwd: "tests/fixtures/formats", pipeline(
|
||||
|
@ -4,9 +4,11 @@ use nu_test_support::nu;
|
||||
fn error_label_works() {
|
||||
let actual = nu!("error make {msg:foo label:{text:unseen}}");
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("label at line 1, columns 1 to 10: unseen"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("label at line 1, columns 1 to 10: unseen")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -29,9 +31,11 @@ fn error_start_bigger_than_end_should_fail() {
|
||||
");
|
||||
|
||||
assert!(!actual.err.contains("invalid error format"));
|
||||
assert!(!actual
|
||||
.err
|
||||
.contains("`$.label.start` should be smaller than `$.label.end`"));
|
||||
assert!(
|
||||
!actual
|
||||
.err
|
||||
.contains("`$.label.start` should be smaller than `$.label.end`")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -4,7 +4,9 @@ use nu_test_support::nu;
|
||||
fn export_subcommands_help() {
|
||||
let actual = nu!("export def -h");
|
||||
|
||||
assert!(actual
|
||||
.out
|
||||
.contains("Define a custom command and export it from a module"));
|
||||
assert!(
|
||||
actual
|
||||
.out
|
||||
.contains("Define a custom command and export it from a module")
|
||||
);
|
||||
}
|
||||
|
@ -17,7 +17,10 @@ fn find_with_list_search_with_char() {
|
||||
let actual = nu!("[moe larry curly] | find l | to json -r");
|
||||
let actual_no_highlight = nu!("[moe larry curly] | find --no-highlight l | to json -r");
|
||||
|
||||
assert_eq!(actual.out, "[\"\\u001b[37m\\u001b[0m\\u001b[41;37ml\\u001b[0m\\u001b[37marry\\u001b[0m\",\"\\u001b[37mcur\\u001b[0m\\u001b[41;37ml\\u001b[0m\\u001b[37my\\u001b[0m\"]");
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"[\"\\u001b[37m\\u001b[0m\\u001b[41;37ml\\u001b[0m\\u001b[37marry\\u001b[0m\",\"\\u001b[37mcur\\u001b[0m\\u001b[41;37ml\\u001b[0m\\u001b[37my\\u001b[0m\"]"
|
||||
);
|
||||
assert_eq!(actual_no_highlight.out, "[\"larry\",\"curly\"]");
|
||||
}
|
||||
|
||||
@ -25,8 +28,9 @@ fn find_with_list_search_with_char() {
|
||||
fn find_with_bytestream_search_with_char() {
|
||||
let actual =
|
||||
nu!("\"ABC\" | save foo.txt; let res = open foo.txt | find abc; rm foo.txt; $res | get 0");
|
||||
let actual_no_highlight =
|
||||
nu!("\"ABC\" | save foo.txt; let res = open foo.txt | find --no-highlight abc; rm foo.txt; $res | get 0");
|
||||
let actual_no_highlight = nu!(
|
||||
"\"ABC\" | save foo.txt; let res = open foo.txt | find --no-highlight abc; rm foo.txt; $res | get 0"
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
@ -88,7 +92,10 @@ fn find_with_filepath_search_with_multiple_patterns() {
|
||||
r#"["amigos.txt","arepas.clu","los.txt","tres.txt"] | find --no-highlight arep ami | to json -r"#
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "[\"\\u001b[37m\\u001b[0m\\u001b[41;37mami\\u001b[0m\\u001b[37mgos.txt\\u001b[0m\",\"\\u001b[37m\\u001b[0m\\u001b[41;37marep\\u001b[0m\\u001b[37mas.clu\\u001b[0m\"]");
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
"[\"\\u001b[37m\\u001b[0m\\u001b[41;37mami\\u001b[0m\\u001b[37mgos.txt\\u001b[0m\",\"\\u001b[37m\\u001b[0m\\u001b[41;37marep\\u001b[0m\\u001b[37mas.clu\\u001b[0m\"]"
|
||||
);
|
||||
assert_eq!(actual_no_highlight.out, "[\"amigos.txt\",\"arepas.clu\"]");
|
||||
}
|
||||
|
||||
@ -158,8 +165,12 @@ fn inverted_find_in_table_keeps_row_if_none_of_the_selected_columns_matches() {
|
||||
|
||||
#[test]
|
||||
fn find_in_table_keeps_row_with_single_matched_and_keeps_other_columns() {
|
||||
let actual = nu!("[[name nickname Age]; [Maurice moe 23] [Laurence larry 67] [William will 18]] | find Maurice");
|
||||
let actual_no_highlight = nu!("[[name nickname Age]; [Maurice moe 23] [Laurence larry 67] [William will 18]] | find --no-highlight Maurice");
|
||||
let actual = nu!(
|
||||
"[[name nickname Age]; [Maurice moe 23] [Laurence larry 67] [William will 18]] | find Maurice"
|
||||
);
|
||||
let actual_no_highlight = nu!(
|
||||
"[[name nickname Age]; [Maurice moe 23] [Laurence larry 67] [William will 18]] | find --no-highlight Maurice"
|
||||
);
|
||||
|
||||
println!("{:?}", actual.out);
|
||||
assert!(actual.out.contains("moe"));
|
||||
@ -174,8 +185,12 @@ fn find_in_table_keeps_row_with_single_matched_and_keeps_other_columns() {
|
||||
|
||||
#[test]
|
||||
fn find_in_table_keeps_row_with_multiple_matched_and_keeps_other_columns() {
|
||||
let actual = nu!("[[name nickname Age]; [Maurice moe 23] [Laurence larry 67] [William will 18] [William bill 60]] | find moe William");
|
||||
let actual_no_highlight = nu!("[[name nickname Age]; [Maurice moe 23] [Laurence larry 67] [William will 18] [William bill 60]] | find --no-highlight moe William");
|
||||
let actual = nu!(
|
||||
"[[name nickname Age]; [Maurice moe 23] [Laurence larry 67] [William will 18] [William bill 60]] | find moe William"
|
||||
);
|
||||
let actual_no_highlight = nu!(
|
||||
"[[name nickname Age]; [Maurice moe 23] [Laurence larry 67] [William will 18] [William bill 60]] | find --no-highlight moe William"
|
||||
);
|
||||
|
||||
println!("{:?}", actual.out);
|
||||
assert!(actual.out.contains("moe"));
|
||||
|
@ -51,9 +51,11 @@ fn headers_invalid_column_type_empty_record() {
|
||||
| headers"
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("needs compatible type: Null, String, Bool, Float, Int"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("needs compatible type: Null, String, Bool, Float, Int")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -64,9 +66,11 @@ fn headers_invalid_column_type_record() {
|
||||
| headers"
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("needs compatible type: Null, String, Bool, Float, Int"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("needs compatible type: Null, String, Bool, Float, Int")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -77,9 +81,11 @@ fn headers_invalid_column_type_array() {
|
||||
| headers"
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("needs compatible type: Null, String, Bool, Float, Int"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("needs compatible type: Null, String, Bool, Float, Int")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -90,9 +96,11 @@ fn headers_invalid_column_type_range() {
|
||||
| headers"
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("needs compatible type: Null, String, Bool, Float, Int"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("needs compatible type: Null, String, Bool, Float, Int")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -103,9 +111,11 @@ fn headers_invalid_column_type_duration() {
|
||||
| headers"
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("needs compatible type: Null, String, Bool, Float, Int"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("needs compatible type: Null, String, Bool, Float, Int")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -116,7 +126,9 @@ fn headers_invalid_column_type_binary() {
|
||||
| headers"#
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("needs compatible type: Null, String, Bool, Float, Int"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("needs compatible type: Null, String, Bool, Float, Int")
|
||||
);
|
||||
}
|
||||
|
@ -31,9 +31,11 @@ fn insert_the_column_conflict() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("column 'pretty_assertions' already exists"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("column 'pretty_assertions' already exists")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -61,9 +63,11 @@ fn insert_at_end_of_list() {
|
||||
fn insert_past_end_of_list() {
|
||||
let actual = nu!("[1, 2, 3] | insert 5 abc");
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("can't insert at index (the next available index is 3)"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("can't insert at index (the next available index is 3)")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -84,9 +88,11 @@ fn insert_at_end_of_list_stream() {
|
||||
fn insert_past_end_of_list_stream() {
|
||||
let actual = nu!("[1, 2, 3] | every 1 | insert 5 abc");
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("can't insert at index (the next available index is 3)"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("can't insert at index (the next available index is 3)")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -63,9 +63,11 @@ fn into_datetime_table_column() {
|
||||
fn into_datetime_from_record_fails_with_wrong_type() {
|
||||
let actual = nu!(r#"{year: '2023'} | into datetime"#);
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("nu::shell::only_supports_this_input_type"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("nu::shell::only_supports_this_input_type")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -72,9 +72,11 @@ fn into_duration_table_column() {
|
||||
fn into_duration_from_record_fails_with_wrong_type() {
|
||||
let actual = nu!(r#"{week: '10'} | into duration"#);
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("nu::shell::only_supports_this_input_type"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("nu::shell::only_supports_this_input_type")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -384,7 +384,10 @@ fn do_cases_where_result_differs_between_join_types_with_different_join_keys(joi
|
||||
] {
|
||||
for (join_type_, expected) in join_types {
|
||||
if join_type_ == join_type {
|
||||
let expr = format!("{} | join {} {} {} {} | to nuon", left, right, join_type, left_on, right_on);
|
||||
let expr = format!(
|
||||
"{} | join {} {} {} {} | to nuon",
|
||||
left, right, join_type, left_on, right_on
|
||||
);
|
||||
let actual = nu!(expr).out;
|
||||
assert_eq!(actual, expected);
|
||||
|
||||
|
@ -5,9 +5,11 @@ use rstest::rstest;
|
||||
#[case("let in = 3")]
|
||||
#[case("let in: int = 3")]
|
||||
fn let_name_builtin_var(#[case] assignment: &str) {
|
||||
assert!(nu!(assignment)
|
||||
.err
|
||||
.contains("'in' is the name of a builtin Nushell variable"));
|
||||
assert!(
|
||||
nu!(assignment)
|
||||
.err
|
||||
.contains("'in' is the name of a builtin Nushell variable")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -664,9 +664,11 @@ fn list_ignores_ansi() {
|
||||
fn list_unknown_flag() {
|
||||
let actual = nu!("ls -r");
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Available flags: --help(-h), --all(-a),"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Available flags: --help(-h), --all(-a),")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1,4 +1,4 @@
|
||||
use nu_test_support::fs::{files_exist_at, Stub::EmptyFile, Stub::FileWithContent};
|
||||
use nu_test_support::fs::{Stub::EmptyFile, Stub::FileWithContent, files_exist_at};
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
use rstest::rstest;
|
||||
@ -249,9 +249,11 @@ fn errors_if_multiple_sources_but_destination_not_a_directory() {
|
||||
"mv file?.txt not_a_dir"
|
||||
);
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Can only move multiple sources if destination is a directory"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Can only move multiple sources if destination is a directory")
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
@ -546,13 +548,15 @@ fn mv_with_no_target() {
|
||||
cwd: dirs.test(),
|
||||
"mv a",
|
||||
);
|
||||
assert!(actual.err.contains(
|
||||
format!(
|
||||
"Missing destination path operand after {}",
|
||||
dirs.test().join("a").display()
|
||||
assert!(
|
||||
actual.err.contains(
|
||||
format!(
|
||||
"Missing destination path operand after {}",
|
||||
dirs.test().join("a").display()
|
||||
)
|
||||
.as_str()
|
||||
)
|
||||
.as_str()
|
||||
));
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -12,18 +12,22 @@ fn mut_variable() {
|
||||
#[case("mut in = 3")]
|
||||
#[case("mut in: int = 3")]
|
||||
fn mut_name_builtin_var(#[case] assignment: &str) {
|
||||
assert!(nu!(assignment)
|
||||
.err
|
||||
.contains("'in' is the name of a builtin Nushell variable"));
|
||||
assert!(
|
||||
nu!(assignment)
|
||||
.err
|
||||
.contains("'in' is the name of a builtin Nushell variable")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mut_name_builtin_var_with_dollar() {
|
||||
let actual = nu!("mut $env = 3");
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("'env' is the name of a builtin Nushell variable"))
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("'env' is the name of a builtin Nushell variable")
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -152,9 +156,11 @@ fn def_should_not_mutate_mut() {
|
||||
#[test]
|
||||
fn assign_to_non_mut_variable_raises_parse_error() {
|
||||
let actual = nu!("let x = 3; $x = 4");
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("parser::assignment_requires_mutable_variable"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("parser::assignment_requires_mutable_variable")
|
||||
);
|
||||
|
||||
let actual = nu!("mut x = 3; x = 5");
|
||||
assert!(actual.err.contains("parser::assignment_requires_variable"));
|
||||
|
@ -76,9 +76,11 @@ fn http_patch_failed_due_to_missing_body() {
|
||||
.as_str()
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Data must be provided either through pipeline or positional argument"))
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Data must be provided either through pipeline or positional argument")
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -75,9 +75,11 @@ fn http_post_failed_due_to_missing_body() {
|
||||
.as_str()
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Data must be provided either through pipeline or positional argument"))
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Data must be provided either through pipeline or positional argument")
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -76,9 +76,11 @@ fn http_put_failed_due_to_missing_body() {
|
||||
.as_str()
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Data must be provided either through pipeline or positional argument"))
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Data must be provided either through pipeline or positional argument")
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -252,11 +252,13 @@ fn errors_if_file_not_found() {
|
||||
// provided error message
|
||||
|
||||
assert!(actual.err.contains("nu::shell::io::file_not_found"));
|
||||
assert!(actual.err.contains(
|
||||
&PathBuf::from_iter(["tests", "fixtures", "formats", "i_dont_exist.txt"])
|
||||
.display()
|
||||
.to_string()
|
||||
));
|
||||
assert!(
|
||||
actual.err.contains(
|
||||
&PathBuf::from_iter(["tests", "fixtures", "formats", "i_dont_exist.txt"])
|
||||
.display()
|
||||
.to_string()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -94,9 +94,11 @@ mod simple {
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Found opening `{` without an associated closing `}`"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Found opening `{` without an associated closing `}`")
|
||||
);
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -184,9 +186,11 @@ mod regex {
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Opening parenthesis without closing parenthesis"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Opening parenthesis without closing parenthesis")
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use nu_test_support::fs::{file_contents, Stub::FileWithContent};
|
||||
use nu_test_support::fs::{Stub::FileWithContent, file_contents};
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
|
||||
@ -468,9 +468,9 @@ fn pipe_redirection_in_let_and_mut(
|
||||
#[case] redir: &str,
|
||||
#[case] output: &str,
|
||||
) {
|
||||
let actual = nu!(
|
||||
format!("$env.BAZ = 'foo'; {keyword} v = nu --testbin echo_env_mixed out-err BAZ BAZ {redir} str length; $v")
|
||||
);
|
||||
let actual = nu!(format!(
|
||||
"$env.BAZ = 'foo'; {keyword} v = nu --testbin echo_env_mixed out-err BAZ BAZ {redir} str length; $v"
|
||||
));
|
||||
assert_eq!(actual.out, output);
|
||||
}
|
||||
|
||||
|
@ -107,9 +107,11 @@ fn error_reduce_fold_type_mismatch() {
|
||||
"echo a b c | reduce --fold 0 { |it, acc| $acc + $it }"
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("nu::shell::operator_incompatible_types"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("nu::shell::operator_incompatible_types")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -129,7 +129,9 @@ fn reject_optional_row() {
|
||||
|
||||
#[test]
|
||||
fn reject_columns_with_list_spread() {
|
||||
let actual = nu!("let arg = [type size]; [[name type size];[Cargo.toml file 10mb] [Cargo.lock file 10mb] [src dir 100mb]] | reject ...$arg | to nuon");
|
||||
let actual = nu!(
|
||||
"let arg = [type size]; [[name type size];[Cargo.toml file 10mb] [Cargo.lock file 10mb] [src dir 100mb]] | reject ...$arg | to nuon"
|
||||
);
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
r#"[[name]; ["Cargo.toml"], ["Cargo.lock"], [src]]"#
|
||||
@ -138,7 +140,9 @@ fn reject_columns_with_list_spread() {
|
||||
|
||||
#[test]
|
||||
fn reject_rows_with_list_spread() {
|
||||
let actual = nu!("let arg = [2 0]; [[name type size];[Cargo.toml file 10mb] [Cargo.lock file 10mb] [src dir 100mb]] | reject ...$arg | to nuon");
|
||||
let actual = nu!(
|
||||
"let arg = [2 0]; [[name type size];[Cargo.toml file 10mb] [Cargo.lock file 10mb] [src dir 100mb]] | reject ...$arg | to nuon"
|
||||
);
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
r#"[[name, type, size]; ["Cargo.lock", file, 10000000b]]"#
|
||||
@ -147,7 +151,9 @@ fn reject_rows_with_list_spread() {
|
||||
|
||||
#[test]
|
||||
fn reject_mixed_with_list_spread() {
|
||||
let actual = nu!("let arg = [type 2]; [[name type size];[Cargp.toml file 10mb] [ Cargo.lock file 10mb] [src dir 100mb]] | reject ...$arg | to nuon");
|
||||
let actual = nu!(
|
||||
"let arg = [type 2]; [[name type size];[Cargp.toml file 10mb] [ Cargo.lock file 10mb] [src dir 100mb]] | reject ...$arg | to nuon"
|
||||
);
|
||||
assert_eq!(
|
||||
actual.out,
|
||||
r#"[[name, size]; ["Cargp.toml", 10000000b], ["Cargo.lock", 10000000b]]"#
|
||||
|
@ -1,6 +1,6 @@
|
||||
#[cfg(not(windows))]
|
||||
use nu_path::AbsolutePath;
|
||||
use nu_test_support::fs::{files_exist_at, Stub::EmptyFile};
|
||||
use nu_test_support::fs::{Stub::EmptyFile, files_exist_at};
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
use rstest::rstest;
|
||||
|
@ -93,7 +93,9 @@ fn clockwise() {
|
||||
#[test]
|
||||
fn different_cols_vals_err() {
|
||||
let actual = nu!("[[[one], [two, three]]] | first | rotate");
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Attempted to create a record from different number of columns and values"))
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Attempted to create a record from different number of columns and values")
|
||||
)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use nu_test_support::fs::{file_contents, Stub};
|
||||
use nu_test_support::fs::{Stub, file_contents};
|
||||
use nu_test_support::playground::Playground;
|
||||
use nu_test_support::{nu, pipeline};
|
||||
use std::io::Write;
|
||||
@ -96,9 +96,11 @@ fn save_stderr_and_stdout_to_same_file() {
|
||||
do -c {nu -n -c 'nu --testbin echo_env FOO; nu --testbin echo_env_stderr BAZ'} | save -r save_test_5/new-file.txt --stderr save_test_5/new-file.txt
|
||||
"#,
|
||||
);
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("can't save both input and stderr input to the same file"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("can't save both input and stderr input to the same file")
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
@ -340,9 +342,11 @@ fn save_same_file_with_extension() {
|
||||
)
|
||||
);
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("pipeline input and output are the same file"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("pipeline input and output are the same file")
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
@ -361,9 +365,11 @@ fn save_same_file_with_extension_pipeline() {
|
||||
)
|
||||
);
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("pipeline input and output are the same file"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("pipeline input and output are the same file")
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
@ -381,9 +387,11 @@ fn save_same_file_without_extension() {
|
||||
)
|
||||
);
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("pipeline input and output are the same file"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("pipeline input and output are the same file")
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
@ -402,9 +410,11 @@ fn save_same_file_without_extension_pipeline() {
|
||||
)
|
||||
);
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("pipeline input and output are the same file"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("pipeline input and output are the same file")
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -4,18 +4,22 @@ use nu_test_support::nu;
|
||||
fn fails_when_first_arg_is_multiple_chars() {
|
||||
let actual = nu!("seq char aa z");
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("input should be a single ASCII character"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("input should be a single ASCII character")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fails_when_second_arg_is_multiple_chars() {
|
||||
let actual = nu!("seq char a zz");
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("input should be a single ASCII character"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("input should be a single ASCII character")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -36,18 +40,22 @@ fn generates_sequence_from_e_to_a() {
|
||||
fn fails_when_non_ascii_character_is_used_in_first_arg() {
|
||||
let actual = nu!("seq char ñ z");
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("input should be a single ASCII character"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("input should be a single ASCII character")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fails_when_non_ascii_character_is_used_in_second_arg() {
|
||||
let actual = nu!("seq char a ñ");
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("input should be a single ASCII character"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("input should be a single ASCII character")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -11,7 +11,9 @@ fn fails_on_datetime_input() {
|
||||
fn fails_when_increment_not_integer_or_duration() {
|
||||
let actual = nu!("seq date --begin-date 2020-01-01 --increment 1.1");
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("expected one of a list of accepted shapes: [Duration, Int]"))
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("expected one of a list of accepted shapes: [Duration, Int]")
|
||||
)
|
||||
}
|
||||
|
@ -283,17 +283,21 @@ fn source_env_is_scoped() {
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), &inp.join("; "));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Command `no-name-similar-to-this` not found"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Command `no-name-similar-to-this` not found")
|
||||
);
|
||||
|
||||
let inp = &[r#"source-env spam.nu"#, r#"nor-similar-to-this"#];
|
||||
|
||||
let actual = nu!(cwd: dirs.test(), &inp.join("; "));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Command `nor-similar-to-this` not found"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Command `nor-similar-to-this` not found")
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@ -146,8 +146,11 @@ fn get_error_columns() {
|
||||
|
||||
#[test]
|
||||
fn get_json_error() {
|
||||
let actual = nu!("try { non_existent_command } catch {|err| $err} | get json | from json | update labels.span {{start: 0 end: 0}} | to json -r");
|
||||
let actual = nu!(
|
||||
"try { non_existent_command } catch {|err| $err} | get json | from json | update labels.span {{start: 0 end: 0}} | to json -r"
|
||||
);
|
||||
assert_eq!(
|
||||
actual.out, "{\"msg\":\"External command failed\",\"labels\":[{\"text\":\"Command `non_existent_command` not found\",\"span\":{\"start\":0,\"end\":0}}],\"code\":\"nu::shell::external_command\",\"url\":null,\"help\":\"`non_existent_command` is neither a Nushell built-in or a known external command\",\"inner\":[]}"
|
||||
actual.out,
|
||||
"{\"msg\":\"External command failed\",\"labels\":[{\"text\":\"Command `non_existent_command` not found\",\"span\":{\"start\":0,\"end\":0}}],\"code\":\"nu::shell::external_command\",\"url\":null,\"help\":\"`non_existent_command` is neither a Nushell built-in or a known external command\",\"inner\":[]}"
|
||||
);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use nu_test_support::fs::file_contents;
|
||||
use nu_test_support::fs::{
|
||||
files_exist_at,
|
||||
Stub::{EmptyFile, FileWithContent, FileWithPermission},
|
||||
files_exist_at,
|
||||
};
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::Playground;
|
||||
@ -928,14 +928,16 @@ fn test_cp_verbose_default() {
|
||||
src.display(),
|
||||
TEST_HELLO_WORLD_DEST
|
||||
);
|
||||
assert!(actual.out.contains(
|
||||
format!(
|
||||
"'{}' -> '{}'",
|
||||
src.display(),
|
||||
dirs.root().join(TEST_HELLO_WORLD_DEST).display()
|
||||
assert!(
|
||||
actual.out.contains(
|
||||
format!(
|
||||
"'{}' -> '{}'",
|
||||
src.display(),
|
||||
dirs.root().join(TEST_HELLO_WORLD_DEST).display()
|
||||
)
|
||||
.as_str(),
|
||||
)
|
||||
.as_str(),
|
||||
));
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -948,9 +950,11 @@ fn test_cp_only_source_no_dest() {
|
||||
"cp {}",
|
||||
src.display(),
|
||||
);
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Missing destination path operand after"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Missing destination path operand after")
|
||||
);
|
||||
assert!(actual.err.contains(TEST_HELLO_WORLD_SOURCE));
|
||||
});
|
||||
}
|
||||
@ -1159,7 +1163,9 @@ fn test_cp_inside_glob_metachars_dir() {
|
||||
#[test]
|
||||
fn test_cp_to_customized_home_directory() {
|
||||
Playground::setup("cp_to_home", |dirs, sandbox| {
|
||||
std::env::set_var("HOME", dirs.test());
|
||||
unsafe {
|
||||
std::env::set_var("HOME", dirs.test());
|
||||
}
|
||||
sandbox.with_files(&[EmptyFile("test_file.txt")]);
|
||||
let actual = nu!(cwd: dirs.test(), "mkdir test; cp test_file.txt ~/test/");
|
||||
|
||||
|
@ -119,9 +119,11 @@ fn limit_set_invalid3() {
|
||||
"
|
||||
);
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Only unlimited, soft and hard are supported for strings"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Only unlimited, soft and hard are supported for strings")
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -211,8 +213,10 @@ fn limit_set_filesize2() {
|
||||
"
|
||||
);
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("filesize is not compatible with resource RLIMIT_NOFILE"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("filesize is not compatible with resource RLIMIT_NOFILE")
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -155,7 +155,9 @@ fn table() {
|
||||
"
|
||||
));
|
||||
|
||||
let expected = nu!("[[fruit day]; [apple monday] [apple friday] [Apple friday] [pear monday] [orange tuesday]]");
|
||||
let expected = nu!(
|
||||
"[[fruit day]; [apple monday] [apple friday] [Apple friday] [pear monday] [orange tuesday]]"
|
||||
);
|
||||
assert_eq!(actual.out, expected.out);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,9 @@ fn upsert_uses_enumerate_index_inserting() {
|
||||
|
||||
#[test]
|
||||
fn upsert_uses_enumerate_index_updating() {
|
||||
let actual = nu!("[[a]; [7] [6]] | enumerate | upsert a {|el| $el.index + 1 + $el.item.a } | flatten | to nuon");
|
||||
let actual = nu!(
|
||||
"[[a]; [7] [6]] | enumerate | upsert a {|el| $el.index + 1 + $el.item.a } | flatten | to nuon"
|
||||
);
|
||||
|
||||
assert_eq!(actual.out, "[[index, a]; [0, 8], [1, 8]]");
|
||||
}
|
||||
@ -84,9 +86,11 @@ fn upsert_at_end_of_list() {
|
||||
fn upsert_past_end_of_list() {
|
||||
let actual = nu!("[1, 2, 3] | upsert 5 abc");
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("can't insert at index (the next available index is 3)"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("can't insert at index (the next available index is 3)")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -107,9 +111,11 @@ fn upsert_at_end_of_list_stream() {
|
||||
fn upsert_past_end_of_list_stream() {
|
||||
let actual = nu!("[1, 2, 3] | every 1 | upsert 5 abc");
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("can't insert at index (the next available index is 3)"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("can't insert at index (the next available index is 3)")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -154,12 +154,16 @@ fn url_join_with_different_query_and_params() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Mismatch, query string from params is: ?par_1=aaab&par_2=bbb"));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("instead query is: ?par_1=aaa&par_2=bbb"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Mismatch, query string from params is: ?par_1=aaab&par_2=bbb")
|
||||
);
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("instead query is: ?par_1=aaa&par_2=bbb")
|
||||
);
|
||||
|
||||
let actual = nu!(pipeline(
|
||||
r#"
|
||||
@ -178,12 +182,16 @@ fn url_join_with_different_query_and_params() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Mismatch, query param is: par_1=aaa&par_2=bbb"));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("instead query string from params is: ?par_1=aaab&par_2=bbb"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Mismatch, query param is: par_1=aaa&par_2=bbb")
|
||||
);
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("instead query string from params is: ?par_1=aaab&par_2=bbb")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -201,9 +209,11 @@ fn url_join_with_invalid_params() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Key params has to be a record or a table"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Key params has to be a record or a table")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -245,9 +255,11 @@ fn url_join_with_invalid_port() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Port parameter should represent an unsigned int"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Port parameter should represent an unsigned int")
|
||||
);
|
||||
|
||||
let actual = nu!(pipeline(
|
||||
r#"
|
||||
@ -259,9 +271,11 @@ fn url_join_with_invalid_port() {
|
||||
"#
|
||||
));
|
||||
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("Port parameter should be an unsigned int or a string representing it"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("Port parameter should be an unsigned int or a string representing it")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -421,7 +435,9 @@ fn url_join_with_params_invalid_table() {
|
||||
));
|
||||
|
||||
assert!(actual.err.contains("expected a table"));
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("not a table, contains non-record values"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("not a table, contains non-record values")
|
||||
);
|
||||
}
|
||||
|
@ -196,9 +196,11 @@ fn use_module_creates_accurate_did_you_mean_2() {
|
||||
let actual = nu!(r#"
|
||||
module spam { export def foo [] { "foo" } }; foo
|
||||
"#);
|
||||
assert!(actual
|
||||
.err
|
||||
.contains("A command with that name exists in module `spam`"));
|
||||
assert!(
|
||||
actual
|
||||
.err
|
||||
.contains("A command with that name exists in module `spam`")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1,6 +1,6 @@
|
||||
use chrono::{DateTime, Days, Local, TimeDelta, Utc};
|
||||
use filetime::FileTime;
|
||||
use nu_test_support::fs::{files_exist_at, Stub};
|
||||
use nu_test_support::fs::{Stub, files_exist_at};
|
||||
use nu_test_support::nu;
|
||||
use nu_test_support::playground::{Dirs, Playground};
|
||||
use std::path::Path;
|
||||
|
@ -50,7 +50,9 @@ fn list_stream() {
|
||||
|
||||
#[test]
|
||||
fn table_stream() {
|
||||
let actual = nu!("([[foo bar]; [0 1] [2 3] [4 5]] | every 1 | window 2) == ([[foo bar]; [0 1] [2 3] [4 5]] | window 2)");
|
||||
let actual = nu!(
|
||||
"([[foo bar]; [0 1] [2 3] [4 5]] | every 1 | window 2) == ([[foo bar]; [0 1] [2 3] [4 5]] | window 2)"
|
||||
);
|
||||
assert_eq!(actual.out, "true");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user