Fix shell extension tests on Windows

This commit is contained in:
Federico Terzi 2019-12-13 22:33:35 +01:00
parent 12fc31700e
commit 5db9d92642

View File

@ -93,8 +93,13 @@ mod tests {
let output = extension.calculate(&params); let output = extension.calculate(&params);
assert!(output.is_some()); assert!(output.is_some());
if cfg!(target_os = "windows") {
assert_eq!(output.unwrap(), "hello world\r\n");
}else{
assert_eq!(output.unwrap(), "hello world\n"); assert_eq!(output.unwrap(), "hello world\n");
} }
}
#[test] #[test]
fn test_shell_trimmed() { fn test_shell_trimmed() {
@ -112,7 +117,12 @@ mod tests {
#[test] #[test]
fn test_shell_trimmed_2() { fn test_shell_trimmed_2() {
let mut params = Mapping::new(); let mut params = Mapping::new();
if cfg!(target_os = "windows") {
params.insert(Value::from("cmd"), Value::from("echo hello world "));
}else{
params.insert(Value::from("cmd"), Value::from("echo \" hello world \"")); params.insert(Value::from("cmd"), Value::from("echo \" hello world \""));
}
params.insert(Value::from("trim"), Value::from(true)); params.insert(Value::from("trim"), Value::from(true));
let extension = ShellExtension::new(); let extension = ShellExtension::new();
@ -132,8 +142,12 @@ mod tests {
let output = extension.calculate(&params); let output = extension.calculate(&params);
assert!(output.is_some()); assert!(output.is_some());
if cfg!(target_os = "windows") {
assert_eq!(output.unwrap(), "hello world\r\n");
}else{
assert_eq!(output.unwrap(), "hello world\n"); assert_eq!(output.unwrap(), "hello world\n");
} }
}
#[test] #[test]
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]