2024-05-20 10:25:18 +03:00
|
|
|
use super::*;
|
|
|
|
|
2024-05-25 11:01:37 +03:00
|
|
|
#[test]
|
|
|
|
fn modules_unsorted() {
|
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "foo:")
|
|
|
|
.write("bar.just", "bar:")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
mod foo
|
|
|
|
|
|
|
|
mod bar
|
|
|
|
",
|
|
|
|
)
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list", "--unsorted"])
|
2024-05-25 11:01:37 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
2024-05-30 05:15:10 +03:00
|
|
|
foo ...
|
|
|
|
bar ...
|
2024-05-20 10:25:18 +03:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2024-05-26 04:10:06 +03:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn unsorted_list_order() {
|
|
|
|
Test::new()
|
|
|
|
.write("a.just", "a:")
|
|
|
|
.write("b.just", "b:")
|
|
|
|
.write("c.just", "c:")
|
|
|
|
.write("d.just", "d:")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
import 'a.just'
|
|
|
|
import 'b.just'
|
|
|
|
import 'c.just'
|
|
|
|
import 'd.just'
|
|
|
|
x:
|
|
|
|
y:
|
|
|
|
z:
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.args(["--list", "--unsorted"])
|
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
x
|
|
|
|
y
|
|
|
|
z
|
|
|
|
a
|
|
|
|
b
|
|
|
|
c
|
|
|
|
d
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
Test::new()
|
|
|
|
.write("a.just", "a:")
|
|
|
|
.write("b.just", "b:")
|
|
|
|
.write("c.just", "c:")
|
|
|
|
.write("d.just", "d:")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
x:
|
|
|
|
y:
|
|
|
|
z:
|
|
|
|
import 'd.just'
|
|
|
|
import 'c.just'
|
|
|
|
import 'b.just'
|
|
|
|
import 'a.just'
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.args(["--list", "--unsorted"])
|
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
x
|
|
|
|
y
|
|
|
|
z
|
|
|
|
d
|
|
|
|
c
|
|
|
|
b
|
|
|
|
a
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
Test::new()
|
|
|
|
.write("a.just", "a:\nimport 'e.just'")
|
|
|
|
.write("b.just", "b:\nimport 'f.just'")
|
|
|
|
.write("c.just", "c:\nimport 'g.just'")
|
|
|
|
.write("d.just", "d:\nimport 'h.just'")
|
|
|
|
.write("e.just", "e:")
|
|
|
|
.write("f.just", "f:")
|
|
|
|
.write("g.just", "g:")
|
|
|
|
.write("h.just", "h:")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
x:
|
|
|
|
y:
|
|
|
|
z:
|
|
|
|
import 'd.just'
|
|
|
|
import 'c.just'
|
|
|
|
import 'b.just'
|
|
|
|
import 'a.just'
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.args(["--list", "--unsorted"])
|
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
x
|
|
|
|
y
|
|
|
|
z
|
|
|
|
d
|
|
|
|
h
|
|
|
|
c
|
|
|
|
g
|
|
|
|
b
|
|
|
|
f
|
|
|
|
a
|
|
|
|
e
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
Test::new()
|
|
|
|
.write("task1.just", "task1:")
|
|
|
|
.write("task2.just", "task2:")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
import 'task1.just'
|
|
|
|
import 'task2.just'
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.args(["--list", "--unsorted"])
|
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
task1
|
|
|
|
task2
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2024-05-29 11:08:29 +03:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn list_submodule() {
|
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "bar:")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
mod foo
|
|
|
|
",
|
|
|
|
)
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list", "foo"])
|
2024-05-29 11:08:29 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
bar
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn list_nested_submodule() {
|
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "mod bar")
|
|
|
|
.write("bar.just", "baz:")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
mod foo
|
|
|
|
",
|
|
|
|
)
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list", "foo", "bar"])
|
2024-05-29 11:08:29 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
baz
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
|
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "mod bar")
|
|
|
|
.write("bar.just", "baz:")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
mod foo
|
|
|
|
",
|
|
|
|
)
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list", "foo::bar"])
|
2024-05-29 11:08:29 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
baz
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn list_invalid_path() {
|
|
|
|
Test::new()
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list", "$hello"])
|
2024-05-29 11:08:29 +03:00
|
|
|
.stderr("error: Invalid module path `$hello`\n")
|
|
|
|
.status(1)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn list_unknown_submodule() {
|
|
|
|
Test::new()
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list", "hello"])
|
2024-05-29 11:08:29 +03:00
|
|
|
.stderr("error: Justfile does not contain submodule `hello`\n")
|
|
|
|
.status(1)
|
|
|
|
.run();
|
|
|
|
}
|
2024-05-30 20:28:54 +03:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn list_with_groups_in_modules() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
[group('FOO')]
|
|
|
|
foo:
|
|
|
|
|
|
|
|
mod bar
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.write("bar.just", "[group('BAZ')]\nbaz:")
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list", "--list-submodules"])
|
2024-05-30 20:28:54 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
bar:
|
|
|
|
[BAZ]
|
|
|
|
baz
|
2024-07-22 02:35:26 +03:00
|
|
|
|
|
|
|
[FOO]
|
|
|
|
foo
|
2024-05-30 20:28:54 +03:00
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn list_displays_recipes_in_submodules() {
|
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "bar:\n @echo FOO")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
mod foo
|
|
|
|
",
|
|
|
|
)
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list", "--list-submodules"])
|
2024-05-30 20:28:54 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
foo:
|
|
|
|
bar
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn modules_are_space_separated_in_output() {
|
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "foo:")
|
|
|
|
.write("bar.just", "bar:")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
mod foo
|
|
|
|
|
|
|
|
mod bar
|
|
|
|
",
|
|
|
|
)
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list", "--list-submodules"])
|
2024-05-30 20:28:54 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
bar:
|
|
|
|
bar
|
|
|
|
|
|
|
|
foo:
|
|
|
|
foo
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn module_recipe_list_alignment_ignores_private_recipes() {
|
|
|
|
Test::new()
|
|
|
|
.write(
|
|
|
|
"foo.just",
|
|
|
|
"
|
|
|
|
# foos
|
|
|
|
foo:
|
|
|
|
@echo FOO
|
|
|
|
|
|
|
|
[private]
|
|
|
|
barbarbar:
|
|
|
|
@echo BAR
|
|
|
|
|
|
|
|
@_bazbazbaz:
|
|
|
|
@echo BAZ
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.justfile("mod foo")
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list", "--list-submodules"])
|
2024-05-30 20:28:54 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
foo:
|
|
|
|
foo # foos
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn nested_modules_are_properly_indented() {
|
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "mod bar")
|
|
|
|
.write("bar.just", "baz:\n @echo FOO")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
mod foo
|
|
|
|
",
|
|
|
|
)
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list", "--list-submodules"])
|
2024-05-30 20:28:54 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
foo:
|
|
|
|
bar:
|
|
|
|
baz
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2024-06-29 07:13:11 +03:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn module_doc_rendered() {
|
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
# Module foo
|
|
|
|
mod foo
|
|
|
|
",
|
|
|
|
)
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list"])
|
2024-06-29 07:13:11 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
foo ... # Module foo
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn module_doc_aligned() {
|
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "")
|
|
|
|
.write("bar.just", "")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
# Module foo
|
|
|
|
mod foo
|
|
|
|
|
|
|
|
# comment
|
|
|
|
mod very_long_name_for_module \"bar.just\" # comment
|
|
|
|
|
|
|
|
# will change your world
|
|
|
|
recipe:
|
|
|
|
@echo Hi
|
|
|
|
",
|
|
|
|
)
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list"])
|
2024-06-29 07:13:11 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
recipe # will change your world
|
|
|
|
foo ... # Module foo
|
|
|
|
very_long_name_for_module ... # comment
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2024-07-14 05:20:35 +03:00
|
|
|
|
|
|
|
#[test]
|
2024-07-22 02:35:26 +03:00
|
|
|
fn submodules_without_groups() {
|
2024-07-14 05:20:35 +03:00
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
mod foo
|
|
|
|
|
|
|
|
[group: 'baz']
|
|
|
|
bar:
|
|
|
|
",
|
|
|
|
)
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list"])
|
2024-07-14 05:20:35 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
2024-07-22 02:35:26 +03:00
|
|
|
foo ...
|
|
|
|
|
2024-07-14 05:20:35 +03:00
|
|
|
[baz]
|
|
|
|
bar
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn no_space_before_submodules_not_following_groups() {
|
|
|
|
Test::new()
|
|
|
|
.write("foo.just", "")
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
mod foo
|
|
|
|
",
|
|
|
|
)
|
2024-07-15 00:22:03 +03:00
|
|
|
.args(["--list"])
|
2024-07-14 05:20:35 +03:00
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
|
|
|
foo ...
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.run();
|
|
|
|
}
|
2024-11-09 22:05:58 +03:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn backticks_highlighted() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
# Comment `` `with backticks` and trailing text
|
|
|
|
recipe:
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.args(["--list", "--color=always"])
|
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
2024-11-17 03:21:14 +03:00
|
|
|
recipe \u{1b}[34m#\u{1b}[0m \u{1b}[34mComment \u{1b}[0m\u{1b}[36m``\u{1b}[0m\u{1b}[34m \u{1b}[0m\u{1b}[36m`with backticks`\u{1b}[0m\u{1b}[34m and trailing text\u{1b}[0m
|
2024-11-09 22:05:58 +03:00
|
|
|
")
|
|
|
|
.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn unclosed_backticks() {
|
|
|
|
Test::new()
|
|
|
|
.justfile(
|
|
|
|
"
|
|
|
|
# Comment `with unclosed backick
|
|
|
|
recipe:
|
|
|
|
",
|
|
|
|
)
|
|
|
|
.args(["--list", "--color=always"])
|
|
|
|
.stdout(
|
|
|
|
"
|
|
|
|
Available recipes:
|
2024-11-17 03:21:14 +03:00
|
|
|
recipe \u{1b}[34m#\u{1b}[0m \u{1b}[34mComment \u{1b}[0m\u{1b}[36m`with unclosed backick\u{1b}[0m
|
2024-11-09 22:05:58 +03:00
|
|
|
")
|
|
|
|
.run();
|
|
|
|
}
|