diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-19 09:26:03 +0000 |
commit | 9918693037dce8aa4bb6f08741b6812923486c18 (patch) | |
tree | 21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /vendor/gix-command/tests | |
parent | Releasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff) | |
download | rustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip |
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-command/tests')
-rw-r--r-- | vendor/gix-command/tests/command.rs | 108 |
1 files changed, 0 insertions, 108 deletions
diff --git a/vendor/gix-command/tests/command.rs b/vendor/gix-command/tests/command.rs deleted file mode 100644 index 606066da1..000000000 --- a/vendor/gix-command/tests/command.rs +++ /dev/null @@ -1,108 +0,0 @@ -use gix_testtools::Result; - -mod prepare { - fn quoted(input: &[&str]) -> String { - input.iter().map(|s| format!("\"{s}\"")).collect::<Vec<_>>().join(" ") - } - #[test] - fn single_and_multiple_arguments() { - let cmd = std::process::Command::from(gix_command::prepare("ls").arg("first").args(["second", "third"])); - assert_eq!(format!("{cmd:?}"), quoted(&["ls", "first", "second", "third"])); - } -} - -mod spawn { - #[cfg(unix)] - use bstr::ByteSlice; - - #[test] - #[cfg(unix)] - fn environment_variables_are_passed_one_by_one() -> crate::Result { - let out = gix_command::prepare("echo $FIRST $SECOND") - .env("FIRST", "first") - .env("SECOND", "second") - .with_shell() - .spawn()? - .wait_with_output()?; - assert_eq!(out.stdout.as_bstr(), "first second\n"); - Ok(()) - } - - #[test] - #[cfg(unix)] - fn disallow_shell() -> crate::Result { - let out = gix_command::prepare("PATH= echo hi") - .with_shell() - .spawn()? - .wait_with_output()?; - assert_eq!(out.stdout.as_bstr(), "hi\n"); - - let mut cmd: std::process::Command = gix_command::prepare("echo hi").with_shell().without_shell().into(); - assert!( - cmd.env_remove("PATH").spawn().is_err(), - "no command named 'echo hi' exists" - ); - Ok(()) - } - - #[test] - fn direct_command_execution_searches_in_path() -> crate::Result { - assert!(gix_command::prepare(if cfg!(unix) { "ls" } else { "dir.exe" }) - .spawn()? - .wait()? - .success()); - Ok(()) - } - - #[cfg(unix)] - #[test] - fn direct_command_with_absolute_command_path() -> crate::Result { - assert!(gix_command::prepare("/bin/ls").spawn()?.wait()?.success()); - Ok(()) - } - - mod with_shell { - use gix_testtools::bstr::ByteSlice; - - #[test] - fn command_in_path_with_args() -> crate::Result { - assert!(gix_command::prepare(if cfg!(unix) { "ls -l" } else { "dir.exe -a" }) - .with_shell() - .spawn()? - .wait()? - .success()); - Ok(()) - } - - #[test] - fn sh_shell_specific_script_code() -> crate::Result { - assert!(gix_command::prepare(":;:;:").with_shell().spawn()?.wait()?.success()); - Ok(()) - } - - #[test] - fn sh_shell_specific_script_code_with_single_extra_arg() -> crate::Result { - let out = gix_command::prepare("printf") - .with_shell() - .arg("1") - .spawn()? - .wait_with_output()?; - assert!(out.status.success()); - assert_eq!(out.stdout.as_bstr(), "1"); - Ok(()) - } - - #[test] - fn sh_shell_specific_script_code_with_multiple_extra_args() -> crate::Result { - let out = gix_command::prepare("printf") - .with_shell() - .arg("%s") - .arg("arg") - .spawn()? - .wait_with_output()?; - assert!(out.status.success()); - assert_eq!(out.stdout.as_bstr(), "arg"); - Ok(()) - } - } -} |