diff --git a/crates/nu-command/tests/commands/append.rs b/crates/nu-command/tests/commands/append.rs index 85c0a297c..6a028ddf6 100644 --- a/crates/nu-command/tests/commands/append.rs +++ b/crates/nu-command/tests/commands/append.rs @@ -2,8 +2,7 @@ use nu_test_support::{nu, pipeline}; #[test] fn adds_a_row_to_the_end() { - let actual = nu!( - cwd: ".", pipeline( + let actual = nu!(pipeline( r#" echo [ "Andrés N. Robalino", "JT Turner", "Yehuda Katz" ] | append "pollo loco" diff --git a/crates/nu-command/tests/commands/break_.rs b/crates/nu-command/tests/commands/break_.rs index 32275c30d..92a656465 100644 --- a/crates/nu-command/tests/commands/break_.rs +++ b/crates/nu-command/tests/commands/break_.rs @@ -1,37 +1,26 @@ -use nu_test_support::{nu, pipeline}; +use nu_test_support::nu; #[test] fn break_for_loop() { - let actual = nu!( - cwd: ".", pipeline( - r#" + let actual = nu!(" for i in 1..10 { if $i == 2 { break }; print $i } - "# - )); + "); - assert_eq!(actual.out, r#"1"#); + assert_eq!(actual.out, "1"); } #[test] fn break_while_loop() { - let actual = nu!( - cwd: ".", pipeline( - r#" - while true { break }; print "hello" - "# - )); + let actual = nu!(r#" while true { break }; print "hello" "#); - assert_eq!(actual.out, r#"hello"#); + assert_eq!(actual.out, "hello"); } #[test] fn break_each() { - let actual = nu!( - cwd: ".", pipeline( - r#" + let actual = nu!(" [1, 2, 3, 4, 5] | each {|x| if $x > 3 { break }; $x} | math sum - "# - )); + "); - assert_eq!(actual.out, r#"6"#); + assert_eq!(actual.out, "6"); } diff --git a/crates/nu-command/tests/commands/cal.rs b/crates/nu-command/tests/commands/cal.rs index 61c0ba2e7..43994a62a 100644 --- a/crates/nu-command/tests/commands/cal.rs +++ b/crates/nu-command/tests/commands/cal.rs @@ -2,12 +2,7 @@ use nu_test_support::{nu, pipeline}; #[test] fn cal_full_year() { - let actual = nu!( - cwd: ".", pipeline( - r#" - cal -y --full-year 2010 | first | to json -r - "# - )); + let actual = nu!("cal -y --full-year 2010 | first | to json -r"); let first_week_2010_json = r#"{"year": 2010,"sunday": null,"monday": null,"tuesday": null,"wednesday": null,"thursday": null,"friday": 1,"saturday": 2}"#; @@ -16,8 +11,7 @@ fn cal_full_year() { #[test] fn cal_february_2020_leap_year() { - let actual = nu!( - cwd: ".", pipeline( + let actual = nu!(pipeline( r#" cal -ym --full-year 2020 --month-names | where month == "february" | to json -r "# @@ -30,8 +24,7 @@ fn cal_february_2020_leap_year() { #[test] fn cal_friday_the_thirteenths_in_2015() { - let actual = nu!( - cwd: ".", pipeline( + let actual = nu!(pipeline( r#" cal --full-year 2015 | default 0 friday | where friday == 13 | length "# @@ -42,8 +35,7 @@ fn cal_friday_the_thirteenths_in_2015() { #[test] fn cal_rows_in_2020() { - let actual = nu!( - cwd: ".", pipeline( + let actual = nu!(pipeline( r#" cal --full-year 2020 | length "# @@ -54,8 +46,7 @@ fn cal_rows_in_2020() { #[test] fn cal_week_day_start_monday() { - let actual = nu!( - cwd: ".", pipeline( + let actual = nu!(pipeline( r#" cal --full-year 2020 -m --month-names --week-start monday | where month == january | to json -r "# @@ -68,8 +59,7 @@ fn cal_week_day_start_monday() { #[test] fn cal_sees_pipeline_year() { - let actual = nu!( - cwd: ".", pipeline( + let actual = nu!(pipeline( r#" cal --full-year 1020 | get monday | first 4 | to json -r "# diff --git a/crates/nu-command/tests/commands/cd.rs b/crates/nu-command/tests/commands/cd.rs index 2d1d7c2b7..8d9e086ff 100644 --- a/crates/nu-command/tests/commands/cd.rs +++ b/crates/nu-command/tests/commands/cd.rs @@ -20,13 +20,7 @@ fn cd_works_with_in_var() { #[test] fn filesystem_change_from_current_directory_using_relative_path() { Playground::setup("cd_test_1", |dirs, _| { - let actual = nu!( - cwd: dirs.root(), - r#" - cd cd_test_1 - $env.PWD - "# - ); + let actual = nu!( cwd: dirs.root(), "cd cd_test_1; $env.PWD"); assert_eq!(PathBuf::from(actual.out), *dirs.test()); }) @@ -55,11 +49,11 @@ fn filesystem_switch_back_to_previous_working_directory() { let actual = nu!( cwd: dirs.test().join("odin"), - r#" + " cd {} cd - $env.PWD - "#, + ", dirs.test().display() ); @@ -74,10 +68,10 @@ fn filesystem_change_from_current_directory_using_relative_path_and_dash() { let actual = nu!( cwd: dirs.test(), - r#" + " cd odin/- $env.PWD - "# + " ); assert_eq!( @@ -92,10 +86,10 @@ fn filesystem_change_current_directory_to_parent_directory() { Playground::setup("cd_test_5", |dirs, _| { let actual = nu!( cwd: dirs.test(), - r#" + " cd .. $env.PWD - "# + " ); assert_eq!(PathBuf::from(actual.out), *dirs.root()); @@ -109,10 +103,10 @@ fn filesystem_change_current_directory_to_two_parents_up_using_multiple_dots() { let actual = nu!( cwd: dirs.test().join("foo/bar"), - r#" + " cd ... $env.PWD - "# + " ); assert_eq!(PathBuf::from(actual.out), *dirs.test()); @@ -124,10 +118,10 @@ fn filesystem_change_to_home_directory() { Playground::setup("cd_test_8", |dirs, _| { let actual = nu!( cwd: dirs.test(), - r#" + " cd ~ $env.PWD - "# + " ); assert_eq!(Some(PathBuf::from(actual.out)), dirs_next::home_dir()); @@ -208,10 +202,10 @@ fn filesystem_change_directory_to_symlink_relative() { let actual = nu!( cwd: dirs.test().join("boo"), - r#" + " cd ../foo_link $env.PWD - "# + " ); assert_eq!(PathBuf::from(actual.out), dirs.test().join("foo")); @@ -251,18 +245,18 @@ fn cd_permission_denied_folder() { sandbox.mkdir("banned"); let actual = nu!( cwd: dirs.test(), - r#" + " chmod -x banned cd banned - "# + " ); assert!(actual.err.contains("Cannot change directory to")); nu!( cwd: dirs.test(), - r#" + " chmod +x banned rm banned - "# + " ); }); } diff --git a/crates/nu-command/tests/commands/compact.rs b/crates/nu-command/tests/commands/compact.rs index c237103b3..2f58535b0 100644 --- a/crates/nu-command/tests/commands/compact.rs +++ b/crates/nu-command/tests/commands/compact.rs @@ -21,12 +21,12 @@ fn discards_rows_where_given_column_is_empty() { let actual = nu!( cwd: dirs.test(), pipeline( - r#" + " open los_tres_amigos.json | get amigos | compact rusty_luck | length - "# + " )); assert_eq!(actual.out, "3"); diff --git a/crates/nu-command/tests/commands/continue_.rs b/crates/nu-command/tests/commands/continue_.rs index c3b436357..e39934f7e 100644 --- a/crates/nu-command/tests/commands/continue_.rs +++ b/crates/nu-command/tests/commands/continue_.rs @@ -1,13 +1,8 @@ -use nu_test_support::{nu, pipeline}; +use nu_test_support::nu; #[test] fn continue_for_loop() { - let actual = nu!( - cwd: ".", pipeline( - r#" - for i in 1..10 { if $i == 2 { continue }; print $i } - "# - )); + let actual = nu!("for i in 1..10 { if $i == 2 { continue }; print $i }"); - assert_eq!(actual.out, r#"1345678910"#); + assert_eq!(actual.out, "1345678910"); } diff --git a/crates/nu-command/tests/commands/def.rs b/crates/nu-command/tests/commands/def.rs index 3537041f3..a9f44e9d0 100644 --- a/crates/nu-command/tests/commands/def.rs +++ b/crates/nu-command/tests/commands/def.rs @@ -1,5 +1,5 @@ +use nu_test_support::nu; use nu_test_support::playground::Playground; -use nu_test_support::{nu, pipeline}; use std::fs; #[test] @@ -39,85 +39,49 @@ param:string #My cool attractive param #[test] fn def_errors_with_multiple_short_flags() { - let actual = nu!( - cwd: ".", pipeline( - r#" - def test-command [ --long(-l)(-o) ] {} - "# - )); + let actual = nu!("def test-command [ --long(-l)(-o) ] {}"); assert!(actual.err.contains("expected only one short flag")); } #[test] fn def_errors_with_comma_before_alternative_short_flag() { - let actual = nu!( - cwd: ".", pipeline( - r#" - def test-command [ --long, (-l) ] {} - "# - )); + let actual = nu!("def test-command [ --long, (-l) ] {}"); assert!(actual.err.contains("expected parameter")); } #[test] fn def_errors_with_comma_before_equals() { - let actual = nu!( - cwd: ".", pipeline( - r#" - def test-command [ foo, = 1 ] {} - "# - )); + let actual = nu!("def test-command [ foo, = 1 ] {}"); assert!(actual.err.contains("expected parameter")); } #[test] fn def_errors_with_comma_before_colon() { - let actual = nu!( - cwd: ".", pipeline( - r#" - def test-command [ foo, : int ] {} - "# - )); + let actual = nu!("def test-command [ foo, : int ] {}"); assert!(actual.err.contains("expected parameter")); } #[test] fn def_errors_with_multiple_colons() { - let actual = nu!( - cwd: ".", pipeline( - r#" - def test-command [ foo::int ] {} - "# - )); - + let actual = nu!("def test-command [ foo::int ] {}"); assert!(actual.err.contains("expected type")); } #[ignore = "This error condition is not implemented yet"] #[test] fn def_errors_with_multiple_types() { - let actual = nu!( - cwd: ".", pipeline( - r#" - def test-command [ foo:int:string ] {} - "# - )); + let actual = nu!("def test-command [ foo:int:string ] {}"); assert!(actual.err.contains("expected parameter")); } #[test] fn def_errors_with_multiple_commas() { - let actual = nu!( - cwd: ".", pipeline( - r#" - def test-command [ foo,,bar ] {} - "# - )); + let actual = nu!("def test-command [ foo,,bar ] {}"); assert!(actual.err.contains("expected parameter")); } @@ -125,28 +89,13 @@ fn def_errors_with_multiple_commas() { #[test] fn def_fails_with_invalid_name() { let err_msg = "command name can't be a number, a filesize, or contain a hash # or caret ^"; - let actual = nu!( - cwd: ".", pipeline( - r#" - def 1234 = echo "test" - "# - )); + let actual = nu!(r#"def 1234 = echo "test""#); assert!(actual.err.contains(err_msg)); - let actual = nu!( - cwd: ".", pipeline( - r#" - def 5gib = echo "test" - "# - )); + let actual = nu!(r#"def 5gib = echo "test""#); assert!(actual.err.contains(err_msg)); - let actual = nu!( - cwd: ".", pipeline( - r#" - def ^foo [] {} - "# - )); + let actual = nu!(r#"def ^foo [] {}"#); assert!(actual.err.contains(err_msg)); } @@ -188,12 +137,7 @@ param: list = [one] #[test] fn def_with_paren_params() { - let actual = nu!( - cwd: ".", pipeline( - r#" - def foo (x: int, y: int) { $x + $y }; foo 1 2 - "# - )); + let actual = nu!("def foo (x: int, y: int) { $x + $y }; foo 1 2"); assert_eq!(actual.out, "3"); } diff --git a/crates/nu-command/tests/commands/default.rs b/crates/nu-command/tests/commands/default.rs index 78bbd3951..d14e0597e 100644 --- a/crates/nu-command/tests/commands/default.rs +++ b/crates/nu-command/tests/commands/default.rs @@ -21,13 +21,13 @@ fn adds_row_data_if_column_missing() { let actual = nu!( cwd: dirs.test(), pipeline( - r#" + " open los_tres_amigos.json | get amigos | default 1 rusty_luck | where rusty_luck == 1 | length - "# + " )); assert_eq!(actual.out, "2"); diff --git a/crates/nu-command/tests/commands/do_.rs b/crates/nu-command/tests/commands/do_.rs index cfca2020e..809b1e6da 100644 --- a/crates/nu-command/tests/commands/do_.rs +++ b/crates/nu-command/tests/commands/do_.rs @@ -1,13 +1,10 @@ -use nu_test_support::{nu, pipeline}; +use nu_test_support::nu; +#[cfg(not(windows))] +use nu_test_support::pipeline; #[test] fn capture_errors_works() { - let actual = nu!( - cwd: ".", pipeline( - r#" - do -c {$env.use} - "# - )); + let actual = nu!("do -c {$env.use}"); eprintln!("actual.err: {:?}", actual.err); @@ -16,60 +13,35 @@ fn capture_errors_works() { #[test] fn capture_errors_works_for_external() { - let actual = nu!( - cwd: ".", pipeline( - r#" - do -c {nu --testbin fail} - "# - )); + let actual = nu!("do -c {nu --testbin fail}"); assert!(actual.err.contains("External command failed")); assert_eq!(actual.out, ""); } #[test] fn capture_errors_works_for_external_with_pipeline() { - let actual = nu!( - cwd: ".", pipeline( - r#" - do -c {nu --testbin fail} | echo `text` - "# - )); + let actual = nu!("do -c {nu --testbin fail} | echo `text`"); assert!(actual.err.contains("External command failed")); assert_eq!(actual.out, ""); } #[test] fn capture_errors_works_for_external_with_semicolon() { - let actual = nu!( - cwd: ".", pipeline( - r#" - do -c {nu --testbin fail}; echo `text` - "# - )); + let actual = nu!(r#"do -c {nu --testbin fail}; echo `text`"#); assert!(actual.err.contains("External command failed")); assert_eq!(actual.out, ""); } #[test] fn do_with_semicolon_break_on_failed_external() { - let actual = nu!( - cwd: ".", pipeline( - r#" - do { nu --not_exist_flag }; `text` - "# - )); + let actual = nu!(r#"do { nu --not_exist_flag }; `text`"#); assert_eq!(actual.out, ""); } #[test] fn ignore_shell_errors_works_for_external_with_semicolon() { - let actual = nu!( - cwd: ".", pipeline( - r#" - do -s { open asdfasdf.txt }; "text" - "# - )); + let actual = nu!(r#"do -s { open asdfasdf.txt }; "text""#); assert_eq!(actual.err, ""); assert_eq!(actual.out, "text"); @@ -77,12 +49,7 @@ fn ignore_shell_errors_works_for_external_with_semicolon() { #[test] fn ignore_program_errors_works_for_external_with_semicolon() { - let actual = nu!( - cwd: ".", pipeline( - r#" - do -p { nu -c 'exit 1' }; "text" - "# - )); + let actual = nu!(r#"do -p { nu -c 'exit 1' }; "text""#); assert_eq!(actual.err, ""); assert_eq!(actual.out, "text"); @@ -90,9 +57,7 @@ fn ignore_program_errors_works_for_external_with_semicolon() { #[test] fn ignore_error_should_work_for_external_command() { - let actual = nu!(cwd: ".", pipeline( - r#"do -i { nu --testbin fail asdf }; echo post"# - )); + let actual = nu!(r#"do -i { nu --testbin fail asdf }; echo post"#); assert_eq!(actual.err, ""); assert_eq!(actual.out, "post"); @@ -190,6 +155,6 @@ fn capture_error_with_both_stdout_stderr_messages_not_hang_nushell() { #[test] fn ignore_error_works_with_list_stream() { - let actual = nu!(cwd: ".", pipeline(r#"do -i { ["a", $nothing, "b"] | ansi strip }"#)); + let actual = nu!(r#"do -i { ["a", $nothing, "b"] | ansi strip }"#); assert!(actual.err.is_empty()); } diff --git a/crates/nu-command/tests/commands/drop.rs b/crates/nu-command/tests/commands/drop.rs index 24ae7fe8c..73d7e0c51 100644 --- a/crates/nu-command/tests/commands/drop.rs +++ b/crates/nu-command/tests/commands/drop.rs @@ -2,51 +2,47 @@ use nu_test_support::{nu, pipeline}; #[test] fn columns() { - let actual = nu!( - cwd: ".", pipeline(r#" + let actual = nu!(pipeline( + " echo [ [arepas, color]; [3, white] [8, yellow] [4, white] ] | drop column | columns | length - "#) - ); + " + )); assert_eq!(actual.out, "1"); } #[test] fn drop_columns_positive_value() { - let actual = nu!( - cwd: ".", pipeline(r#" - echo [[a, b];[1,2]] | drop column -1 - "#) - ); + let actual = nu!("echo [[a, b];[1,2]] | drop column -1"); assert!(actual.err.contains("use a positive value")); } #[test] fn more_columns_than_table_has() { - let actual = nu!( - cwd: ".", pipeline(r#" + let actual = nu!(pipeline( + " echo [ [arepas, color]; [3, white] [8, yellow] [4, white] ] | drop column 3 | columns | is-empty - "#) - ); + " + )); assert_eq!(actual.out, "true"); } #[test] fn rows() { - let actual = nu!( - cwd: ".", pipeline(r#" + let actual = nu!(pipeline( + " echo [ [arepas]; @@ -57,43 +53,43 @@ fn rows() { | drop 2 | get arepas | math sum - "#) - ); + " + )); assert_eq!(actual.out, "3"); } #[test] fn more_rows_than_table_has() { - let actual = nu!(cwd: ".", "[date] | drop 50 | length"); + let actual = nu!("[date] | drop 50 | length"); assert_eq!(actual.out, "0"); } #[test] fn nth_range_inclusive() { - let actual = nu!(cwd: ".", "echo 10..15 | drop nth (2..3) | to json --raw"); + let actual = nu!("echo 10..15 | drop nth (2..3) | to json --raw"); assert_eq!(actual.out, "[10,11,14,15]"); } #[test] fn nth_range_exclusive() { - let actual = nu!(cwd: ".", "echo 10..15 | drop nth (1..<3) | to json --raw"); + let actual = nu!("echo 10..15 | drop nth (1..<3) | to json --raw"); assert_eq!(actual.out, "[10,13,14,15]"); } #[test] fn nth_missing_first_argument() { - let actual = nu!(cwd: ".", "echo 10..15 | drop nth \"\""); + let actual = nu!("echo 10..15 | drop nth \"\""); assert!(actual.err.contains("int or range")); } #[test] fn fail_on_non_iterator() { - let actual = nu!(cwd: ".", pipeline("1 | drop 50")); + let actual = nu!("1 | drop 50"); assert!(actual.err.contains("only_supports_this_input_type")); } diff --git a/crates/nu-command/tests/commands/each.rs b/crates/nu-command/tests/commands/each.rs index 50dd8c6b3..0681d9e63 100644 --- a/crates/nu-command/tests/commands/each.rs +++ b/crates/nu-command/tests/commands/each.rs @@ -1,13 +1,11 @@ -use nu_test_support::{nu, pipeline}; +use nu_test_support::nu; #[test] fn each_works_separately() { let actual = nu!( - cwd: "tests/fixtures/formats", pipeline( - r#" - echo [1 2 3] | each { |it| echo $it 10 | math sum } | to json -r - "# - )); + cwd: "tests/fixtures/formats", + "echo [1 2 3] | each { |it| echo $it 10 | math sum } | to json -r" + ); assert_eq!(actual.out, "[11,12,13]"); } @@ -15,11 +13,9 @@ fn each_works_separately() { #[test] fn each_group_works() { let actual = nu!( - cwd: "tests/fixtures/formats", pipeline( - r#" - echo [1 2 3 4 5 6] | group 3 | to json --raw - "# - )); + cwd: "tests/fixtures/formats", + "echo [1 2 3 4 5 6] | group 3 | to json --raw" + ); assert_eq!(actual.out, "[[1,2,3],[4,5,6]]"); } @@ -27,11 +23,9 @@ fn each_group_works() { #[test] fn each_window() { let actual = nu!( - cwd: "tests/fixtures/formats", pipeline( - r#" - echo [1 2 3 4] | window 3 | to json --raw - "# - )); + cwd: "tests/fixtures/formats", + "echo [1 2 3 4] | window 3 | to json --raw" + ); assert_eq!(actual.out, "[[1,2,3],[2,3,4]]"); } @@ -39,11 +33,9 @@ fn each_window() { #[test] fn each_window_stride() { let actual = nu!( - cwd: "tests/fixtures/formats", pipeline( - r#" - echo [1 2 3 4 5 6] | window 3 -s 2 | to json --raw - "# - )); + cwd: "tests/fixtures/formats", + "echo [1 2 3 4 5 6] | window 3 -s 2 | to json --raw" + ); assert_eq!(actual.out, "[[1,2,3],[3,4,5]]"); } @@ -51,11 +43,9 @@ fn each_window_stride() { #[test] fn each_no_args_in_block() { let actual = nu!( - cwd: "tests/fixtures/formats", pipeline( - r#" - echo [[foo bar]; [a b] [c d] [e f]] | each {|i| $i | to json -r } | get 1 - "# - )); + cwd: "tests/fixtures/formats", + "echo [[foo bar]; [a b] [c d] [e f]] | each {|i| $i | to json -r } | get 1" + ); assert_eq!(actual.out, r#"{"foo": "c","bar": "d"}"#); } @@ -63,31 +53,23 @@ fn each_no_args_in_block() { #[test] fn each_implicit_it_in_block() { let actual = nu!( - cwd: "tests/fixtures/formats", pipeline( - r#" - echo [[foo bar]; [a b] [c d] [e f]] | each { |it| nu --testbin cococo $it.foo } | str join - "# - )); + cwd: "tests/fixtures/formats", + "echo [[foo bar]; [a b] [c d] [e f]] | each { |it| nu --testbin cococo $it.foo } | str join" + ); assert_eq!(actual.out, "ace"); } #[test] fn each_uses_enumerate_index() { - let actual = nu!( - cwd: ".", pipeline( - r#"[7 8 9 10] | enumerate | each {|el| $el.index } | to nuon"# - )); + let actual = nu!("[7 8 9 10] | enumerate | each {|el| $el.index } | to nuon"); assert_eq!(actual.out, "[0, 1, 2, 3]"); } #[test] fn each_while_uses_enumerate_index() { - let actual = nu!( - cwd: ".", pipeline( - r#"[7 8 9 10] | enumerate | each while {|el| $el.index } | to nuon"# - )); + let actual = nu!("[7 8 9 10] | enumerate | each while {|el| $el.index } | to nuon"); assert_eq!(actual.out, "[0, 1, 2, 3]"); } diff --git a/crates/nu-command/tests/commands/echo.rs b/crates/nu-command/tests/commands/echo.rs index cad2a6c77..44e6d8145 100644 --- a/crates/nu-command/tests/commands/echo.rs +++ b/crates/nu-command/tests/commands/echo.rs @@ -1,61 +1,36 @@ -use nu_test_support::{nu, pipeline}; +use nu_test_support::nu; #[test] fn echo_range_is_lazy() { - let actual = nu!( - cwd: "tests/fixtures/formats", pipeline( - r#" - echo 1..10000000000 | first 3 | to json --raw - "# - )); + let actual = nu!("echo 1..10000000000 | first 3 | to json --raw"); assert_eq!(actual.out, "[1,2,3]"); } #[test] fn echo_range_handles_inclusive() { - let actual = nu!( - cwd: "tests/fixtures/formats", pipeline( - r#" - echo 1..3 | each { |x| $x } | to json --raw - "# - )); + let actual = nu!("echo 1..3 | each { |x| $x } | to json --raw"); assert_eq!(actual.out, "[1,2,3]"); } #[test] fn echo_range_handles_exclusive() { - let actual = nu!( - cwd: "tests/fixtures/formats", pipeline( - r#" - echo 1..<3 | each { |x| $x } | to json --raw - "# - )); + let actual = nu!("echo 1..<3 | each { |x| $x } | to json --raw"); assert_eq!(actual.out, "[1,2]"); } #[test] fn echo_range_handles_inclusive_down() { - let actual = nu!( - cwd: "tests/fixtures/formats", pipeline( - r#" - echo 3..1 | each { |it| $it } | to json --raw - "# - )); + let actual = nu!("echo 3..1 | each { |it| $it } | to json --raw"); assert_eq!(actual.out, "[3,2,1]"); } #[test] fn echo_range_handles_exclusive_down() { - let actual = nu!( - cwd: "tests/fixtures/formats", pipeline( - r#" - echo 3..<1 | each { |it| $it } | to json --raw - "# - )); + let actual = nu!("echo 3..<1 | each { |it| $it } | to json --raw"); assert_eq!(actual.out, "[3,2]"); } diff --git a/crates/nu-command/tests/commands/empty.rs b/crates/nu-command/tests/commands/empty.rs index 9ba4567ad..7366f941d 100644 --- a/crates/nu-command/tests/commands/empty.rs +++ b/crates/nu-command/tests/commands/empty.rs @@ -2,8 +2,7 @@ use nu_test_support::{nu, pipeline}; #[test] fn reports_emptiness() { - let actual = nu!( - cwd: ".", pipeline( + let actual = nu!(pipeline( r#" [[] '' {} null] | all {|| @@ -17,8 +16,7 @@ fn reports_emptiness() { #[test] fn reports_nonemptiness() { - let actual = nu!( - cwd: ".", pipeline( + let actual = nu!(pipeline( r#" [[1] ' ' {a:1} 0] | any {|| @@ -32,14 +30,13 @@ fn reports_nonemptiness() { #[test] fn reports_emptiness_by_columns() { - let actual = nu!( - cwd: ".", pipeline( - r#" + let actual = nu!(pipeline( + " [{a:1 b:null c:null} {a:2 b:null c:null}] | any {|| is-empty b c } - "# + " )); assert_eq!(actual.out, "true"); @@ -47,14 +44,13 @@ fn reports_emptiness_by_columns() { #[test] fn reports_nonemptiness_by_columns() { - let actual = nu!( - cwd: ".", pipeline( - r#" + let actual = nu!(pipeline( + " [{a:1 b:null c:3} {a:null b:5 c:2}] | any {|| is-empty a b } - "# + " )); assert_eq!(actual.out, "false"); diff --git a/crates/nu-command/tests/commands/enter.rs b/crates/nu-command/tests/commands/enter.rs index 0ffcac946..86b88ed6c 100644 --- a/crates/nu-command/tests/commands/enter.rs +++ b/crates/nu-command/tests/commands/enter.rs @@ -28,7 +28,7 @@ fn knows_the_filesystems_entered() { nu!( cwd: dirs.test(), - r#" + " enter expected mkdir recycled enter ../red_pill @@ -47,7 +47,7 @@ fn knows_the_filesystems_entered() { n rm blue_pill --recursive exit - "# + " ); assert!(!red_pill_dir.exists()); diff --git a/crates/nu-command/tests/commands/error_make.rs b/crates/nu-command/tests/commands/error_make.rs index 40a1bb209..d70851ab5 100644 --- a/crates/nu-command/tests/commands/error_make.rs +++ b/crates/nu-command/tests/commands/error_make.rs @@ -1,13 +1,8 @@ -use nu_test_support::{nu, pipeline}; +use nu_test_support::nu; #[test] fn error_label_works() { - let actual = nu!( - cwd: ".", pipeline( - r#" - error make {msg:foo label:{text:unseen}} - "# - )); + let actual = nu!("error make {msg:foo label:{text:unseen}}"); assert!(actual.err.contains("unseen")); assert!(actual.err.contains("╰──")); @@ -15,24 +10,14 @@ fn error_label_works() { #[test] fn no_span_if_unspanned() { - let actual = nu!( - cwd: ".", pipeline( - r#" - error make -u {msg:foo label:{text:unseen}} - "# - )); + let actual = nu!("error make -u {msg:foo label:{text:unseen}}"); assert!(!actual.err.contains("unseen")); } #[test] fn error_start_bigger_than_end_should_fail() { - let actual = nu!( - cwd: ".", pipeline( - r#" - error make {msg: foo label: {text: bar start 456 end 123}} - "# - )); + let actual = nu!("error make {msg: foo label: {text: bar start 456 end 123}}"); assert!(!actual.err.contains("invalid error format")); assert!(!actual diff --git a/crates/nu-command/tests/commands/every.rs b/crates/nu-command/tests/commands/every.rs index c44ddfb50..688790c20 100644 --- a/crates/nu-command/tests/commands/every.rs +++ b/crates/nu-command/tests/commands/every.rs @@ -14,12 +14,12 @@ fn gets_all_rows_by_every_zero() { let actual = nu!( cwd: dirs.test(), pipeline( - r#" + " ls | get name | every 0 | to json --raw - "# + " )); assert_eq!( @@ -41,12 +41,12 @@ fn gets_no_rows_by_every_skip_zero() { let actual = nu!( cwd: dirs.test(), pipeline( - r#" + " ls | get name | every 0 --skip | to json --raw - "# + " )); assert_eq!(actual.out, "[]"); @@ -65,12 +65,12 @@ fn gets_all_rows_by_every_one() { let actual = nu!( cwd: dirs.test(), pipeline( - r#" + " ls | get name | every 1 | to json --raw - "# + " )); assert_eq!( @@ -92,12 +92,12 @@ fn gets_no_rows_by_every_skip_one() { let actual = nu!( cwd: dirs.test(), pipeline( - r#" + " ls | get name | every 1 --skip | to json --raw - "# + " )); assert_eq!(actual.out, "[]"); @@ -116,19 +116,14 @@ fn gets_first_row_by_every_too_much() { let actual = nu!( cwd: dirs.test(), pipeline( - r#" + " ls | get name | every 999 - "# + " )); - let expected = nu!( - cwd: dirs.test(), pipeline( - r#" - echo [ amigos.txt ] - "# - )); + let expected = nu!( cwd: dirs.test(), "echo [ amigos.txt ]"); assert_eq!(actual.out, expected.out); }) @@ -146,12 +141,12 @@ fn gets_all_rows_except_first_by_every_skip_too_much() { let actual = nu!( cwd: dirs.test(), pipeline( - r#" + " ls | get name | every 999 --skip | to json --raw - "# + " )); assert_eq!(actual.out, r#"["arepas.clu","los.txt","tres.txt"]"#); @@ -171,12 +166,12 @@ fn gets_every_third_row() { let actual = nu!( cwd: dirs.test(), pipeline( - r#" + " ls | get name | every 3 | to json --raw - "# + " )); assert_eq!(actual.out, r#"["amigos.txt","quatro.txt"]"#); @@ -196,12 +191,12 @@ fn skips_every_third_row() { let actual = nu!( cwd: dirs.test(), pipeline( - r#" + " ls | get name | every 3 --skip | to json --raw - "# + " )); assert_eq!(actual.out, r#"["arepas.clu","los.txt","tres.txt"]"#);