From 78f52e8b668e26e9b02a29d682ffb5532a13da87 Mon Sep 17 00:00:00 2001 From: Andrej Kolchin Date: Fri, 15 Dec 2023 06:53:19 +0000 Subject: [PATCH] Replace bash with POSIX sh in tests (#11293) Just my small pet peeve. This allows to run tests without bash installed. There were only two minor tests which required a change. --- crates/nu-command/src/system/run_external.rs | 4 ++-- crates/nu-command/tests/commands/do_.rs | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/crates/nu-command/src/system/run_external.rs b/crates/nu-command/src/system/run_external.rs index 6b3bbdf248..cfd9e71eb6 100644 --- a/crates/nu-command/src/system/run_external.rs +++ b/crates/nu-command/src/system/run_external.rs @@ -927,9 +927,9 @@ mod test { #[test] fn argument_with_inner_quotes_test() { - let input = r#"bash -c 'echo a'"#.into(); + let input = r#"sh -c 'echo a'"#.into(); let res = remove_quotes(input); - assert_eq!("bash -c 'echo a'", res) + assert_eq!("sh -c 'echo a'", res) } } diff --git a/crates/nu-command/tests/commands/do_.rs b/crates/nu-command/tests/commands/do_.rs index ff58cc413d..e1b982b256 100644 --- a/crates/nu-command/tests/commands/do_.rs +++ b/crates/nu-command/tests/commands/do_.rs @@ -122,27 +122,24 @@ fn capture_error_with_both_stdout_stderr_messages_not_hang_nushell() { "external with many stdout and stderr messages", |dirs, sandbox| { let script_body = r#" - x=$(printf '=%.0s' {1..40960}) + x=$(printf '=%.0s' $(seq 40960)) echo $x echo $x 1>&2 "#; - let mut expect_body = String::new(); - for _ in 0..40960 { - expect_body.push('='); - } + let expect_body = "=".repeat(40960); sandbox.with_files(vec![FileWithContent("test.sh", script_body)]); // check for stdout let actual = nu!( cwd: dirs.test(), pipeline( - "do -c {bash test.sh} | complete | get stdout | str trim", + "do -c {sh test.sh} | complete | get stdout | str trim", )); assert_eq!(actual.out, expect_body); // check for stderr let actual = nu!( cwd: dirs.test(), pipeline( - "do -c {bash test.sh} | complete | get stderr | str trim", + "do -c {sh test.sh} | complete | get stderr | str trim", )); assert_eq!(actual.out, expect_body); },