just/tests/json.rs

1192 lines
26 KiB
Rust
Raw Permalink Normal View History

use super::*;
2021-11-17 00:07:48 -08:00
2023-12-27 20:27:15 -08:00
fn case(justfile: &str, value: Value) {
2021-11-17 00:07:48 -08:00
Test::new()
.justfile(justfile)
2023-01-03 22:31:56 -08:00
.args(["--dump", "--dump-format", "json", "--unstable"])
2021-11-17 00:07:48 -08:00
.stdout(format!("{}\n", serde_json::to_string(&value).unwrap()))
.run();
}
#[test]
fn alias() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"
alias f := foo
foo:
",
json!({
"first": "foo",
"doc": null,
2021-11-17 00:07:48 -08:00
"aliases": {
"f": {
"name": "f",
"target": "foo",
"attributes": [],
2021-11-17 00:07:48 -08:00
}
},
"assignments": {},
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {
"foo": {
"attributes": [],
2021-11-17 00:07:48 -08:00
"body": [],
"dependencies": [],
"doc": null,
"name": "foo",
"namepath": "foo",
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
}
},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
"ignore_comments": false,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn assignment() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"foo := 'bar'",
json!({
"aliases": {},
"assignments": {
"foo": {
"export": false,
"name": "foo",
"value": "bar",
"depth": 0,
2021-11-17 00:07:48 -08:00
}
},
"first": null,
"doc": null,
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
"ignore_comments": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn body() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"
foo:
bar
abc{{ 'xyz' }}def
",
json!({
"aliases": {},
"assignments": {},
"first": "foo",
"doc": null,
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {
"foo": {
"attributes": [],
2021-11-17 00:07:48 -08:00
"body": [
["bar"],
["abc", ["xyz"], "def"],
],
"dependencies": [],
"doc": null,
"name": "foo",
"namepath": "foo",
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
}
},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
"ignore_comments": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn dependencies() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"
foo:
bar: foo
",
json!({
"aliases": {},
"assignments": {},
"first": "foo",
"doc": null,
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {
"bar": {
"attributes": [],
2021-11-17 00:07:48 -08:00
"doc": null,
"name": "bar",
"namepath": "bar",
2021-11-17 00:07:48 -08:00
"body": [],
"dependencies": [{
"arguments": [],
"recipe": "foo"
}],
"parameters": [],
"priors": 1,
"private": false,
"quiet": false,
"shebang": false,
},
"foo": {
"body": [],
"dependencies": [],
"doc": null,
"name": "foo",
"namepath": "foo",
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
}
},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
"ignore_comments": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn dependency_argument() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"
x := 'foo'
foo *args:
bar: (
foo
'baz'
('baz')
('a' + 'b')
`echo`
x
if 'a' == 'b' { 'c' } else { 'd' }
arch()
env_var('foo')
join('a', 'b')
replace('a', 'b', 'c')
)
",
json!({
"aliases": {},
"first": "foo",
"doc": null,
2021-11-17 00:07:48 -08:00
"assignments": {
"x": {
"export": false,
"name": "x",
"value": "foo",
"depth": 0,
2021-11-17 00:07:48 -08:00
},
},
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {
"bar": {
"doc": null,
"name": "bar",
"namepath": "bar",
2021-11-17 00:07:48 -08:00
"body": [],
"dependencies": [{
"arguments": [
"baz",
"baz",
2022-12-30 12:36:08 -08:00
["concatenate", "a", "b"],
2021-11-17 00:07:48 -08:00
["evaluate", "echo"],
["variable", "x"],
2024-05-14 18:55:32 -07:00
["if", ["==", "a", "b"], "c", "d"],
2021-11-17 00:07:48 -08:00
["call", "arch"],
["call", "env_var", "foo"],
["call", "join", "a", "b"],
["call", "replace", "a", "b", "c"],
],
"recipe": "foo"
}],
"parameters": [],
"priors": 1,
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
},
"foo": {
"body": [],
"dependencies": [],
"doc": null,
"name": "foo",
"namepath": "foo",
2021-11-17 00:07:48 -08:00
"parameters": [
{
"name": "args",
"export": false,
"default": null,
"kind": "star",
}
],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
}
},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2022-02-14 18:37:06 -08:00
"export": false,
"fallback": false,
"ignore_comments": false,
2022-02-14 18:37:06 -08:00
"positional_arguments": false,
"quiet": false,
2022-02-14 18:37:06 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
2022-02-14 18:37:06 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2022-02-14 18:37:06 -08:00
},
"unexports": [],
2022-02-14 18:37:06 -08:00
"warnings": [],
}),
);
}
#[test]
fn duplicate_recipes() {
2023-12-27 20:27:15 -08:00
case(
2022-02-14 18:37:06 -08:00
"
set allow-duplicate-recipes
alias f := foo
foo:
foo bar:
",
json!({
"first": "foo",
"doc": null,
2022-02-14 18:37:06 -08:00
"aliases": {
"f": {
"attributes": [],
2022-02-14 18:37:06 -08:00
"name": "f",
"target": "foo",
}
},
"assignments": {},
2023-12-27 20:27:15 -08:00
"modules": {},
2022-02-14 18:37:06 -08:00
"recipes": {
"foo": {
"body": [],
"dependencies": [],
"doc": null,
"name": "foo",
"namepath": "foo",
2022-02-14 18:37:06 -08:00
"parameters": [
{
"name": "bar",
"export": false,
"default": null,
"kind": "singular",
},
],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2022-02-14 18:37:06 -08:00
}
},
"settings": {
"allow_duplicate_recipes": true,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
"export": false,
"fallback": false,
"ignore_comments": false,
"positional_arguments": false,
"quiet": false,
"shell": null,
"tempdir" : null,
"unstable": false,
"windows_powershell": false,
"windows_shell": null,
},
"unexports": [],
"warnings": [],
}),
);
}
#[test]
fn duplicate_variables() {
case(
"
set allow-duplicate-variables
x := 'foo'
x := 'bar'
",
json!({
"aliases": {},
"assignments": {
"x": {
"export": false,
"name": "x",
"value": "bar",
"depth": 0,
}
},
"first": null,
"doc": null,
"modules": {},
"recipes": {},
"settings": {
"allow_duplicate_recipes": false,
"allow_duplicate_variables": true,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
"ignore_comments": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn doc_comment() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"# hello\nfoo:",
json!({
"aliases": {},
"first": "foo",
"doc": null,
2021-11-17 00:07:48 -08:00
"assignments": {},
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {
"foo": {
"body": [],
"dependencies": [],
"doc": "hello",
"name": "foo",
"namepath": "foo",
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
}
},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
"ignore_comments": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn empty_justfile() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"",
json!({
"aliases": {},
"assignments": {},
"first": null,
"doc": null,
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
"ignore_comments": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn parameters() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"
a:
b x:
c x='y':
d +x:
e *x:
f $x:
",
json!({
"aliases": {},
"first": "a",
"doc": null,
2021-11-17 00:07:48 -08:00
"assignments": {},
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {
"a": {
"attributes": [],
2021-11-17 00:07:48 -08:00
"body": [],
"dependencies": [],
"doc": null,
"name": "a",
"namepath": "a",
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
},
"b": {
"body": [],
"dependencies": [],
"doc": null,
"name": "b",
"namepath": "b",
2021-11-17 00:07:48 -08:00
"parameters": [
{
"name": "x",
"export": false,
"default": null,
"kind": "singular",
},
],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
},
"c": {
"body": [],
"dependencies": [],
"doc": null,
"name": "c",
"namepath": "c",
2021-11-17 00:07:48 -08:00
"parameters": [
{
"name": "x",
"export": false,
"default": "y",
"kind": "singular",
}
],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
},
"d": {
"body": [],
"dependencies": [],
"doc": null,
"name": "d",
"namepath": "d",
2021-11-17 00:07:48 -08:00
"parameters": [
{
"name": "x",
"export": false,
"default": null,
"kind": "plus",
}
],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
},
"e": {
"body": [],
"dependencies": [],
"doc": null,
"name": "e",
"namepath": "e",
2021-11-17 00:07:48 -08:00
"parameters": [
{
"name": "x",
"export": false,
"default": null,
"kind": "star",
}
],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
},
"f": {
"body": [],
"dependencies": [],
"doc": null,
"name": "f",
"namepath": "f",
2021-11-17 00:07:48 -08:00
"parameters": [
{
"name": "x",
"export": true,
"default": null,
"kind": "singular",
}
],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
},
},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
"ignore_comments": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn priors() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"
a:
b: a && c
c:
",
json!({
"aliases": {},
"assignments": {},
"first": "a",
"doc": null,
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {
"a": {
"body": [],
"dependencies": [],
"doc": null,
"name": "a",
"namepath": "a",
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
},
"b": {
"body": [],
"dependencies": [
{
"arguments": [],
"recipe": "a",
},
{
"arguments": [],
"recipe": "c",
}
],
"doc": null,
"name": "b",
"namepath": "b",
2021-11-17 00:07:48 -08:00
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 1,
},
"c": {
"body": [],
"dependencies": [],
"doc": null,
"name": "c",
"namepath": "c",
2021-11-17 00:07:48 -08:00
"parameters": [],
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 0,
},
},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
"ignore_comments": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn private() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"_foo:",
json!({
"aliases": {},
"assignments": {},
"first": "_foo",
"doc": null,
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {
"_foo": {
"body": [],
"dependencies": [],
"doc": null,
"name": "_foo",
"namepath": "_foo",
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 0,
"private": true,
"quiet": false,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
}
},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
"ignore_comments": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn quiet() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"@foo:",
json!({
"aliases": {},
"assignments": {},
"first": "foo",
"doc": null,
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {
"foo": {
"body": [],
"dependencies": [],
"doc": null,
"name": "foo",
"namepath": "foo",
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 0,
"private": false,
"quiet": true,
"shebang": false,
"attributes": [],
2021-11-17 00:07:48 -08:00
}
},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
"ignore_comments": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn settings() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"
set dotenv-load
set dotenv-filename := \"filename\"
set dotenv-path := \"path\"
2021-11-17 00:07:48 -08:00
set export
set fallback
2021-11-17 00:07:48 -08:00
set positional-arguments
set quiet
set ignore-comments
2021-11-17 00:07:48 -08:00
set shell := ['a', 'b', 'c']
foo:
#!bar
",
json!({
"aliases": {},
"assignments": {},
"first": "foo",
"doc": null,
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {
"foo": {
"body": [["#!bar"]],
"dependencies": [],
"doc": null,
"name": "foo",
"namepath": "foo",
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 0,
"private": false,
"quiet": false,
"shebang": true,
"attributes": [],
2021-11-17 00:07:48 -08:00
}
},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": "filename",
2021-11-17 00:07:48 -08:00
"dotenv_load": true,
"dotenv_path": "path",
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": true,
"fallback": true,
"ignore_comments": true,
2021-11-17 00:07:48 -08:00
"positional_arguments": true,
"quiet": true,
2021-11-17 00:07:48 -08:00
"shell": {
"arguments": ["b", "c"],
"command": "a",
},
2022-10-25 16:57:20 -07:00
"tempdir": null,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn shebang() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"
foo:
#!bar
",
json!({
"aliases": {},
"assignments": {},
"first": "foo",
"doc": null,
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {
"foo": {
"body": [["#!bar"]],
"dependencies": [],
"doc": null,
"name": "foo",
"namepath": "foo",
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 0,
"private": false,
"quiet": false,
"shebang": true,
"attributes": [],
2021-11-17 00:07:48 -08:00
}
},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
"ignore_comments": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir": null,
"unstable": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
#[test]
fn simple() {
2023-12-27 20:27:15 -08:00
case(
2021-11-17 00:07:48 -08:00
"foo:",
json!({
"aliases": {},
"assignments": {},
"first": "foo",
"doc": null,
2023-12-27 20:27:15 -08:00
"modules": {},
2021-11-17 00:07:48 -08:00
"recipes": {
"foo": {
"body": [],
"dependencies": [],
"doc": null,
"name": "foo",
"namepath": "foo",
2021-11-17 00:07:48 -08:00
"parameters": [],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
"attributes": [],
}
},
"settings": {
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
"export": false,
"fallback": false,
"ignore_comments": false,
"positional_arguments": false,
"quiet": false,
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir": null,
"unstable": false,
"windows_powershell": false,
"windows_shell": null,
},
"unexports": [],
"warnings": [],
}),
);
}
#[test]
fn attribute() {
2023-12-27 20:27:15 -08:00
case(
"
[no-exit-message]
foo:
",
json!({
"aliases": {},
"assignments": {},
"first": "foo",
"doc": null,
2023-12-27 20:27:15 -08:00
"modules": {},
"recipes": {
"foo": {
"attributes": ["no-exit-message"],
"body": [],
"dependencies": [],
"doc": null,
"name": "foo",
"namepath": "foo",
"parameters": [],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
2021-11-17 00:07:48 -08:00
}
},
"settings": {
2022-02-14 18:37:06 -08:00
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
"dotenv_filename": null,
"dotenv_load": false,
"dotenv_path": null,
"dotenv_required": false,
2021-11-17 00:07:48 -08:00
"export": false,
"fallback": false,
2021-11-17 00:07:48 -08:00
"positional_arguments": false,
"quiet": false,
2021-11-17 00:07:48 -08:00
"shell": null,
2022-10-25 16:57:20 -07:00
"tempdir" : null,
"unstable": false,
"ignore_comments": false,
2022-01-18 11:02:15 -08:00
"windows_powershell": false,
2022-05-31 13:01:59 -07:00
"windows_shell": null,
2021-11-17 00:07:48 -08:00
},
"unexports": [],
2021-11-17 00:07:48 -08:00
"warnings": [],
}),
);
}
2023-12-27 20:27:15 -08:00
#[test]
fn module() {
Test::new()
.justfile(
"
# hello
2023-12-27 20:27:15 -08:00
mod foo
",
)
.tree(tree! {
"foo.just": "bar:",
})
.args(["--dump", "--dump-format", "json", "--unstable"])
.test_round_trip(false)
.stdout(format!(
"{}\n",
serde_json::to_string(&json!({
"aliases": {},
"assignments": {},
"first": null,
"doc": null,
2023-12-27 20:27:15 -08:00
"modules": {
"foo": {
"aliases": {},
"assignments": {},
"first": "bar",
"doc": "hello",
2023-12-27 20:27:15 -08:00
"modules": {},
"recipes": {
"bar": {
"attributes": [],
"body": [],
"dependencies": [],
"doc": null,
"name": "bar",
"namepath": "foo::bar",
2023-12-27 20:27:15 -08:00
"parameters": [],
"priors": 0,
"private": false,
"quiet": false,
"shebang": false,
}
},
"settings": {
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
2023-12-27 20:27:15 -08:00
"dotenv_filename": null,
"dotenv_load": false,
2023-12-27 20:27:15 -08:00
"dotenv_path": null,
"dotenv_required": false,
2023-12-27 20:27:15 -08:00
"export": false,
"fallback": false,
"positional_arguments": false,
"quiet": false,
2023-12-27 20:27:15 -08:00
"shell": null,
"tempdir" : null,
"unstable": false,
2023-12-27 20:27:15 -08:00
"ignore_comments": false,
"windows_powershell": false,
"windows_shell": null,
},
"unexports": [],
2023-12-27 20:27:15 -08:00
"warnings": [],
},
},
"recipes": {},
"settings": {
"allow_duplicate_recipes": false,
"allow_duplicate_variables": false,
2023-12-27 20:27:15 -08:00
"dotenv_filename": null,
"dotenv_load": false,
2023-12-27 20:27:15 -08:00
"dotenv_path": null,
"dotenv_required": false,
2023-12-27 20:27:15 -08:00
"export": false,
"fallback": false,
"positional_arguments": false,
"quiet": false,
2023-12-27 20:27:15 -08:00
"shell": null,
"tempdir" : null,
"unstable": false,
2023-12-27 20:27:15 -08:00
"ignore_comments": false,
"windows_powershell": false,
"windows_shell": null,
},
"unexports": [],
2023-12-27 20:27:15 -08:00
"warnings": [],
}))
.unwrap()
))
.run();
}