From f0404d434c32c48f6f35f1b80f6f2e00ba30fc4a Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Fri, 3 Aug 2018 19:53:06 -0700 Subject: [PATCH] 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. --- tests/integration.rs | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index 5bf39be..62412fb 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -234,19 +234,19 @@ integration_test! { integration_test! { name: backtick_success, - justfile: "a = `printf Hello,`\nbar:\n printf '{{a + `printf ' world!'`}}'", + justfile: "a = `printf Hello,`\nbar:\n printf '{{a + `printf ' world.'`}}'", args: (), - stdout: "Hello, world!", - stderr: "printf 'Hello, world!'\n", + stdout: "Hello, world.", + stderr: "printf 'Hello, world.'\n", status: EXIT_SUCCESS, } integration_test! { name: backtick_trimming, - justfile: "a = `echo Hello,`\nbar:\n echo '{{a + `echo ' world!'`}}'", + justfile: "a = `echo Hello,`\nbar:\n echo '{{a + `echo ' world.'`}}'", args: (), - stdout: "Hello, world!\n", - stderr: "echo 'Hello, world!'\n", + stdout: "Hello, world.\n", + stderr: "echo 'Hello, world.'\n", status: EXIT_SUCCESS, } @@ -974,12 +974,12 @@ integration_test! { name: use_raw_string_default, justfile: r#" bar: -hello baz arg='XYZ\t" ': +hello baz arg='XYZ" ': printf '{{baz}}...{{arg}}' "#, args: ("hello", "ABC"), - stdout: "ABC...XYZ\t\"\t", - stderr: "printf 'ABC...XYZ\\t\"\t'\n", + stdout: "ABC...XYZ\"\t", + stderr: "printf 'ABC...XYZ\"\t'\n", status: EXIT_SUCCESS, } @@ -1194,10 +1194,11 @@ foo: status: EXIT_SUCCESS, } +#[cfg(not(windows))] integration_test! { name: env_var_functions, justfile: r#" -p = env_var('PATH') +p = env_var('USER') b = env_var_or_default('ZADDY', 'HTAP') x = env_var_or_default('XYZ', 'ABC') @@ -1205,11 +1206,29 @@ foo: /bin/echo '{{p}}' '{{b}}' '{{x}}' "#, args: (), - stdout: format!("{} HTAP ABC\n", env::var("PATH").unwrap()).as_str(), - stderr: format!("/bin/echo '{}' '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("USER").unwrap()).as_str(), 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! { name: env_var_failure, justfile: "a:\n echo {{env_var('ZADDY')}}",