2019-04-19 12:17:43 +03:00
|
|
|
use colored_diff::PrettyDifference;
|
2017-11-30 21:38:44 +03:00
|
|
|
use executable_path::executable_path;
|
2017-11-17 10:30:08 +03:00
|
|
|
use libc::{EXIT_FAILURE, EXIT_SUCCESS};
|
2019-04-17 05:52:16 +03:00
|
|
|
use std::{
|
|
|
|
env, fs,
|
|
|
|
io::Write,
|
|
|
|
process::{Command, Stdio},
|
|
|
|
str,
|
|
|
|
};
|
2017-11-17 10:30:08 +03:00
|
|
|
use tempdir::TempDir;
|
2017-04-23 02:15:15 +03:00
|
|
|
|
|
|
|
/// Instantiate integration tests for a given test case using
|
|
|
|
/// sh, dash, and bash.
|
|
|
|
///
|
|
|
|
/// Although `sh` is likely to be dash or bash, we include it
|
|
|
|
/// in case it's a different version or a different shell entirely.
|
|
|
|
///
|
|
|
|
/// For example, on FreeBSD, `sh` is ash.
|
|
|
|
macro_rules! integration_test {
|
|
|
|
(
|
|
|
|
name: $name:ident,
|
|
|
|
justfile: $text:tt,
|
|
|
|
args: ($($arg:tt)*),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: $stdin:expr,
|
2017-05-13 05:03:43 +03:00
|
|
|
stdout: $stdout:expr,
|
|
|
|
stderr: $stderr:expr,
|
|
|
|
status: $status:expr,
|
2017-04-23 02:15:15 +03:00
|
|
|
) => {
|
|
|
|
mod $name {
|
2017-11-17 10:30:08 +03:00
|
|
|
use super::*;
|
2017-04-23 02:15:15 +03:00
|
|
|
|
|
|
|
// silence unused import warnings
|
|
|
|
const __: i32 = EXIT_SUCCESS;
|
|
|
|
|
2019-04-17 05:52:16 +03:00
|
|
|
#[test] fn sh() { integration_test("sh", $text, &[$($arg)*], $stdin, $stdout, $stderr, $status); }
|
|
|
|
#[test] fn dash() { integration_test("dash", $text, &[$($arg)*], $stdin, $stdout, $stderr, $status); }
|
|
|
|
#[test] fn bash() { integration_test("bash", $text, &[$($arg)*], $stdin, $stdout, $stderr, $status); }
|
2017-04-23 02:15:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-10-29 01:25:59 +03:00
|
|
|
|
|
|
|
fn integration_test(
|
2018-12-09 01:29:41 +03:00
|
|
|
shell: &str,
|
|
|
|
justfile: &str,
|
|
|
|
args: &[&str],
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: &str,
|
2016-10-29 01:25:59 +03:00
|
|
|
expected_stdout: &str,
|
|
|
|
expected_stderr: &str,
|
2017-04-23 02:15:15 +03:00
|
|
|
expected_status: i32,
|
2016-10-29 01:25:59 +03:00
|
|
|
) {
|
2018-12-09 01:29:41 +03:00
|
|
|
let tmp = TempDir::new("just-integration").unwrap_or_else(|err| {
|
|
|
|
panic!(
|
|
|
|
"integration test: failed to create temporary directory: {}",
|
|
|
|
err
|
|
|
|
)
|
|
|
|
});
|
2018-03-06 00:21:35 +03:00
|
|
|
|
|
|
|
let mut justfile_path = tmp.path().to_path_buf();
|
|
|
|
justfile_path.push("justfile");
|
2019-04-17 08:06:28 +03:00
|
|
|
fs::write(justfile_path, justfile).unwrap();
|
2018-03-06 00:21:35 +03:00
|
|
|
|
|
|
|
let mut dotenv_path = tmp.path().to_path_buf();
|
|
|
|
dotenv_path.push(".env");
|
2019-04-17 08:06:28 +03:00
|
|
|
fs::write(dotenv_path, "DOTENV_KEY=dotenv-value").unwrap();
|
2017-05-08 05:48:07 +03:00
|
|
|
|
2019-04-17 05:52:16 +03:00
|
|
|
let mut child = Command::new(&executable_path("just"))
|
2016-10-29 01:25:59 +03:00
|
|
|
.current_dir(tmp.path())
|
2017-04-23 02:15:15 +03:00
|
|
|
.args(&["--shell", shell])
|
2017-08-19 00:21:18 +03:00
|
|
|
.args(args)
|
2019-04-17 05:52:16 +03:00
|
|
|
.stdin(Stdio::piped())
|
|
|
|
.stdout(Stdio::piped())
|
|
|
|
.stderr(Stdio::piped())
|
|
|
|
.spawn()
|
2016-10-31 04:12:59 +03:00
|
|
|
.expect("just invocation failed");
|
2016-10-29 01:25:59 +03:00
|
|
|
|
2019-04-17 05:52:16 +03:00
|
|
|
{
|
|
|
|
let mut stdin_handle = child.stdin.take().expect("failed to unwrap stdin handle");
|
|
|
|
|
|
|
|
stdin_handle
|
|
|
|
.write_all(stdin.as_bytes())
|
|
|
|
.expect("failed to write stdin to just process");
|
|
|
|
}
|
|
|
|
|
|
|
|
let output = child
|
|
|
|
.wait_with_output()
|
|
|
|
.expect("failed to wait for just process");
|
|
|
|
|
2016-10-29 01:25:59 +03:00
|
|
|
let mut failure = false;
|
|
|
|
|
|
|
|
let status = output.status.code().unwrap();
|
|
|
|
if status != expected_status {
|
|
|
|
println!("bad status: {} != {}", status, expected_status);
|
|
|
|
failure = true;
|
|
|
|
}
|
|
|
|
|
2016-11-17 07:17:24 +03:00
|
|
|
let stdout = str::from_utf8(&output.stdout).unwrap();
|
2019-04-19 12:17:43 +03:00
|
|
|
|
2016-10-29 01:25:59 +03:00
|
|
|
if stdout != expected_stdout {
|
2018-12-09 01:29:41 +03:00
|
|
|
println!(
|
2019-04-19 12:17:43 +03:00
|
|
|
"bad stdout:\n {}",
|
|
|
|
PrettyDifference {
|
|
|
|
expected: expected_stdout,
|
|
|
|
actual: stdout
|
|
|
|
},
|
2018-12-09 01:29:41 +03:00
|
|
|
);
|
2016-10-29 01:25:59 +03:00
|
|
|
failure = true;
|
|
|
|
}
|
|
|
|
|
2016-11-17 07:17:24 +03:00
|
|
|
let stderr = str::from_utf8(&output.stderr).unwrap();
|
2016-10-29 01:25:59 +03:00
|
|
|
if stderr != expected_stderr {
|
2018-12-09 01:29:41 +03:00
|
|
|
println!(
|
2019-04-19 12:17:43 +03:00
|
|
|
"bad stderr: {}",
|
|
|
|
PrettyDifference {
|
|
|
|
expected: expected_stderr,
|
|
|
|
actual: stderr
|
|
|
|
},
|
2018-12-09 01:29:41 +03:00
|
|
|
);
|
2016-10-29 01:25:59 +03:00
|
|
|
failure = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if failure {
|
|
|
|
panic!("test failed");
|
|
|
|
}
|
2019-04-12 09:58:08 +03:00
|
|
|
|
|
|
|
if expected_status == EXIT_SUCCESS {
|
|
|
|
println!("Reparsing...");
|
|
|
|
|
2019-04-17 05:52:16 +03:00
|
|
|
let output = Command::new(&executable_path("just"))
|
2019-04-12 09:58:08 +03:00
|
|
|
.current_dir(tmp.path())
|
|
|
|
.arg("--dump")
|
|
|
|
.output()
|
|
|
|
.expect("just invocation failed");
|
|
|
|
|
|
|
|
if !output.status.success() {
|
|
|
|
panic!("dump failed: {}", output.status);
|
|
|
|
}
|
|
|
|
|
|
|
|
let dumped = String::from_utf8(output.stdout).unwrap();
|
|
|
|
|
|
|
|
let reparsed_path = tmp.path().join("reparsed.just");
|
|
|
|
|
|
|
|
fs::write(&reparsed_path, &dumped).unwrap();
|
|
|
|
|
2019-04-17 05:52:16 +03:00
|
|
|
let output = Command::new(&executable_path("just"))
|
2019-04-12 09:58:08 +03:00
|
|
|
.current_dir(tmp.path())
|
|
|
|
.arg("--justfile")
|
|
|
|
.arg(&reparsed_path)
|
|
|
|
.arg("--dump")
|
|
|
|
.output()
|
|
|
|
.expect("just invocation failed");
|
|
|
|
|
|
|
|
if !output.status.success() {
|
|
|
|
panic!("reparse failed: {}", output.status);
|
|
|
|
}
|
|
|
|
|
|
|
|
let reparsed = String::from_utf8(output.stdout).unwrap();
|
|
|
|
|
|
|
|
if reparsed != dumped {
|
2019-04-19 12:17:43 +03:00
|
|
|
println!(
|
|
|
|
"reparse mismatch:\n {}",
|
|
|
|
PrettyDifference {
|
|
|
|
expected: &dumped,
|
|
|
|
actual: &reparsed
|
|
|
|
},
|
|
|
|
);
|
2019-04-12 09:58:08 +03:00
|
|
|
}
|
|
|
|
}
|
2016-10-29 01:25:59 +03:00
|
|
|
}
|
|
|
|
|
2019-04-11 22:30:29 +03:00
|
|
|
integration_test! {
|
|
|
|
name: alias_listing,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "foo:\n echo foo\nalias f := foo",
|
2019-04-11 22:30:29 +03:00
|
|
|
args: ("--list"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-11 22:30:29 +03:00
|
|
|
stdout: "Available recipes:
|
|
|
|
foo
|
|
|
|
f # alias for `foo`
|
|
|
|
",
|
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: alias_listing_multiple_aliases,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "foo:\n echo foo\nalias f := foo\nalias fo := foo",
|
2019-04-11 22:30:29 +03:00
|
|
|
args: ("--list"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-11 22:30:29 +03:00
|
|
|
stdout: "Available recipes:
|
|
|
|
foo
|
|
|
|
f # alias for `foo`
|
|
|
|
fo # alias for `foo`
|
|
|
|
",
|
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: alias_listing_parameters,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "foo PARAM='foo':\n echo {{PARAM}}\nalias f := foo",
|
2019-04-11 22:30:29 +03:00
|
|
|
args: ("--list"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-11 22:30:29 +03:00
|
|
|
stdout: "Available recipes:
|
|
|
|
foo PARAM='foo'
|
|
|
|
f PARAM='foo' # alias for `foo`
|
|
|
|
",
|
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
2019-04-12 01:57:34 +03:00
|
|
|
integration_test! {
|
|
|
|
name: alias_listing_private,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "foo PARAM='foo':\n echo {{PARAM}}\nalias _f := foo",
|
2019-04-12 01:57:34 +03:00
|
|
|
args: ("--list"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-12 01:57:34 +03:00
|
|
|
stdout: "Available recipes:
|
|
|
|
foo PARAM='foo'
|
|
|
|
",
|
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
2019-04-11 22:30:29 +03:00
|
|
|
integration_test! {
|
|
|
|
name: alias,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "foo:\n echo foo\nalias f := foo",
|
2019-04-11 22:30:29 +03:00
|
|
|
args: ("f"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-11 22:30:29 +03:00
|
|
|
stdout: "foo\n",
|
|
|
|
stderr: "echo foo\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: alias_with_parameters,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "foo value='foo':\n echo {{value}}\nalias f := foo",
|
2019-04-11 22:30:29 +03:00
|
|
|
args: ("f", "bar"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-11 22:30:29 +03:00
|
|
|
stdout: "bar\n",
|
|
|
|
stderr: "echo bar\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: alias_with_dependencies,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "foo:\n echo foo\nbar: foo\nalias b := bar",
|
2019-04-11 22:30:29 +03:00
|
|
|
args: ("b"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-11 22:30:29 +03:00
|
|
|
stdout: "foo\n",
|
|
|
|
stderr: "echo foo\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: duplicate_alias,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "alias foo := bar\nalias foo := baz\n",
|
2019-04-11 22:30:29 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-11 22:30:29 +03:00
|
|
|
stdout: "" ,
|
|
|
|
stderr: "error: Alias `foo` first defined on line `1` is redefined on line `2`
|
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
2 | alias foo := baz
|
2019-04-11 22:30:29 +03:00
|
|
|
| ^^^
|
|
|
|
",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: unknown_alias_target,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "alias foo := bar\n",
|
2019-04-11 22:30:29 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-11 22:30:29 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Alias `foo` has an unknown target `bar`
|
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
1 | alias foo := bar
|
2019-04-11 22:30:29 +03:00
|
|
|
| ^^^
|
|
|
|
",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: alias_shadows_recipe,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "bar:\n echo bar\nalias foo := bar\nfoo:\n echo foo",
|
2019-04-11 22:30:29 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-11 22:30:29 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Alias `foo` defined on `3` shadows recipe defined on `4`
|
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
3 | alias foo := bar
|
2019-04-11 22:30:29 +03:00
|
|
|
| ^^^
|
|
|
|
",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: default,
|
|
|
|
justfile: "default:\n echo hello\nother: \n echo bar",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "hello\n",
|
|
|
|
stderr: "echo hello\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-05 11:25:36 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: quiet,
|
|
|
|
justfile: "default:\n @echo hello",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "hello\n",
|
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-12-30 11:09:35 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: verbose,
|
|
|
|
justfile: "default:\n @echo hello",
|
|
|
|
args: ("--verbose"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "hello\n",
|
|
|
|
stderr: "===> Running recipe `default`...\necho hello\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-12-30 11:09:35 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: order,
|
|
|
|
justfile: "
|
2016-10-29 01:34:01 +03:00
|
|
|
b: a
|
|
|
|
echo b
|
|
|
|
@mv a b
|
|
|
|
|
|
|
|
a:
|
|
|
|
echo a
|
|
|
|
@touch F
|
|
|
|
@touch a
|
|
|
|
|
|
|
|
d: c
|
|
|
|
echo d
|
|
|
|
@rm c
|
|
|
|
|
|
|
|
c: b
|
|
|
|
echo c
|
2017-04-23 02:15:15 +03:00
|
|
|
@mv b c",
|
|
|
|
args: ("a", "d"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "a\nb\nc\nd\n",
|
|
|
|
stderr: "echo a\necho b\necho c\necho d\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: summary,
|
|
|
|
justfile: "b: a
|
2016-10-29 01:59:50 +03:00
|
|
|
a:
|
|
|
|
d: c
|
2017-10-07 09:48:07 +03:00
|
|
|
c: b
|
|
|
|
_z: _y
|
|
|
|
_y:
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--summary"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "a b c d\n",
|
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: select,
|
|
|
|
justfile: "b:
|
2016-10-29 02:32:13 +03:00
|
|
|
@echo b
|
|
|
|
a:
|
|
|
|
@echo a
|
|
|
|
d:
|
|
|
|
@echo d
|
|
|
|
c:
|
2017-04-23 02:15:15 +03:00
|
|
|
@echo c",
|
|
|
|
args: ("d", "c"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "d\nc\n",
|
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: print,
|
|
|
|
justfile: "b:
|
2016-10-30 10:20:29 +03:00
|
|
|
echo b
|
|
|
|
a:
|
|
|
|
echo a
|
|
|
|
d:
|
|
|
|
echo d
|
|
|
|
c:
|
2017-04-23 02:15:15 +03:00
|
|
|
echo c",
|
|
|
|
args: ("d", "c"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "d\nc\n",
|
|
|
|
stderr: "echo d\necho c\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-10-30 10:20:29 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: show,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: r#"hello := "foo"
|
|
|
|
bar := hello + hello
|
2016-10-29 02:32:13 +03:00
|
|
|
recipe:
|
2017-04-23 02:15:15 +03:00
|
|
|
echo {{hello + "bar" + bar}}"#,
|
|
|
|
args: ("--show", "recipe"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: r#"recipe:
|
2016-10-29 02:32:13 +03:00
|
|
|
echo {{hello + "bar" + bar}}
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-10-29 02:32:13 +03:00
|
|
|
}
|
2016-10-29 05:38:03 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: status_passthrough,
|
|
|
|
justfile: "
|
2016-11-17 09:18:55 +03:00
|
|
|
|
|
|
|
hello:
|
|
|
|
|
2016-10-29 01:59:50 +03:00
|
|
|
recipe:
|
2017-04-23 02:15:15 +03:00
|
|
|
@exit 100",
|
|
|
|
args: ("recipe"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Recipe `recipe` failed on line 6 with exit code 100\n",
|
|
|
|
status: 100,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: unknown_dependency,
|
|
|
|
justfile: "bar:\nhello:\nfoo: bar baaaaaaaz hello",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Recipe `foo` has unknown dependency `baaaaaaaz`
|
2016-10-29 06:34:25 +03:00
|
|
|
|
|
|
|
|
3 | foo: bar baaaaaaaz hello
|
|
|
|
| ^^^^^^^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: backtick_success,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "a := `printf Hello,`\nbar:\n printf '{{a + `printf ' world.'`}}'",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2018-08-04 05:53:06 +03:00
|
|
|
stdout: "Hello, world.",
|
|
|
|
stderr: "printf 'Hello, world.'\n",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: backtick_trimming,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "a := `echo Hello,`\nbar:\n echo '{{a + `echo ' world.'`}}'",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2018-08-04 05:53:06 +03:00
|
|
|
stdout: "Hello, world.\n",
|
|
|
|
stderr: "echo 'Hello, world.'\n",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: backtick_code_assignment,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "b := a\na := `exit 100`\nbar:\n echo '{{`exit 200`}}'",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 100
|
2016-10-30 11:27:05 +03:00
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
2 | a := `exit 100`
|
|
|
|
| ^^^^^^^^^^
|
2016-10-30 11:27:05 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 100,
|
2016-10-30 11:27:05 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: backtick_code_interpolation,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "b := a\na := `echo hello`\nbar:\n echo '{{`exit 200`}}'",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 200
|
2016-10-30 11:27:05 +03:00
|
|
|
|
|
2016-11-05 11:19:54 +03:00
|
|
|
4 | echo '{{`exit 200`}}'
|
|
|
|
| ^^^^^^^^^^
|
2016-10-30 11:27:05 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 200,
|
2016-10-30 11:27:05 +03:00
|
|
|
}
|
|
|
|
|
2019-04-16 08:40:02 +03:00
|
|
|
integration_test! {
|
|
|
|
name: backtick_code_interpolation_mod,
|
|
|
|
justfile: "f:\n 無{{`exit 200`}}",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-16 08:40:02 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 200
|
|
|
|
|
|
|
|
|
2 | 無{{`exit 200`}}
|
|
|
|
| ^^^^^^^^^^
|
|
|
|
",
|
|
|
|
status: 200,
|
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: backtick_code_interpolation_tab,
|
|
|
|
justfile: "
|
2016-11-12 02:18:42 +03:00
|
|
|
backtick-fail:
|
|
|
|
\techo {{`exit 1`}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 1
|
2016-11-12 02:18:42 +03:00
|
|
|
|
|
|
|
|
3 | echo {{`exit 1`}}
|
|
|
|
| ^^^^^^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 1,
|
2016-11-12 02:18:42 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: backtick_code_interpolation_tabs,
|
|
|
|
justfile: "
|
2016-11-12 02:18:42 +03:00
|
|
|
backtick-fail:
|
|
|
|
\techo {{\t`exit 1`}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 1
|
2016-11-12 02:18:42 +03:00
|
|
|
|
|
|
|
|
3 | echo {{ `exit 1`}}
|
|
|
|
| ^^^^^^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 1,
|
2016-11-12 02:18:42 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: backtick_code_interpolation_inner_tab,
|
|
|
|
justfile: "
|
2016-11-12 02:18:42 +03:00
|
|
|
backtick-fail:
|
|
|
|
\techo {{\t`exit\t\t1`}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 1
|
2016-11-12 02:18:42 +03:00
|
|
|
|
|
|
|
|
3 | echo {{ `exit 1`}}
|
|
|
|
| ^^^^^^^^^^^^^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 1,
|
2016-11-12 02:18:42 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: backtick_code_interpolation_leading_emoji,
|
|
|
|
justfile: "
|
2016-11-12 02:18:42 +03:00
|
|
|
backtick-fail:
|
|
|
|
\techo 😬{{`exit 1`}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 1
|
2016-11-12 02:18:42 +03:00
|
|
|
|
|
|
|
|
3 | echo 😬{{`exit 1`}}
|
2017-04-21 07:38:44 +03:00
|
|
|
| ^^^^^^^^
|
2016-11-12 02:18:42 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 1,
|
2016-11-12 02:18:42 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: backtick_code_interpolation_unicode_hell,
|
|
|
|
justfile: "
|
2016-11-12 02:18:42 +03:00
|
|
|
backtick-fail:
|
2017-04-24 02:36:38 +03:00
|
|
|
\techo \t\t\t😬鎌鼬{{\t\t`exit 1 # \t\t\tabc`}}\t\t\t😬鎌鼬
|
2016-11-12 02:18:42 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 1
|
2016-11-12 02:18:42 +03:00
|
|
|
|
|
2017-04-24 02:36:38 +03:00
|
|
|
3 | echo 😬鎌鼬{{ `exit 1 # abc`}} 😬鎌鼬
|
|
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2016-11-12 02:18:42 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 1,
|
2016-11-12 02:18:42 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: backtick_code_long,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "\n\n\n\n\n\nb := a\na := `echo hello`\nbar:\n echo '{{`exit 200`}}'",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 200
|
2016-11-12 04:15:16 +03:00
|
|
|
|
|
|
|
|
10 | echo '{{`exit 200`}}'
|
|
|
|
| ^^^^^^^^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 200,
|
2016-11-12 04:15:16 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: shebang_backtick_failure,
|
|
|
|
justfile: "foo:
|
2016-10-30 11:27:05 +03:00
|
|
|
#!/bin/sh
|
|
|
|
echo hello
|
|
|
|
echo {{`exit 123`}}",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 123
|
2016-10-30 11:27:05 +03:00
|
|
|
|
|
|
|
|
4 | echo {{`exit 123`}}
|
|
|
|
| ^^^^^^^^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 123,
|
2016-10-30 11:27:05 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: command_backtick_failure,
|
|
|
|
justfile: "foo:
|
2016-10-30 11:27:05 +03:00
|
|
|
echo hello
|
|
|
|
echo {{`exit 123`}}",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "hello\n",
|
|
|
|
stderr: "echo hello\nerror: Backtick failed with exit code 123
|
2016-10-30 11:27:05 +03:00
|
|
|
|
|
|
|
|
3 | echo {{`exit 123`}}
|
|
|
|
| ^^^^^^^^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 123,
|
2016-10-30 11:27:05 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: assignment_backtick_failure,
|
|
|
|
justfile: "foo:
|
2016-10-30 11:27:05 +03:00
|
|
|
echo hello
|
|
|
|
echo {{`exit 111`}}
|
2019-04-18 21:48:02 +03:00
|
|
|
a := `exit 222`",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 222
|
2016-10-30 11:27:05 +03:00
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
4 | a := `exit 222`
|
|
|
|
| ^^^^^^^^^^
|
2016-10-30 11:27:05 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 222,
|
2016-10-30 11:27:05 +03:00
|
|
|
}
|
2016-10-30 13:08:28 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: unknown_override_options,
|
|
|
|
justfile: "foo:
|
2016-10-30 13:08:28 +03:00
|
|
|
echo hello
|
|
|
|
echo {{`exit 111`}}
|
2019-04-18 21:48:02 +03:00
|
|
|
a := `exit 222`",
|
2017-08-19 00:21:18 +03:00
|
|
|
args: ("--set", "foo", "bar", "--set", "baz", "bob", "--set", "a", "b", "a", "b"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Variables `baz` and `foo` overridden on the command line but not present \
|
2016-11-12 20:28:30 +03:00
|
|
|
in justfile\n",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2016-10-30 13:08:28 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: unknown_override_args,
|
|
|
|
justfile: "foo:
|
2016-10-30 13:08:28 +03:00
|
|
|
echo hello
|
|
|
|
echo {{`exit 111`}}
|
2019-04-18 21:48:02 +03:00
|
|
|
a := `exit 222`",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("foo=bar", "baz=bob", "a=b", "a", "b"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Variables `baz` and `foo` overridden on the command line but not present \
|
2016-11-12 20:28:30 +03:00
|
|
|
in justfile\n",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2016-11-12 01:33:17 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: unknown_override_arg,
|
|
|
|
justfile: "foo:
|
2016-11-12 01:33:17 +03:00
|
|
|
echo hello
|
|
|
|
echo {{`exit 111`}}
|
2019-04-18 21:48:02 +03:00
|
|
|
a := `exit 222`",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("foo=bar", "a=b", "a", "b"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Variable `foo` overridden on the command line but not present in justfile\n",
|
|
|
|
status: EXIT_FAILURE,
|
2016-10-30 13:08:28 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: overrides_first,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
foo := "foo"
|
|
|
|
a := "a"
|
|
|
|
baz := "baz"
|
2016-11-13 00:03:33 +03:00
|
|
|
|
2016-10-30 13:08:28 +03:00
|
|
|
recipe arg:
|
|
|
|
echo arg={{arg}}
|
|
|
|
echo {{foo + a + baz}}"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("foo=bar", "a=b", "recipe", "baz=bar"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "arg=baz=bar\nbarbbaz\n",
|
|
|
|
stderr: "echo arg=baz=bar\necho barbbaz\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-10-30 13:08:28 +03:00
|
|
|
}
|
2016-10-30 23:14:39 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: overrides_not_evaluated,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
foo := `exit 1`
|
|
|
|
a := "a"
|
|
|
|
baz := "baz"
|
2016-11-13 00:03:33 +03:00
|
|
|
|
|
|
|
recipe arg:
|
|
|
|
echo arg={{arg}}
|
|
|
|
echo {{foo + a + baz}}"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("foo=bar", "a=b", "recipe", "baz=bar"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "arg=baz=bar\nbarbbaz\n",
|
|
|
|
stderr: "echo arg=baz=bar\necho barbbaz\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-13 00:03:33 +03:00
|
|
|
}
|
2016-10-30 23:14:39 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: dry_run,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
var := `echo stderr 1>&2; echo backtick`
|
2016-10-30 23:14:39 +03:00
|
|
|
|
|
|
|
command:
|
|
|
|
@touch /this/is/not/a/file
|
|
|
|
{{var}}
|
|
|
|
echo {{`echo command interpolation`}}
|
|
|
|
|
|
|
|
shebang:
|
|
|
|
#!/bin/sh
|
|
|
|
touch /this/is/not/a/file
|
|
|
|
{{var}}
|
|
|
|
echo {{`echo shebang interpolation`}}"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--dry-run", "shebang", "command"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
2017-11-18 07:21:37 +03:00
|
|
|
stderr: "#!/bin/sh
|
2016-10-30 23:14:39 +03:00
|
|
|
touch /this/is/not/a/file
|
2017-11-18 07:21:37 +03:00
|
|
|
`echo stderr 1>&2; echo backtick`
|
|
|
|
echo `echo shebang interpolation`
|
2016-10-30 23:14:39 +03:00
|
|
|
touch /this/is/not/a/file
|
2017-11-18 07:21:37 +03:00
|
|
|
`echo stderr 1>&2; echo backtick`
|
|
|
|
echo `echo command interpolation`
|
2016-10-30 23:14:39 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_SUCCESS,
|
2016-10-30 23:14:39 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: evaluate,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
foo := "a\t"
|
|
|
|
hello := "c"
|
|
|
|
bar := "b\t"
|
|
|
|
ab := foo + bar + hello
|
2016-10-30 23:14:39 +03:00
|
|
|
|
|
|
|
wut:
|
|
|
|
touch /this/is/not/a/file
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--evaluate"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-18 21:48:02 +03:00
|
|
|
stdout: r#"ab := "a b c"
|
|
|
|
bar := "b "
|
|
|
|
foo := "a "
|
|
|
|
hello := "c"
|
2016-10-30 23:14:39 +03:00
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-10-30 23:14:39 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: export_success,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
export FOO := "a"
|
|
|
|
baz := "c"
|
|
|
|
export BAR := "b"
|
|
|
|
export ABC := FOO + BAR + baz
|
2016-10-31 02:15:18 +03:00
|
|
|
|
|
|
|
wut:
|
2017-04-23 02:39:13 +03:00
|
|
|
echo $FOO $BAR $ABC
|
2016-10-31 02:15:18 +03:00
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "a b abc\n",
|
2017-04-23 02:39:13 +03:00
|
|
|
stderr: "echo $FOO $BAR $ABC\n",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_SUCCESS,
|
2016-10-31 02:15:18 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: export_override,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
export FOO := "a"
|
|
|
|
baz := "c"
|
|
|
|
export BAR := "b"
|
|
|
|
export ABC := FOO + "-" + BAR + "-" + baz
|
2016-11-14 08:26:28 +03:00
|
|
|
|
|
|
|
wut:
|
2017-04-23 02:39:13 +03:00
|
|
|
echo $FOO $BAR $ABC
|
2016-11-14 08:26:28 +03:00
|
|
|
"#,
|
2017-08-19 00:21:18 +03:00
|
|
|
args: ("--set", "BAR", "bye", "FOO=hello"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "hello bye hello-bye-c\n",
|
2017-04-23 02:39:13 +03:00
|
|
|
stderr: "echo $FOO $BAR $ABC\n",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_SUCCESS,
|
2016-11-14 08:26:28 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: export_shebang,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
export FOO := "a"
|
|
|
|
baz := "c"
|
|
|
|
export BAR := "b"
|
|
|
|
export ABC := FOO + BAR + baz
|
2016-10-31 02:15:18 +03:00
|
|
|
|
|
|
|
wut:
|
|
|
|
#!/bin/sh
|
2017-04-23 02:39:13 +03:00
|
|
|
echo $FOO $BAR $ABC
|
2016-10-31 02:15:18 +03:00
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "a b abc\n",
|
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-10-31 02:15:18 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: export_recipe_backtick,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
export EXPORTED_VARIABLE := "A-IS-A"
|
2016-10-31 02:15:18 +03:00
|
|
|
|
|
|
|
recipe:
|
2017-04-23 02:39:13 +03:00
|
|
|
echo {{`echo recipe $EXPORTED_VARIABLE`}}
|
2016-10-31 02:15:18 +03:00
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "recipe A-IS-A\n",
|
|
|
|
stderr: "echo recipe A-IS-A\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-10-31 02:15:18 +03:00
|
|
|
}
|
2016-10-31 02:56:22 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: raw_string,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
export EXPORTED_VARIABLE := '\z'
|
2016-10-31 02:56:22 +03:00
|
|
|
|
|
|
|
recipe:
|
2017-04-23 02:15:15 +03:00
|
|
|
printf "$EXPORTED_VARIABLE"
|
2016-10-31 02:56:22 +03:00
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "\\z",
|
|
|
|
stderr: "printf \"$EXPORTED_VARIABLE\"\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-10-31 02:56:22 +03:00
|
|
|
}
|
2016-11-01 07:53:31 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: line_error_spacing,
|
|
|
|
justfile: r#"
|
2016-11-01 07:53:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
???
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Unknown start of token:
|
2016-11-01 07:53:31 +03:00
|
|
|
|
|
|
|
|
10 | ???
|
|
|
|
| ^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2016-11-01 07:53:31 +03:00
|
|
|
}
|
2016-11-05 11:01:43 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: quiet_flag_no_stdout,
|
|
|
|
justfile: r#"
|
2016-11-05 11:01:43 +03:00
|
|
|
default:
|
|
|
|
@echo hello
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--quiet"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-05 11:01:43 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: quiet_flag_no_stderr,
|
|
|
|
justfile: r#"
|
2016-11-05 11:01:43 +03:00
|
|
|
default:
|
|
|
|
@echo hello 1>&2
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--quiet"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-05 11:01:43 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: quiet_flag_no_command_echoing,
|
|
|
|
justfile: r#"
|
2016-11-05 11:01:43 +03:00
|
|
|
default:
|
|
|
|
exit
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--quiet"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-05 11:01:43 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: quiet_flag_no_error_messages,
|
|
|
|
justfile: r#"
|
2016-11-05 11:01:43 +03:00
|
|
|
default:
|
|
|
|
exit 100
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--quiet"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "",
|
|
|
|
status: 100,
|
2016-11-05 11:01:43 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: quiet_flag_no_assignment_backtick_stderr,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
a := `echo hello 1>&2`
|
2016-11-05 11:01:43 +03:00
|
|
|
default:
|
|
|
|
exit 100
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--quiet"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "",
|
|
|
|
status: 100,
|
2016-11-05 11:01:43 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: quiet_flag_no_interpolation_backtick_stderr,
|
|
|
|
justfile: r#"
|
2016-11-05 11:01:43 +03:00
|
|
|
default:
|
|
|
|
echo `echo hello 1>&2`
|
|
|
|
exit 100
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--quiet"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "",
|
|
|
|
status: 100,
|
2016-11-05 11:01:43 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: argument_single,
|
|
|
|
justfile: "
|
2016-11-12 00:34:28 +03:00
|
|
|
foo A:
|
|
|
|
echo {{A}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("foo", "ARGUMENT"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "ARGUMENT\n",
|
|
|
|
stderr: "echo ARGUMENT\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-12 00:34:28 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: argument_multiple,
|
|
|
|
justfile: "
|
2016-11-12 00:34:28 +03:00
|
|
|
foo A B:
|
|
|
|
echo A:{{A}} B:{{B}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("foo", "ONE", "TWO"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "A:ONE B:TWO\n",
|
|
|
|
stderr: "echo A:ONE B:TWO\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-12 00:34:28 +03:00
|
|
|
}
|
2016-11-12 01:33:17 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: argument_mismatch_more,
|
|
|
|
justfile: "
|
2016-11-12 01:33:17 +03:00
|
|
|
foo A B:
|
|
|
|
echo A:{{A}} B:{{B}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("foo", "ONE", "TWO", "THREE"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Justfile does not contain recipe `THREE`.\n",
|
|
|
|
status: EXIT_FAILURE,
|
2016-11-12 01:33:17 +03:00
|
|
|
}
|
2016-11-12 20:15:13 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: argument_mismatch_fewer,
|
|
|
|
justfile: "
|
2016-11-12 01:33:17 +03:00
|
|
|
foo A B:
|
|
|
|
echo A:{{A}} B:{{B}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("foo", "ONE"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
2018-11-04 00:51:06 +03:00
|
|
|
stderr: "error: Recipe `foo` got 1 argument but takes 2\nusage:\n just foo A B\n",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2016-11-12 01:33:17 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: argument_mismatch_more_with_default,
|
|
|
|
justfile: "
|
2016-11-12 20:15:13 +03:00
|
|
|
foo A B='B':
|
|
|
|
echo A:{{A}} B:{{B}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("foo", "ONE", "TWO", "THREE"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Justfile does not contain recipe `THREE`.\n",
|
|
|
|
status: EXIT_FAILURE,
|
2016-11-12 20:15:13 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: argument_mismatch_fewer_with_default,
|
|
|
|
justfile: "
|
2016-11-12 20:15:13 +03:00
|
|
|
foo A B C='C':
|
|
|
|
echo A:{{A}} B:{{B}} C:{{C}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("foo", "bar"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
2018-11-04 00:51:06 +03:00
|
|
|
stderr: "error: Recipe `foo` got 1 argument but takes at least 2\nusage:\n just foo A B C='C'\n",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: unknown_recipe,
|
|
|
|
justfile: "hello:",
|
|
|
|
args: ("foo"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Justfile does not contain recipe `foo`.\n",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: unknown_recipes,
|
|
|
|
justfile: "hello:",
|
|
|
|
args: ("foo", "bar"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Justfile does not contain recipes `foo` or `bar`.\n",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: color_always,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "b := a\na := `exit 100`\nbar:\n echo '{{`exit 200`}}'",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--color", "always"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "\u{1b}[1;31merror:\u{1b}[0m \u{1b}[1mBacktick failed with exit code 100
|
2019-04-18 21:48:02 +03:00
|
|
|
\u{1b}[0m |\n2 | a := `exit 100`\n | \u{1b}[1;31m^^^^^^^^^^\u{1b}[0m\n",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 100,
|
2016-11-08 08:01:27 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: color_never,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "b := a\na := `exit 100`\nbar:\n echo '{{`exit 200`}}'",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--color", "never"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 100
|
2016-11-12 05:46:04 +03:00
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
2 | a := `exit 100`
|
|
|
|
| ^^^^^^^^^^
|
2016-11-12 05:46:04 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 100,
|
2016-11-12 05:46:04 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: color_auto,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "b := a\na := `exit 100`\nbar:\n echo '{{`exit 200`}}'",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--color", "auto"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Backtick failed with exit code 100
|
2016-11-12 05:46:04 +03:00
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
2 | a := `exit 100`
|
|
|
|
| ^^^^^^^^^^
|
2016-11-12 05:46:04 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 100,
|
2016-11-12 05:46:04 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: colors_no_context,
|
|
|
|
justfile: "
|
2016-11-08 08:01:27 +03:00
|
|
|
recipe:
|
2017-04-23 02:15:15 +03:00
|
|
|
@exit 100",
|
|
|
|
args: ("--color=always"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "\u{1b}[1;31merror:\u{1b}[0m \u{1b}[1m\
|
2016-11-17 09:18:55 +03:00
|
|
|
Recipe `recipe` failed on line 3 with exit code 100\u{1b}[0m\n",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: 100,
|
2016-11-12 01:33:17 +03:00
|
|
|
}
|
2016-11-08 08:01:27 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: dump,
|
|
|
|
justfile: r#"
|
2016-11-13 10:31:19 +03:00
|
|
|
# this recipe does something
|
2016-11-18 18:03:34 +03:00
|
|
|
recipe a b +d:
|
2017-04-23 02:15:15 +03:00
|
|
|
@exit 100"#,
|
|
|
|
args: ("--dump"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "# this recipe does something
|
2016-11-18 18:03:34 +03:00
|
|
|
recipe a b +d:
|
2016-11-12 07:25:37 +03:00
|
|
|
@exit 100
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: mixed_whitespace,
|
|
|
|
justfile: "bar:\n\t echo hello",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Found a mix of tabs and spaces in leading whitespace: `␉␠`
|
2017-01-09 06:01:48 +03:00
|
|
|
Leading whitespace may consist of tabs or spaces, but not both
|
|
|
|
|
|
|
|
|
2 | echo hello
|
2019-04-16 08:40:02 +03:00
|
|
|
| ^^^^^
|
2017-01-09 06:01:48 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: extra_leading_whitespace,
|
|
|
|
justfile: "bar:\n\t\techo hello\n\t\t\techo goodbye",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Recipe line has extra leading whitespace
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
|
|
|
3 | echo goodbye
|
|
|
|
| ^^^^^^^^^^^^^^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: inconsistent_leading_whitespace,
|
|
|
|
justfile: "bar:\n\t\techo hello\n\t echo goodbye",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
2017-05-13 05:09:47 +03:00
|
|
|
stderr: "error: Recipe line has inconsistent leading whitespace. \
|
|
|
|
Recipe started with `␉␉` but found line with `␉␠`
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
|
|
|
3 | echo goodbye
|
2019-04-16 08:40:02 +03:00
|
|
|
| ^^^^^
|
2017-01-09 06:01:48 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: required_after_default,
|
|
|
|
justfile: "bar:\nhello baz arg='foo' bar:",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Non-default parameter `bar` follows default parameter
|
2016-11-12 20:15:13 +03:00
|
|
|
|
|
|
|
|
2 | hello baz arg='foo' bar:
|
|
|
|
| ^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2016-11-12 20:15:13 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: required_after_variadic,
|
|
|
|
justfile: "bar:\nhello baz +arg bar:",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Parameter `bar` follows variadic parameter
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
|
|
|
2 | hello baz +arg bar:
|
|
|
|
| ^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: use_string_default,
|
|
|
|
justfile: r#"
|
2016-11-12 20:15:13 +03:00
|
|
|
bar:
|
|
|
|
hello baz arg="XYZ\t\" ":
|
|
|
|
echo '{{baz}}...{{arg}}'
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("hello", "ABC"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "ABC...XYZ\t\"\t\n",
|
|
|
|
stderr: "echo 'ABC...XYZ\t\"\t'\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-12 20:15:13 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: use_raw_string_default,
|
|
|
|
justfile: r#"
|
2016-11-12 20:15:13 +03:00
|
|
|
bar:
|
2018-08-04 05:53:06 +03:00
|
|
|
hello baz arg='XYZ" ':
|
2017-04-23 02:15:15 +03:00
|
|
|
printf '{{baz}}...{{arg}}'
|
2016-11-12 20:15:13 +03:00
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("hello", "ABC"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2018-08-04 05:53:06 +03:00
|
|
|
stdout: "ABC...XYZ\"\t",
|
|
|
|
stderr: "printf 'ABC...XYZ\"\t'\n",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_SUCCESS,
|
2016-11-12 20:15:13 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: supply_use_default,
|
|
|
|
justfile: r#"
|
2016-11-12 20:15:13 +03:00
|
|
|
hello a b='B' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("hello", "0", "1"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "0 1 C\n",
|
|
|
|
stderr: "echo 0 1 C\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-12 20:15:13 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: supply_defaults,
|
|
|
|
justfile: r#"
|
2016-11-12 20:15:13 +03:00
|
|
|
hello a b='B' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("hello", "0", "1", "2"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "0 1 2\n",
|
|
|
|
stderr: "echo 0 1 2\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-12 20:15:13 +03:00
|
|
|
}
|
2016-11-12 22:40:52 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: list,
|
|
|
|
justfile: r#"
|
2016-11-13 10:31:19 +03:00
|
|
|
|
|
|
|
# this does a thing
|
2016-11-12 22:40:52 +03:00
|
|
|
hello a b='B ' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
|
2016-11-13 10:31:19 +03:00
|
|
|
# this comment will be ignored
|
|
|
|
|
2016-11-12 22:40:52 +03:00
|
|
|
a Z="\t z":
|
2017-10-07 09:48:07 +03:00
|
|
|
|
|
|
|
# this recipe will not appear
|
|
|
|
_private-recipe:
|
2016-11-12 22:40:52 +03:00
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--list"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-12 09:58:08 +03:00
|
|
|
stdout: r#"Available recipes:
|
|
|
|
a Z="\t z"
|
|
|
|
hello a b='B ' c='C' # this does a thing
|
|
|
|
"#,
|
2017-12-01 02:03:59 +03:00
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: list_alignment,
|
|
|
|
justfile: r#"
|
|
|
|
|
|
|
|
# this does a thing
|
|
|
|
hello a b='B ' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
|
|
|
|
# something else
|
|
|
|
a Z="\t z":
|
|
|
|
|
|
|
|
# this recipe will not appear
|
|
|
|
_private-recipe:
|
|
|
|
"#,
|
|
|
|
args: ("--list"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-12 09:58:08 +03:00
|
|
|
stdout: r#"Available recipes:
|
|
|
|
a Z="\t z" # something else
|
|
|
|
hello a b='B ' c='C' # this does a thing
|
|
|
|
"#,
|
2017-12-01 02:03:59 +03:00
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: list_alignment_long,
|
|
|
|
justfile: r#"
|
|
|
|
|
|
|
|
# this does a thing
|
|
|
|
hello a b='B ' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
|
|
|
|
# this does another thing
|
|
|
|
x a b='B ' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
|
|
|
|
# something else
|
|
|
|
this-recipe-is-very-very-very-important Z="\t z":
|
|
|
|
|
|
|
|
# this recipe will not appear
|
|
|
|
_private-recipe:
|
|
|
|
"#,
|
|
|
|
args: ("--list"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-12 09:58:08 +03:00
|
|
|
stdout: r#"Available recipes:
|
|
|
|
hello a b='B ' c='C' # this does a thing
|
|
|
|
this-recipe-is-very-very-very-important Z="\t z" # something else
|
|
|
|
x a b='B ' c='C' # this does another thing
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-12 22:40:52 +03:00
|
|
|
}
|
2016-11-12 23:36:12 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: show_suggestion,
|
|
|
|
justfile: r#"
|
2016-11-12 23:36:12 +03:00
|
|
|
hello a b='B ' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
|
|
|
|
a Z="\t z":
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--show", "hell"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "Justfile does not contain recipe `hell`.\nDid you mean `hello`?\n",
|
|
|
|
status: EXIT_FAILURE,
|
2016-11-12 23:36:12 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: show_no_suggestion,
|
|
|
|
justfile: r#"
|
2016-11-12 23:36:12 +03:00
|
|
|
helloooooo a b='B ' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
|
|
|
|
a Z="\t z":
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("--show", "hell"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "Justfile does not contain recipe `hell`.\n",
|
|
|
|
status: EXIT_FAILURE,
|
2016-11-12 23:36:12 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: run_suggestion,
|
|
|
|
justfile: r#"
|
2016-11-12 23:36:12 +03:00
|
|
|
hello a b='B ' c='C':
|
|
|
|
echo {{a}} {{b}} {{c}}
|
|
|
|
|
|
|
|
a Z="\t z":
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("hell"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Justfile does not contain recipe `hell`.\nDid you mean `hello`?\n",
|
|
|
|
status: EXIT_FAILURE,
|
2016-11-12 23:36:12 +03:00
|
|
|
}
|
2016-11-13 02:45:12 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: line_continuation_with_space,
|
|
|
|
justfile: r#"
|
2016-11-13 02:45:12 +03:00
|
|
|
foo:
|
|
|
|
echo a\
|
|
|
|
b \
|
|
|
|
c
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "a b c\n",
|
|
|
|
stderr: "echo a b c\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-13 02:45:12 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: line_continuation_with_quoted_space,
|
|
|
|
justfile: r#"
|
2016-11-13 02:45:12 +03:00
|
|
|
foo:
|
|
|
|
echo 'a\
|
|
|
|
b \
|
|
|
|
c'
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "a b c\n",
|
|
|
|
stderr: "echo 'a b c'\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-13 02:45:12 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: line_continuation_no_space,
|
|
|
|
justfile: r#"
|
2016-11-13 02:45:12 +03:00
|
|
|
foo:
|
|
|
|
echo a\
|
|
|
|
b\
|
|
|
|
c
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "abc\n",
|
|
|
|
stderr: "echo abc\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-13 02:45:12 +03:00
|
|
|
}
|
2016-11-13 03:12:00 +03:00
|
|
|
|
2017-12-02 16:37:10 +03:00
|
|
|
integration_test! {
|
|
|
|
name: test_os_arch_functions_in_interpolation,
|
|
|
|
justfile: r#"
|
|
|
|
foo:
|
|
|
|
echo {{arch()}} {{os()}} {{os_family()}}
|
|
|
|
"#,
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-12-02 16:37:10 +03:00
|
|
|
stdout: format!("{} {} {}\n", target::arch(), target::os(), target::os_family()).as_str(),
|
|
|
|
stderr: format!("echo {} {} {}\n", target::arch(), target::os(), target::os_family()).as_str(),
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: test_os_arch_functions_in_expression,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
a := arch()
|
|
|
|
o := os()
|
|
|
|
f := os_family()
|
2017-12-02 16:37:10 +03:00
|
|
|
|
|
|
|
foo:
|
|
|
|
echo {{a}} {{o}} {{f}}
|
|
|
|
"#,
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-12-02 16:37:10 +03:00
|
|
|
stdout: format!("{} {} {}\n", target::arch(), target::os(), target::os_family()).as_str(),
|
|
|
|
stderr: format!("echo {} {} {}\n", target::arch(), target::os(), target::os_family()).as_str(),
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
2018-08-04 05:53:06 +03:00
|
|
|
#[cfg(not(windows))]
|
2017-12-03 01:59:07 +03:00
|
|
|
integration_test! {
|
|
|
|
name: env_var_functions,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
p := env_var('USER')
|
|
|
|
b := env_var_or_default('ZADDY', 'HTAP')
|
|
|
|
x := env_var_or_default('XYZ', 'ABC')
|
2017-12-03 01:59:07 +03:00
|
|
|
|
|
|
|
foo:
|
|
|
|
/bin/echo '{{p}}' '{{b}}' '{{x}}'
|
|
|
|
"#,
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2018-08-04 05:53:06 +03:00
|
|
|
stdout: format!("{} HTAP ABC\n", env::var("USER").unwrap()).as_str(),
|
|
|
|
stderr: format!("/bin/echo '{}' 'HTAP' 'ABC'\n", env::var("USER").unwrap()).as_str(),
|
2017-12-03 01:59:07 +03:00
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
2018-08-04 05:53:06 +03:00
|
|
|
#[cfg(windows)]
|
|
|
|
integration_test! {
|
|
|
|
name: env_var_functions,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
p := env_var('USERNAME')
|
|
|
|
b := env_var_or_default('ZADDY', 'HTAP')
|
|
|
|
x := env_var_or_default('XYZ', 'ABC')
|
2018-08-04 05:53:06 +03:00
|
|
|
|
|
|
|
foo:
|
|
|
|
/bin/echo '{{p}}' '{{b}}' '{{x}}'
|
|
|
|
"#,
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2018-08-04 05:53:06 +03:00
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
2017-12-03 01:59:07 +03:00
|
|
|
integration_test! {
|
|
|
|
name: env_var_failure,
|
|
|
|
justfile: "a:\n echo {{env_var('ZADDY')}}",
|
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-12-03 01:59:07 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Call to function `env_var` failed: environment variable `ZADDY` not present
|
|
|
|
|
|
|
|
|
2 | echo {{env_var('ZADDY')}}
|
|
|
|
| ^^^^^^^
|
|
|
|
",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
2017-12-02 16:37:10 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: quiet_recipe,
|
|
|
|
justfile: r#"
|
2016-11-13 03:12:00 +03:00
|
|
|
@quiet:
|
|
|
|
# a
|
|
|
|
# b
|
|
|
|
@echo c
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "c\n",
|
|
|
|
stderr: "echo c\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-13 03:12:00 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: quiet_shebang_recipe,
|
|
|
|
justfile: r#"
|
2016-11-13 03:12:00 +03:00
|
|
|
@quiet:
|
|
|
|
#!/bin/sh
|
|
|
|
echo hello
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "hello\n",
|
|
|
|
stderr: "#!/bin/sh\necho hello\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-13 03:12:00 +03:00
|
|
|
}
|
2016-11-13 11:01:42 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: shebang_line_numbers,
|
|
|
|
justfile: r#"
|
2016-11-17 08:37:43 +03:00
|
|
|
quiet:
|
|
|
|
#!/usr/bin/env cat
|
|
|
|
|
|
|
|
a
|
|
|
|
|
|
|
|
b
|
|
|
|
|
|
|
|
|
|
|
|
c
|
|
|
|
|
|
|
|
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "#!/usr/bin/env cat
|
2016-11-17 08:37:43 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
a
|
|
|
|
|
|
|
|
b
|
|
|
|
|
|
|
|
|
|
|
|
c
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-17 08:37:43 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: complex_dependencies,
|
|
|
|
justfile: r#"
|
2016-11-13 11:01:42 +03:00
|
|
|
a: b
|
|
|
|
b:
|
|
|
|
c: b a
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("b"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: parameter_shadows_variable,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "FOO := 'hello'\na FOO:",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Parameter `FOO` shadows variable of the same name
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
|
|
|
2 | a FOO:
|
|
|
|
| ^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-12-02 16:37:10 +03:00
|
|
|
integration_test! {
|
|
|
|
name: unknown_function_in_assignment,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: r#"foo := foo() + "hello"
|
2017-12-02 16:37:10 +03:00
|
|
|
bar:"#,
|
|
|
|
args: ("bar"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-12-02 16:37:10 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: r#"error: Call to unknown function `foo`
|
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
1 | foo := foo() + "hello"
|
|
|
|
| ^^^
|
2017-12-02 16:37:10 +03:00
|
|
|
"#,
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
2017-01-09 06:01:48 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: dependency_takes_arguments,
|
|
|
|
justfile: "b: a\na FOO:",
|
|
|
|
args: ("b"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
2017-05-13 05:09:47 +03:00
|
|
|
stderr: "error: Recipe `b` depends on `a` which requires arguments. \
|
|
|
|
Dependencies may not require arguments
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
|
|
|
1 | b: a
|
|
|
|
| ^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: duplicate_parameter,
|
|
|
|
justfile: "a foo foo:",
|
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Recipe `a` has duplicate parameter `foo`
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
|
|
|
1 | a foo foo:
|
|
|
|
| ^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: duplicate_dependency,
|
|
|
|
justfile: "b:\na: b b",
|
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Recipe `a` has duplicate dependency `b`
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
|
|
|
2 | a: b b
|
|
|
|
| ^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: duplicate_recipe,
|
|
|
|
justfile: "b:\nb:",
|
|
|
|
args: ("b"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Recipe `b` first defined on line 1 is redefined on line 2
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
|
|
|
2 | b:
|
|
|
|
| ^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: duplicate_variable,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "a := 'hello'\na := 'hello'\nfoo:",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("foo"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Variable `a` has multiple definitions
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
2 | a := 'hello'
|
2017-01-09 06:01:48 +03:00
|
|
|
| ^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
2017-11-15 00:03:26 +03:00
|
|
|
name: unexpected_token_in_dependency_position,
|
2017-04-23 02:15:15 +03:00
|
|
|
justfile: "foo: 'bar'",
|
|
|
|
args: ("foo"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Expected name, end of line, or end of file, but found raw string
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
|
|
|
1 | foo: 'bar'
|
|
|
|
| ^^^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-11-15 00:03:26 +03:00
|
|
|
integration_test! {
|
|
|
|
name: unexpected_token_after_name,
|
|
|
|
justfile: "foo 'bar'",
|
|
|
|
args: ("foo"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-11-15 00:03:26 +03:00
|
|
|
stdout: "",
|
2019-04-18 21:48:02 +03:00
|
|
|
stderr: "error: Expected name, '+', ':', or ':=', but found raw string
|
2017-11-15 00:03:26 +03:00
|
|
|
|
|
|
|
|
1 | foo 'bar'
|
|
|
|
| ^^^^^
|
|
|
|
",
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
2017-01-09 06:01:48 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: self_dependency,
|
|
|
|
justfile: "a: a",
|
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Recipe `a` depends on itself
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
|
|
|
1 | a: a
|
|
|
|
| ^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: long_circular_recipe_dependency,
|
|
|
|
justfile: "a: b\nb: c\nc: d\nd: a",
|
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Recipe `d` has circular dependency `a -> b -> c -> d -> a`
|
2016-11-13 11:01:42 +03:00
|
|
|
|
|
|
|
|
4 | d: a
|
|
|
|
| ^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2016-11-13 11:01:42 +03:00
|
|
|
}
|
2016-11-14 01:04:20 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: variable_self_dependency,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "z := z\na:",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Variable `z` is defined in terms of itself
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
1 | z := z
|
2017-01-09 06:01:48 +03:00
|
|
|
| ^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: variable_circular_dependency,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: "x := y\ny := z\nz := x\na:",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Variable `x` depends on its own value: `x -> y -> z -> x`
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
1 | x := y
|
2017-01-09 06:01:48 +03:00
|
|
|
| ^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: invalid_escape_sequence,
|
2019-04-18 21:48:02 +03:00
|
|
|
justfile: r#"x := "\q"
|
2017-01-09 06:01:48 +03:00
|
|
|
a:"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: `\\q` is not a valid escape sequence
|
2017-01-09 06:01:48 +03:00
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
1 | x := \"\\q\"
|
|
|
|
| ^^^^
|
2017-01-09 06:01:48 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-09 06:01:48 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: multiline_raw_string,
|
|
|
|
justfile: "
|
2019-04-18 21:48:02 +03:00
|
|
|
string := 'hello
|
2016-11-14 01:04:20 +03:00
|
|
|
whatever'
|
|
|
|
|
|
|
|
a:
|
|
|
|
echo '{{string}}'
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "hello
|
2016-11-14 01:04:20 +03:00
|
|
|
whatever
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
stderr: "echo 'hello
|
2016-11-14 01:04:20 +03:00
|
|
|
whatever'
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_SUCCESS,
|
2016-11-14 01:04:20 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: error_line_after_multiline_raw_string,
|
|
|
|
justfile: "
|
2019-04-18 21:48:02 +03:00
|
|
|
string := 'hello
|
2016-11-14 01:04:20 +03:00
|
|
|
|
|
|
|
whatever' + 'yo'
|
|
|
|
|
|
|
|
a:
|
|
|
|
echo '{{foo}}'
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Variable `foo` not defined
|
2016-11-14 01:04:20 +03:00
|
|
|
|
|
|
|
|
7 | echo '{{foo}}'
|
|
|
|
| ^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2016-11-14 01:04:20 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: error_column_after_multiline_raw_string,
|
|
|
|
justfile: "
|
2019-04-18 21:48:02 +03:00
|
|
|
string := 'hello
|
2016-11-14 01:04:20 +03:00
|
|
|
|
|
|
|
whatever' + bar
|
|
|
|
|
|
|
|
a:
|
|
|
|
echo '{{string}}'
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Variable `bar` not defined
|
2016-11-14 01:04:20 +03:00
|
|
|
|
|
|
|
|
4 | whatever' + bar
|
|
|
|
| ^^^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2016-11-14 01:04:20 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: multiline_raw_string_in_interpolation,
|
|
|
|
justfile: r#"
|
2016-11-14 01:04:20 +03:00
|
|
|
a:
|
|
|
|
echo '{{"a" + '
|
|
|
|
' + "b"}}'
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "a
|
2016-11-14 01:04:20 +03:00
|
|
|
b
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
stderr: "echo 'a
|
2016-11-14 01:04:20 +03:00
|
|
|
b'
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_SUCCESS,
|
2016-11-14 01:04:20 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: error_line_after_multiline_raw_string_in_interpolation,
|
|
|
|
justfile: r#"
|
2016-11-14 01:04:20 +03:00
|
|
|
a:
|
|
|
|
echo '{{"a" + '
|
|
|
|
' + "b"}}'
|
|
|
|
|
|
|
|
echo {{b}}
|
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Variable `b` not defined
|
2016-11-14 01:04:20 +03:00
|
|
|
|
|
|
|
|
6 | echo {{b}}
|
|
|
|
| ^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2016-11-14 01:04:20 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: unterminated_raw_string,
|
|
|
|
justfile: "
|
2019-04-16 08:40:02 +03:00
|
|
|
a b= ':
|
2016-11-14 01:04:20 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Unterminated string
|
2016-11-14 01:04:20 +03:00
|
|
|
|
|
2019-04-16 08:40:02 +03:00
|
|
|
2 | a b= ':
|
|
|
|
| ^
|
2016-11-14 01:04:20 +03:00
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2016-11-14 01:04:20 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: unterminated_string,
|
|
|
|
justfile: r#"
|
2019-04-16 08:40:02 +03:00
|
|
|
a b= ":
|
2016-11-14 01:04:20 +03:00
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: r#"error: Unterminated string
|
2016-11-14 01:04:20 +03:00
|
|
|
|
|
2019-04-16 08:40:02 +03:00
|
|
|
2 | a b= ":
|
|
|
|
| ^
|
2016-11-14 01:04:20 +03:00
|
|
|
"#,
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2016-11-14 01:04:20 +03:00
|
|
|
}
|
2016-11-18 18:03:34 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: variadic_recipe,
|
|
|
|
justfile: "
|
2016-11-18 18:03:34 +03:00
|
|
|
a x y +z:
|
|
|
|
echo {{x}} {{y}} {{z}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a", "0", "1", "2", "3", " 4 "),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "0 1 2 3 4\n",
|
|
|
|
stderr: "echo 0 1 2 3 4 \n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-18 18:03:34 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: variadic_ignore_default,
|
|
|
|
justfile: "
|
2016-11-18 18:03:34 +03:00
|
|
|
a x y +z='HELLO':
|
|
|
|
echo {{x}} {{y}} {{z}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a", "0", "1", "2", "3", " 4 "),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "0 1 2 3 4\n",
|
|
|
|
stderr: "echo 0 1 2 3 4 \n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-18 18:03:34 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: variadic_use_default,
|
|
|
|
justfile: "
|
2016-11-18 18:03:34 +03:00
|
|
|
a x y +z='HELLO':
|
|
|
|
echo {{x}} {{y}} {{z}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a", "0", "1"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "0 1 HELLO\n",
|
|
|
|
stderr: "echo 0 1 HELLO\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-11-18 18:03:34 +03:00
|
|
|
}
|
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: variadic_too_few,
|
|
|
|
justfile: "
|
2016-11-18 18:03:34 +03:00
|
|
|
a x y +z:
|
|
|
|
echo {{x}} {{y}} {{z}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("a", "0", "1"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
2018-11-04 00:51:06 +03:00
|
|
|
stderr: "error: Recipe `a` got 2 arguments but takes at least 3\nusage:\n just a x y +z\n",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2016-11-18 18:03:34 +03:00
|
|
|
}
|
2016-12-11 03:35:52 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: argument_grouping,
|
|
|
|
justfile: "
|
2016-12-11 03:35:52 +03:00
|
|
|
FOO A B='blarg':
|
|
|
|
echo foo: {{A}} {{B}}
|
|
|
|
|
|
|
|
BAR X:
|
|
|
|
echo bar: {{X}}
|
|
|
|
|
|
|
|
BAZ +Z:
|
|
|
|
echo baz: {{Z}}
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: ("BAR", "0", "FOO", "1", "2", "BAZ", "3", "4", "5"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "bar: 0\nfoo: 1 2\nbaz: 3 4 5\n",
|
|
|
|
stderr: "echo bar: 0\necho foo: 1 2\necho baz: 3 4 5\n",
|
|
|
|
status: EXIT_SUCCESS,
|
2016-12-11 03:35:52 +03:00
|
|
|
}
|
2017-01-19 07:32:55 +03:00
|
|
|
|
2017-04-23 02:15:15 +03:00
|
|
|
integration_test! {
|
|
|
|
name: missing_second_dependency,
|
|
|
|
justfile: "
|
2017-01-19 07:32:55 +03:00
|
|
|
x:
|
|
|
|
|
|
|
|
a: x y
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-04-23 02:15:15 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: "error: Recipe `a` has unknown dependency `y`
|
2017-01-19 07:32:55 +03:00
|
|
|
|
|
|
|
|
4 | a: x y
|
|
|
|
| ^
|
|
|
|
",
|
2017-04-23 02:15:15 +03:00
|
|
|
status: EXIT_FAILURE,
|
2017-01-19 07:32:55 +03:00
|
|
|
}
|
2017-06-02 04:01:35 +03:00
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: list_colors,
|
|
|
|
justfile: "
|
|
|
|
# comment
|
|
|
|
a B C +D='hello':
|
|
|
|
echo {{B}} {{C}} {{D}}
|
|
|
|
",
|
|
|
|
args: ("--color", "always", "--list"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-06-04 08:46:07 +03:00
|
|
|
stdout: "Available recipes:\n a \
|
|
|
|
\u{1b}[36mB\u{1b}[0m \u{1b}[36mC\u{1b}[0m \u{1b}[35m+\
|
2019-04-12 09:58:08 +03:00
|
|
|
\u{1b}[0m\u{1b}[36mD\u{1b}[0m=\u{1b}[32m'hello'\u{1b}[0m \
|
|
|
|
\u{1b}[34m#\u{1b}[0m \u{1b}[34mcomment\u{1b}[0m\n",
|
2017-06-02 04:01:35 +03:00
|
|
|
stderr: "",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: run_colors,
|
|
|
|
justfile: "
|
|
|
|
# comment
|
|
|
|
a:
|
|
|
|
echo hi
|
|
|
|
",
|
|
|
|
args: ("--color", "always", "--highlight", "--verbose"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-06-02 04:01:35 +03:00
|
|
|
stdout: "hi\n",
|
|
|
|
stderr: "\u{1b}[1;36m===> Running recipe `a`...\u{1b}[0m\n\u{1b}[1mecho hi\u{1b}[0m\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
2017-08-19 00:21:18 +03:00
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: trailing_flags,
|
|
|
|
justfile: "
|
|
|
|
echo A B C:
|
|
|
|
echo {{A}} {{B}} {{C}}
|
|
|
|
",
|
|
|
|
args: ("echo", "--some", "--awesome", "--flags"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-08-19 00:21:18 +03:00
|
|
|
stdout: "--some --awesome --flags\n",
|
|
|
|
stderr: "echo --some --awesome --flags\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
2017-11-15 23:53:01 +03:00
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: comment_before_variable,
|
|
|
|
justfile: "
|
|
|
|
#
|
2019-04-18 21:48:02 +03:00
|
|
|
A:='1'
|
2017-11-15 23:53:01 +03:00
|
|
|
echo:
|
|
|
|
echo {{A}}
|
|
|
|
",
|
|
|
|
args: ("echo"),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2017-11-15 23:53:01 +03:00
|
|
|
stdout: "1\n",
|
|
|
|
stderr: "echo 1\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
2018-03-06 00:21:35 +03:00
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: dotenv_variable_in_recipe,
|
|
|
|
justfile: "
|
|
|
|
#
|
|
|
|
echo:
|
|
|
|
echo $DOTENV_KEY
|
|
|
|
",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2018-03-06 00:21:35 +03:00
|
|
|
stdout: "dotenv-value\n",
|
|
|
|
stderr: "echo $DOTENV_KEY\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: dotenv_variable_in_backtick,
|
|
|
|
justfile: "
|
|
|
|
#
|
2019-04-18 21:48:02 +03:00
|
|
|
X:=`echo $DOTENV_KEY`
|
2018-03-06 00:21:35 +03:00
|
|
|
echo:
|
|
|
|
echo {{X}}
|
|
|
|
",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2018-03-06 00:21:35 +03:00
|
|
|
stdout: "dotenv-value\n",
|
|
|
|
stderr: "echo dotenv-value\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
2018-03-17 19:17:41 +03:00
|
|
|
integration_test! {
|
|
|
|
name: dotenv_variable_in_function_in_recipe,
|
|
|
|
justfile: "
|
|
|
|
#
|
|
|
|
echo:
|
|
|
|
echo {{env_var_or_default('DOTENV_KEY', 'foo')}}
|
|
|
|
echo {{env_var('DOTENV_KEY')}}
|
|
|
|
",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2018-03-17 19:17:41 +03:00
|
|
|
stdout: "dotenv-value\ndotenv-value\n",
|
|
|
|
stderr: "echo dotenv-value\necho dotenv-value\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: dotenv_variable_in_function_in_backtick,
|
|
|
|
justfile: "
|
|
|
|
#
|
2019-04-18 21:48:02 +03:00
|
|
|
X:=env_var_or_default('DOTENV_KEY', 'foo')
|
|
|
|
Y:=env_var('DOTENV_KEY')
|
2018-03-17 19:17:41 +03:00
|
|
|
echo:
|
|
|
|
echo {{X}}
|
|
|
|
echo {{Y}}
|
|
|
|
",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2018-03-17 19:17:41 +03:00
|
|
|
stdout: "dotenv-value\ndotenv-value\n",
|
|
|
|
stderr: "echo dotenv-value\necho dotenv-value\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
2018-07-01 05:19:13 +03:00
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: invalid_escape_sequence_message,
|
|
|
|
justfile: r#"
|
2019-04-18 21:48:02 +03:00
|
|
|
X := "\'"
|
2018-07-01 05:19:13 +03:00
|
|
|
"#,
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2018-07-01 05:19:13 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: r#"error: `\'` is not a valid escape sequence
|
|
|
|
|
|
2019-04-18 21:48:02 +03:00
|
|
|
2 | X := "\'"
|
|
|
|
| ^^^^
|
2018-07-01 05:19:13 +03:00
|
|
|
"#,
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
2019-04-12 09:58:08 +03:00
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: unknown_variable_in_default,
|
|
|
|
justfile: "
|
|
|
|
foo x=bar:
|
|
|
|
",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-12 09:58:08 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: r#"error: Variable `bar` not defined
|
|
|
|
|
|
|
|
|
2 | foo x=bar:
|
|
|
|
| ^^^
|
|
|
|
"#,
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: unknown_function_in_default,
|
|
|
|
justfile: "
|
|
|
|
foo x=bar():
|
|
|
|
",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-12 09:58:08 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: r#"error: Call to unknown function `bar`
|
|
|
|
|
|
|
|
|
2 | foo x=bar():
|
|
|
|
| ^^^
|
|
|
|
"#,
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: default_string,
|
|
|
|
justfile: "
|
|
|
|
foo x='bar':
|
|
|
|
echo {{x}}
|
|
|
|
",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-12 09:58:08 +03:00
|
|
|
stdout: "bar\n",
|
|
|
|
stderr: "echo bar\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: default_concatination,
|
|
|
|
justfile: "
|
|
|
|
foo x=(`echo foo` + 'bar'):
|
|
|
|
echo {{x}}
|
|
|
|
",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-12 09:58:08 +03:00
|
|
|
stdout: "foobar\n",
|
|
|
|
stderr: "echo foobar\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: default_backtick,
|
|
|
|
justfile: "
|
|
|
|
foo x=`echo foo`:
|
|
|
|
echo {{x}}
|
|
|
|
",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-12 09:58:08 +03:00
|
|
|
stdout: "foo\n",
|
|
|
|
stderr: "echo foo\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: default_variable,
|
|
|
|
justfile: "
|
2019-04-18 21:48:02 +03:00
|
|
|
y := 'foo'
|
2019-04-12 09:58:08 +03:00
|
|
|
foo x=y:
|
|
|
|
echo {{x}}
|
|
|
|
",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-12 09:58:08 +03:00
|
|
|
stdout: "foo\n",
|
|
|
|
stderr: "echo foo\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: test_os_arch_functions_in_default,
|
|
|
|
justfile: r#"
|
|
|
|
foo a=arch() o=os() f=os_family():
|
|
|
|
echo {{a}} {{o}} {{f}}
|
|
|
|
"#,
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-12 09:58:08 +03:00
|
|
|
stdout: format!("{} {} {}\n", target::arch(), target::os(), target::os_family()).as_str(),
|
|
|
|
stderr: format!("echo {} {} {}\n", target::arch(), target::os(), target::os_family()).as_str(),
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
2019-04-16 08:40:02 +03:00
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: unterminated_interpolation_eol,
|
|
|
|
justfile: "
|
|
|
|
foo:
|
|
|
|
echo {{
|
|
|
|
",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-16 08:40:02 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: r#"error: Unterminated interpolation
|
|
|
|
|
|
|
|
|
3 | echo {{
|
|
|
|
| ^^
|
|
|
|
"#,
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: unterminated_interpolation_eof,
|
|
|
|
justfile: "
|
|
|
|
foo:
|
|
|
|
echo {{",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-16 08:40:02 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: r#"error: Unterminated interpolation
|
|
|
|
|
|
|
|
|
3 | echo {{
|
|
|
|
| ^^
|
|
|
|
"#,
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: unterminated_backtick,
|
|
|
|
justfile: "
|
|
|
|
foo a=\t`echo blaaaaaah:
|
|
|
|
echo {{a}}",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-16 08:40:02 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: r#"error: Unterminated backtick
|
|
|
|
|
|
|
|
|
2 | foo a= `echo blaaaaaah:
|
|
|
|
| ^
|
|
|
|
"#,
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: unknown_start_of_token,
|
|
|
|
justfile: "
|
|
|
|
assembly_source_files = $(wildcard src/arch/$(arch)/*.s)
|
|
|
|
",
|
|
|
|
args: (),
|
2019-04-17 05:52:16 +03:00
|
|
|
stdin: "",
|
2019-04-16 08:40:02 +03:00
|
|
|
stdout: "",
|
|
|
|
stderr: r#"error: Unknown start of token:
|
|
|
|
|
|
|
|
|
2 | assembly_source_files = $(wildcard src/arch/$(arch)/*.s)
|
|
|
|
| ^
|
|
|
|
"#,
|
|
|
|
status: EXIT_FAILURE,
|
|
|
|
}
|
2019-04-17 05:52:16 +03:00
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: backtick_variable_cat,
|
|
|
|
justfile: "
|
2019-04-18 21:48:02 +03:00
|
|
|
stdin := `cat`
|
2019-04-17 05:52:16 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
echo {{stdin}}
|
|
|
|
",
|
|
|
|
args: (),
|
|
|
|
stdin: "STDIN",
|
|
|
|
stdout: "STDIN\n",
|
|
|
|
stderr: "echo STDIN\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: backtick_default_cat_stdin,
|
|
|
|
justfile: "
|
|
|
|
default stdin = `cat`:
|
|
|
|
echo {{stdin}}
|
|
|
|
",
|
|
|
|
args: (),
|
|
|
|
stdin: "STDIN",
|
|
|
|
stdout: "STDIN\n",
|
|
|
|
stderr: "echo STDIN\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: backtick_default_cat_justfile,
|
|
|
|
justfile: "
|
|
|
|
default stdin = `cat justfile`:
|
|
|
|
echo '{{stdin}}'
|
|
|
|
",
|
|
|
|
args: (),
|
|
|
|
stdin: "",
|
|
|
|
stdout: "
|
|
|
|
default stdin = `cat justfile`:
|
|
|
|
echo {{stdin}}
|
|
|
|
",
|
|
|
|
stderr: "echo '
|
|
|
|
default stdin = `cat justfile`:
|
|
|
|
echo '{{stdin}}''\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: backtick_variable_read_single,
|
|
|
|
justfile: "
|
2019-04-18 21:48:02 +03:00
|
|
|
password := `read PW && echo $PW`
|
2019-04-17 05:52:16 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
echo {{password}}
|
|
|
|
",
|
|
|
|
args: (),
|
|
|
|
stdin: "foobar\n",
|
|
|
|
stdout: "foobar\n",
|
|
|
|
stderr: "echo foobar\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: backtick_variable_read_multiple,
|
|
|
|
justfile: "
|
2019-04-18 21:48:02 +03:00
|
|
|
a := `read A && echo $A`
|
|
|
|
b := `read B && echo $B`
|
2019-04-17 05:52:16 +03:00
|
|
|
|
|
|
|
default:
|
|
|
|
echo {{a}}
|
|
|
|
echo {{b}}
|
|
|
|
",
|
|
|
|
args: (),
|
|
|
|
stdin: "foo\nbar\n",
|
|
|
|
stdout: "foo\nbar\n",
|
|
|
|
stderr: "echo foo\necho bar\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: backtick_default_read_multiple,
|
|
|
|
justfile: "
|
|
|
|
|
|
|
|
default a=`read A && echo $A` b=`read B && echo $B`:
|
|
|
|
echo {{a}}
|
|
|
|
echo {{b}}
|
|
|
|
",
|
|
|
|
args: (),
|
|
|
|
stdin: "foo\nbar\n",
|
|
|
|
stdout: "foo\nbar\n",
|
|
|
|
stderr: "echo foo\necho bar\n",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
2019-04-18 21:48:02 +03:00
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: equals_deprecated_assignment,
|
|
|
|
justfile: "
|
|
|
|
|
|
|
|
foo = 'bar'
|
|
|
|
|
|
|
|
default:
|
|
|
|
echo {{foo}}
|
|
|
|
|
|
|
|
",
|
|
|
|
args: (),
|
|
|
|
stdin: "",
|
|
|
|
stdout: "bar\n",
|
|
|
|
stderr: "warning: `=` in assignments, exports, and aliases is being phased out on favor of `:=`
|
|
|
|
Please see this issue for more details: https://github.com/casey/just/issues/379
|
|
|
|
echo bar
|
|
|
|
",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: equals_deprecated_export,
|
|
|
|
justfile: "
|
|
|
|
|
|
|
|
export FOO = 'bar'
|
|
|
|
|
|
|
|
default:
|
|
|
|
echo $FOO
|
|
|
|
|
|
|
|
",
|
|
|
|
args: (),
|
|
|
|
stdin: "",
|
|
|
|
stdout: "bar\n",
|
|
|
|
stderr: "warning: `=` in assignments, exports, and aliases is being phased out on favor of `:=`
|
|
|
|
Please see this issue for more details: https://github.com/casey/just/issues/379
|
|
|
|
echo $FOO
|
|
|
|
",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|
|
|
|
|
|
|
|
integration_test! {
|
|
|
|
name: equals_deprecated_alias,
|
|
|
|
justfile: "
|
|
|
|
|
|
|
|
alias foo = default
|
|
|
|
|
|
|
|
default:
|
|
|
|
echo default
|
|
|
|
|
|
|
|
",
|
|
|
|
args: ("foo"),
|
|
|
|
stdin: "",
|
|
|
|
stdout: "default\n",
|
|
|
|
stderr: "warning: `=` in assignments, exports, and aliases is being phased out on favor of `:=`
|
|
|
|
Please see this issue for more details: https://github.com/casey/just/issues/379
|
|
|
|
echo default
|
|
|
|
",
|
|
|
|
status: EXIT_SUCCESS,
|
|
|
|
}
|