Fix integration tests with dash (#338)

Integration tests run with bash, dash, and whatever's installed as `sh`, to ensure compatibility with a wide range of systems.

This commit changed the way that dash escapes special characters, which broke the integration tests:

https://git.kernel.org/pub/scm/utils/dash/dash.git/commit/?id=6900ff60ef7347a8c1445853a8f4689808e0976e

This commit modifies our tests to be compatible with dash before and after the changes, and should fix the Travis build.
This commit is contained in:
Casey Rodarmor 2018-08-03 19:53:06 -07:00 committed by GitHub
parent e4ab3416f0
commit f0404d434c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -234,19 +234,19 @@ integration_test! {
integration_test! { integration_test! {
name: backtick_success, name: backtick_success,
justfile: "a = `printf Hello,`\nbar:\n printf '{{a + `printf ' world!'`}}'", justfile: "a = `printf Hello,`\nbar:\n printf '{{a + `printf ' world.'`}}'",
args: (), args: (),
stdout: "Hello, world!", stdout: "Hello, world.",
stderr: "printf 'Hello, world!'\n", stderr: "printf 'Hello, world.'\n",
status: EXIT_SUCCESS, status: EXIT_SUCCESS,
} }
integration_test! { integration_test! {
name: backtick_trimming, name: backtick_trimming,
justfile: "a = `echo Hello,`\nbar:\n echo '{{a + `echo ' world!'`}}'", justfile: "a = `echo Hello,`\nbar:\n echo '{{a + `echo ' world.'`}}'",
args: (), args: (),
stdout: "Hello, world!\n", stdout: "Hello, world.\n",
stderr: "echo 'Hello, world!'\n", stderr: "echo 'Hello, world.'\n",
status: EXIT_SUCCESS, status: EXIT_SUCCESS,
} }
@ -974,12 +974,12 @@ integration_test! {
name: use_raw_string_default, name: use_raw_string_default,
justfile: r#" justfile: r#"
bar: bar:
hello baz arg='XYZ\t" ': hello baz arg='XYZ" ':
printf '{{baz}}...{{arg}}' printf '{{baz}}...{{arg}}'
"#, "#,
args: ("hello", "ABC"), args: ("hello", "ABC"),
stdout: "ABC...XYZ\t\"\t", stdout: "ABC...XYZ\"\t",
stderr: "printf 'ABC...XYZ\\t\"\t'\n", stderr: "printf 'ABC...XYZ\"\t'\n",
status: EXIT_SUCCESS, status: EXIT_SUCCESS,
} }
@ -1194,10 +1194,11 @@ foo:
status: EXIT_SUCCESS, status: EXIT_SUCCESS,
} }
#[cfg(not(windows))]
integration_test! { integration_test! {
name: env_var_functions, name: env_var_functions,
justfile: r#" justfile: r#"
p = env_var('PATH') p = env_var('USER')
b = env_var_or_default('ZADDY', 'HTAP') b = env_var_or_default('ZADDY', 'HTAP')
x = env_var_or_default('XYZ', 'ABC') x = env_var_or_default('XYZ', 'ABC')
@ -1205,11 +1206,29 @@ foo:
/bin/echo '{{p}}' '{{b}}' '{{x}}' /bin/echo '{{p}}' '{{b}}' '{{x}}'
"#, "#,
args: (), args: (),
stdout: format!("{} HTAP ABC\n", env::var("PATH").unwrap()).as_str(), stdout: format!("{} HTAP ABC\n", env::var("USER").unwrap()).as_str(),
stderr: format!("/bin/echo '{}' 'HTAP' 'ABC'\n", env::var("PATH").unwrap()).as_str(), stderr: format!("/bin/echo '{}' 'HTAP' 'ABC'\n", env::var("USER").unwrap()).as_str(),
status: EXIT_SUCCESS, status: EXIT_SUCCESS,
} }
#[cfg(windows)]
integration_test! {
name: env_var_functions,
justfile: r#"
p = env_var('USERNAME')
b = env_var_or_default('ZADDY', 'HTAP')
x = env_var_or_default('XYZ', 'ABC')
foo:
/bin/echo '{{p}}' '{{b}}' '{{x}}'
"#,
args: (),
stdout: format!("{} HTAP ABC\n", env::var("USERNAME").unwrap()).as_str(),
stderr: format!("/bin/echo '{}' 'HTAP' 'ABC'\n", env::var("USERNAME").unwrap()).as_str(),
status: EXIT_SUCCESS,
}
integration_test! { integration_test! {
name: env_var_failure, name: env_var_failure,
justfile: "a:\n echo {{env_var('ZADDY')}}", justfile: "a:\n echo {{env_var('ZADDY')}}",