mirror of
https://github.com/casey/just.git
synced 2024-09-11 05:55:31 +03:00
Fix Rust 1.80.0 warnings (#2281)
This commit is contained in:
parent
df9774da5a
commit
044b00a90a
16
Cargo.toml
16
Cargo.toml
@ -60,6 +60,22 @@ pretty_assertions = "1.0.0"
|
||||
temptree = "0.2.0"
|
||||
which = "6.0.0"
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }
|
||||
|
||||
[lints.clippy]
|
||||
all = { level = "deny", priority = -1 }
|
||||
enum_glob_use = "allow"
|
||||
needless_pass_by_value = "allow"
|
||||
pedantic = { level = "deny", priority = -1 }
|
||||
similar_names = "allow"
|
||||
struct_excessive_bools = "allow"
|
||||
struct_field_names = "allow"
|
||||
too_many_arguments = "allow"
|
||||
too_many_lines = "allow"
|
||||
unnecessary_wraps = "allow"
|
||||
wildcard_imports = "allow"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
|
15
src/lib.rs
15
src/lib.rs
@ -1,18 +1,3 @@
|
||||
#![deny(clippy::all, clippy::pedantic)]
|
||||
#![allow(
|
||||
clippy::enum_glob_use,
|
||||
clippy::let_underscore_untyped,
|
||||
clippy::needless_pass_by_value,
|
||||
clippy::similar_names,
|
||||
clippy::struct_excessive_bools,
|
||||
clippy::struct_field_names,
|
||||
clippy::too_many_arguments,
|
||||
clippy::too_many_lines,
|
||||
clippy::unnecessary_wraps,
|
||||
clippy::wildcard_imports,
|
||||
overlapping_range_endpoints
|
||||
)]
|
||||
|
||||
//! `just` is primarily used as a command-line binary, but does provide a
|
||||
//! limited public library interface.
|
||||
//!
|
||||
|
@ -81,12 +81,11 @@ fn file_paths_are_relative() {
|
||||
.stderr(format!(
|
||||
"
|
||||
error: Expected '*', ':', '$', identifier, or '+', but found end of file
|
||||
——▶ foo{}bar.just:1:4
|
||||
——▶ foo{MAIN_SEPARATOR}bar.just:1:4
|
||||
│
|
||||
1 │ baz
|
||||
│ ^
|
||||
",
|
||||
MAIN_SEPARATOR
|
||||
))
|
||||
.run();
|
||||
}
|
||||
|
@ -2,17 +2,17 @@ use super::*;
|
||||
|
||||
test! {
|
||||
name: test_os_arch_functions_in_interpolation,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
foo:
|
||||
echo {{arch()}} {{os()}} {{os_family()}} {{num_cpus()}}
|
||||
"#,
|
||||
",
|
||||
stdout: format!("{} {} {} {}\n", target::arch(), target::os(), target::family(), num_cpus::get()).as_str(),
|
||||
stderr: format!("echo {} {} {} {}\n", target::arch(), target::os(), target::family(), num_cpus::get()).as_str(),
|
||||
}
|
||||
|
||||
test! {
|
||||
name: test_os_arch_functions_in_expression,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
a := arch()
|
||||
o := os()
|
||||
f := os_family()
|
||||
@ -20,7 +20,7 @@ n := num_cpus()
|
||||
|
||||
foo:
|
||||
echo {{a}} {{o}} {{f}} {{n}}
|
||||
"#,
|
||||
",
|
||||
stdout: format!("{} {} {} {}\n", target::arch(), target::os(), target::family(), num_cpus::get()).as_str(),
|
||||
stderr: format!("echo {} {} {} {}\n", target::arch(), target::os(), target::family(), num_cpus::get()).as_str(),
|
||||
}
|
||||
@ -28,14 +28,14 @@ foo:
|
||||
#[cfg(not(windows))]
|
||||
test! {
|
||||
name: env_var_functions,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
p := env_var('USER')
|
||||
b := env_var_or_default('ZADDY', 'HTAP')
|
||||
x := env_var_or_default('XYZ', 'ABC')
|
||||
|
||||
foo:
|
||||
/usr/bin/env echo '{{p}}' '{{b}}' '{{x}}'
|
||||
"#,
|
||||
",
|
||||
stdout: format!("{} HTAP ABC\n", env::var("USER").unwrap()).as_str(),
|
||||
stderr: format!("/usr/bin/env echo '{}' 'HTAP' 'ABC'\n", env::var("USER").unwrap()).as_str(),
|
||||
}
|
||||
@ -43,7 +43,7 @@ foo:
|
||||
#[cfg(not(windows))]
|
||||
test! {
|
||||
name: path_functions,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
we := without_extension('/foo/bar/baz.hello')
|
||||
fs := file_stem('/foo/bar/baz.hello')
|
||||
fn := file_name('/foo/bar/baz.hello')
|
||||
@ -53,7 +53,7 @@ jn := join('a', 'b')
|
||||
|
||||
foo:
|
||||
/usr/bin/env echo '{{we}}' '{{fs}}' '{{fn}}' '{{dir}}' '{{ext}}' '{{jn}}'
|
||||
"#,
|
||||
",
|
||||
stdout: "/foo/bar/baz baz baz.hello /foo/bar hello a/b\n",
|
||||
stderr: "/usr/bin/env echo '/foo/bar/baz' 'baz' 'baz.hello' '/foo/bar' 'hello' 'a/b'\n",
|
||||
}
|
||||
@ -61,7 +61,7 @@ foo:
|
||||
#[cfg(not(windows))]
|
||||
test! {
|
||||
name: path_functions2,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
we := without_extension('/foo/bar/baz')
|
||||
fs := file_stem('/foo/bar/baz.hello.ciao')
|
||||
fn := file_name('/bar/baz.hello.ciao')
|
||||
@ -70,7 +70,7 @@ ext := extension('/foo/bar/baz.hello.ciao')
|
||||
|
||||
foo:
|
||||
/usr/bin/env echo '{{we}}' '{{fs}}' '{{fn}}' '{{dir}}' '{{ext}}'
|
||||
"#,
|
||||
",
|
||||
stdout: "/foo/bar/baz baz.hello baz.hello.ciao / ciao\n",
|
||||
stderr: "/usr/bin/env echo '/foo/bar/baz' 'baz.hello' 'baz.hello.ciao' '/' 'ciao'\n",
|
||||
}
|
||||
@ -78,12 +78,12 @@ foo:
|
||||
#[cfg(not(windows))]
|
||||
test! {
|
||||
name: broken_without_extension_function,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
we := without_extension('')
|
||||
|
||||
foo:
|
||||
/usr/bin/env echo '{{we}}'
|
||||
"#,
|
||||
",
|
||||
stdout: "",
|
||||
stderr: format!("{} {}\n{}\n{}\n{}\n{}\n",
|
||||
"error: Call to function `without_extension` failed:",
|
||||
@ -98,12 +98,12 @@ foo:
|
||||
#[cfg(not(windows))]
|
||||
test! {
|
||||
name: broken_extension_function,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
we := extension('')
|
||||
|
||||
foo:
|
||||
/usr/bin/env echo '{{we}}'
|
||||
"#,
|
||||
",
|
||||
stdout: "",
|
||||
stderr: format!("{}\n{}\n{}\n{}\n{}\n",
|
||||
"error: Call to function `extension` failed: Could not extract extension from ``",
|
||||
@ -117,12 +117,12 @@ foo:
|
||||
#[cfg(not(windows))]
|
||||
test! {
|
||||
name: broken_extension_function2,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
we := extension('foo')
|
||||
|
||||
foo:
|
||||
/usr/bin/env echo '{{we}}'
|
||||
"#,
|
||||
",
|
||||
stdout: "",
|
||||
stderr: format!("{}\n{}\n{}\n{}\n{}\n",
|
||||
"error: Call to function `extension` failed: Could not extract extension from `foo`",
|
||||
@ -136,12 +136,12 @@ foo:
|
||||
#[cfg(not(windows))]
|
||||
test! {
|
||||
name: broken_file_stem_function,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
we := file_stem('')
|
||||
|
||||
foo:
|
||||
/usr/bin/env echo '{{we}}'
|
||||
"#,
|
||||
",
|
||||
stdout: "",
|
||||
stderr: format!("{}\n{}\n{}\n{}\n{}\n",
|
||||
"error: Call to function `file_stem` failed: Could not extract file stem from ``",
|
||||
@ -155,12 +155,12 @@ foo:
|
||||
#[cfg(not(windows))]
|
||||
test! {
|
||||
name: broken_file_name_function,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
we := file_name('')
|
||||
|
||||
foo:
|
||||
/usr/bin/env echo '{{we}}'
|
||||
"#,
|
||||
",
|
||||
stdout: "",
|
||||
stderr: format!("{}\n{}\n{}\n{}\n{}\n",
|
||||
"error: Call to function `file_name` failed: Could not extract file name from ``",
|
||||
@ -174,12 +174,12 @@ foo:
|
||||
#[cfg(not(windows))]
|
||||
test! {
|
||||
name: broken_directory_function,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
we := parent_directory('')
|
||||
|
||||
foo:
|
||||
/usr/bin/env echo '{{we}}'
|
||||
"#,
|
||||
",
|
||||
stdout: "",
|
||||
stderr: format!("{} {}\n{}\n{}\n{}\n{}\n",
|
||||
"error: Call to function `parent_directory` failed:",
|
||||
@ -194,12 +194,12 @@ foo:
|
||||
#[cfg(not(windows))]
|
||||
test! {
|
||||
name: broken_directory_function2,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
we := parent_directory('/')
|
||||
|
||||
foo:
|
||||
/usr/bin/env echo '{{we}}'
|
||||
"#,
|
||||
",
|
||||
stdout: "",
|
||||
stderr: format!("{} {}\n{}\n{}\n{}\n{}\n",
|
||||
"error: Call to function `parent_directory` failed:",
|
||||
@ -254,10 +254,10 @@ test! {
|
||||
|
||||
test! {
|
||||
name: test_os_arch_functions_in_default,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
foo a=arch() o=os() f=os_family() n=num_cpus():
|
||||
echo {{a}} {{o}} {{f}} {{n}}
|
||||
"#,
|
||||
",
|
||||
stdout: format!("{} {} {} {}\n", target::arch(), target::os(), target::family(), num_cpus::get()).as_str(),
|
||||
stderr: format!("echo {} {} {} {}\n", target::arch(), target::os(), target::family(), num_cpus::get()).as_str(),
|
||||
}
|
||||
@ -664,7 +664,7 @@ fn uuid() {
|
||||
#[test]
|
||||
fn choose() {
|
||||
Test::new()
|
||||
.justfile(r#"x := choose('10', 'xXyYzZ')"#)
|
||||
.justfile(r"x := choose('10', 'xXyYzZ')")
|
||||
.args(["--evaluate", "x"])
|
||||
.stdout_regex("^[X-Zx-z]{10}$")
|
||||
.run();
|
||||
|
@ -5,7 +5,7 @@ use {
|
||||
|
||||
fn kill(process_id: u32) {
|
||||
unsafe {
|
||||
libc::kill(process_id as i32, libc::SIGINT);
|
||||
libc::kill(process_id.try_into().unwrap(), libc::SIGINT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,13 +31,15 @@ fn interrupt_test(arguments: &[&str], justfile: &str) {
|
||||
|
||||
let elapsed = start.elapsed();
|
||||
|
||||
if elapsed > Duration::from_secs(2) {
|
||||
panic!("process returned too late: {elapsed:?}");
|
||||
}
|
||||
assert!(
|
||||
elapsed <= Duration::from_secs(2),
|
||||
"process returned too late: {elapsed:?}"
|
||||
);
|
||||
|
||||
if elapsed < Duration::from_millis(100) {
|
||||
panic!("process returned too early : {elapsed:?}");
|
||||
}
|
||||
assert!(
|
||||
elapsed >= Duration::from_millis(100),
|
||||
"process returned too early : {elapsed:?}"
|
||||
);
|
||||
|
||||
assert_eq!(status.code(), Some(130));
|
||||
}
|
||||
|
@ -78,9 +78,7 @@ fn test_invocation_directory() {
|
||||
failure = true;
|
||||
}
|
||||
|
||||
if failure {
|
||||
panic!("test failed");
|
||||
}
|
||||
assert!(!failure, "test failed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
104
tests/misc.rs
104
tests/misc.rs
@ -515,7 +515,7 @@ recipe arg:
|
||||
|
||||
test! {
|
||||
name: dry_run,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
var := `echo stderr 1>&2; echo backtick`
|
||||
|
||||
command:
|
||||
@ -527,7 +527,7 @@ shebang:
|
||||
#!/bin/sh
|
||||
touch /this/is/not/a/file
|
||||
{{var}}
|
||||
echo {{`echo shebang interpolation`}}"#,
|
||||
echo {{`echo shebang interpolation`}}",
|
||||
args: ("--dry-run", "shebang", "command"),
|
||||
stdout: "",
|
||||
stderr: "#!/bin/sh
|
||||
@ -542,7 +542,7 @@ echo `echo command interpolation`
|
||||
|
||||
test! {
|
||||
name: line_error_spacing,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
|
||||
|
||||
|
||||
@ -553,7 +553,7 @@ test! {
|
||||
|
||||
|
||||
^^^
|
||||
"#,
|
||||
",
|
||||
stdout: "",
|
||||
stderr: "error: Unknown start of token:
|
||||
——▶ justfile:10:1
|
||||
@ -707,10 +707,10 @@ Recipe `recipe` failed on line 2 with exit code 100\u{1b}[0m\n",
|
||||
|
||||
test! {
|
||||
name: dump,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
# this recipe does something
|
||||
recipe a b +d:
|
||||
@exit 100"#,
|
||||
@exit 100",
|
||||
args: ("--dump"),
|
||||
stdout: "# this recipe does something
|
||||
recipe a b +d:
|
||||
@ -824,10 +824,10 @@ hello baz arg='XYZ" ':
|
||||
|
||||
test! {
|
||||
name: supply_use_default,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
hello a b='B' c='C':
|
||||
echo {{a}} {{b}} {{c}}
|
||||
"#,
|
||||
",
|
||||
args: ("hello", "0", "1"),
|
||||
stdout: "0 1 C\n",
|
||||
stderr: "echo 0 1 C\n",
|
||||
@ -835,10 +835,10 @@ hello a b='B' c='C':
|
||||
|
||||
test! {
|
||||
name: supply_defaults,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
hello a b='B' c='C':
|
||||
echo {{a}} {{b}} {{c}}
|
||||
"#,
|
||||
",
|
||||
args: ("hello", "0", "1", "2"),
|
||||
stdout: "0 1 2\n",
|
||||
stderr: "echo 0 1 2\n",
|
||||
@ -918,75 +918,75 @@ _private-recipe:
|
||||
|
||||
test! {
|
||||
name: list_sorted,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
alias c := b
|
||||
b:
|
||||
a:
|
||||
"#,
|
||||
",
|
||||
args: ("--list"),
|
||||
stdout: r#"
|
||||
stdout: r"
|
||||
Available recipes:
|
||||
a
|
||||
b
|
||||
c # alias for `b`
|
||||
"#,
|
||||
",
|
||||
}
|
||||
|
||||
test! {
|
||||
name: list_unsorted,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
alias c := b
|
||||
b:
|
||||
a:
|
||||
"#,
|
||||
",
|
||||
args: ("--list", "--unsorted"),
|
||||
stdout: r#"
|
||||
stdout: r"
|
||||
Available recipes:
|
||||
b
|
||||
c # alias for `b`
|
||||
a
|
||||
"#,
|
||||
",
|
||||
}
|
||||
|
||||
test! {
|
||||
name: list_heading,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
a:
|
||||
b:
|
||||
"#,
|
||||
",
|
||||
args: ("--list", "--list-heading", "Cool stuff…\n"),
|
||||
stdout: r#"
|
||||
stdout: r"
|
||||
Cool stuff…
|
||||
a
|
||||
b
|
||||
"#,
|
||||
",
|
||||
}
|
||||
|
||||
test! {
|
||||
name: list_prefix,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
a:
|
||||
b:
|
||||
"#,
|
||||
",
|
||||
args: ("--list", "--list-prefix", "····"),
|
||||
stdout: r#"
|
||||
stdout: r"
|
||||
Available recipes:
|
||||
····a
|
||||
····b
|
||||
"#,
|
||||
",
|
||||
}
|
||||
|
||||
test! {
|
||||
name: list_empty_prefix_and_heading,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
a:
|
||||
b:
|
||||
"#,
|
||||
",
|
||||
args: ("--list", "--list-heading", "", "--list-prefix", ""),
|
||||
stdout: r#"
|
||||
stdout: r"
|
||||
a
|
||||
b
|
||||
"#,
|
||||
",
|
||||
}
|
||||
|
||||
test! {
|
||||
@ -1041,58 +1041,58 @@ foo:
|
||||
|
||||
test! {
|
||||
name: infallible_command,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
infallible:
|
||||
-exit 101
|
||||
"#,
|
||||
",
|
||||
stderr: "exit 101\n",
|
||||
status: EXIT_SUCCESS,
|
||||
}
|
||||
|
||||
test! {
|
||||
name: infallible_with_failing,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
infallible:
|
||||
-exit 101
|
||||
exit 202
|
||||
"#,
|
||||
stderr: r#"exit 101
|
||||
",
|
||||
stderr: r"exit 101
|
||||
exit 202
|
||||
error: Recipe `infallible` failed on line 3 with exit code 202
|
||||
"#,
|
||||
",
|
||||
status: 202,
|
||||
}
|
||||
|
||||
test! {
|
||||
name: quiet_recipe,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
@quiet:
|
||||
# a
|
||||
# b
|
||||
@echo c
|
||||
"#,
|
||||
",
|
||||
stdout: "c\n",
|
||||
stderr: "echo c\n",
|
||||
}
|
||||
|
||||
test! {
|
||||
name: quiet_shebang_recipe,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
@quiet:
|
||||
#!/bin/sh
|
||||
echo hello
|
||||
"#,
|
||||
",
|
||||
stdout: "hello\n",
|
||||
stderr: "#!/bin/sh\necho hello\n",
|
||||
}
|
||||
|
||||
test! {
|
||||
name: complex_dependencies,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
a: b
|
||||
b:
|
||||
c: b a
|
||||
"#,
|
||||
",
|
||||
args: ("b"),
|
||||
stdout: "",
|
||||
}
|
||||
@ -1551,12 +1551,12 @@ test! {
|
||||
foo x=bar:
|
||||
",
|
||||
stdout: "",
|
||||
stderr: r#"error: Variable `bar` not defined
|
||||
stderr: r"error: Variable `bar` not defined
|
||||
——▶ justfile:1:7
|
||||
│
|
||||
1 │ foo x=bar:
|
||||
│ ^^^
|
||||
"#,
|
||||
",
|
||||
status: EXIT_FAILURE,
|
||||
}
|
||||
|
||||
@ -1566,12 +1566,12 @@ test! {
|
||||
foo x=bar():
|
||||
",
|
||||
stdout: "",
|
||||
stderr: r#"error: Call to unknown function `bar`
|
||||
stderr: r"error: Call to unknown function `bar`
|
||||
——▶ justfile:1:7
|
||||
│
|
||||
1 │ foo x=bar():
|
||||
│ ^^^
|
||||
"#,
|
||||
",
|
||||
status: EXIT_FAILURE,
|
||||
}
|
||||
|
||||
@ -1622,13 +1622,13 @@ test! {
|
||||
foo:
|
||||
echo {{
|
||||
",
|
||||
stderr: r#"
|
||||
stderr: r"
|
||||
error: Unterminated interpolation
|
||||
——▶ justfile:2:8
|
||||
│
|
||||
2 │ echo {{
|
||||
│ ^^
|
||||
"#,
|
||||
",
|
||||
status: EXIT_FAILURE,
|
||||
}
|
||||
|
||||
@ -1638,13 +1638,13 @@ test! {
|
||||
foo:
|
||||
echo {{
|
||||
",
|
||||
stderr: r#"
|
||||
stderr: r"
|
||||
error: Unterminated interpolation
|
||||
——▶ justfile:2:8
|
||||
│
|
||||
2 │ echo {{
|
||||
│ ^^
|
||||
"#,
|
||||
",
|
||||
status: EXIT_FAILURE,
|
||||
}
|
||||
|
||||
@ -1653,13 +1653,13 @@ test! {
|
||||
justfile: "
|
||||
assembly_source_files = %(wildcard src/arch/$(arch)/*.s)
|
||||
",
|
||||
stderr: r#"
|
||||
stderr: r"
|
||||
error: Unknown start of token:
|
||||
——▶ justfile:1:25
|
||||
│
|
||||
1 │ assembly_source_files = %(wildcard src/arch/$(arch)/*.s)
|
||||
│ ^
|
||||
"#,
|
||||
",
|
||||
status: EXIT_FAILURE,
|
||||
}
|
||||
|
||||
|
@ -778,7 +778,7 @@ fn group_attribute_on_module() {
|
||||
.write("bar.just", "")
|
||||
.write("zee.just", "")
|
||||
.justfile(
|
||||
r#"
|
||||
r"
|
||||
[group('alpha')]
|
||||
mod zee
|
||||
|
||||
@ -795,7 +795,7 @@ fn group_attribute_on_module() {
|
||||
mod bar
|
||||
|
||||
c:
|
||||
"#,
|
||||
",
|
||||
)
|
||||
.test_round_trip(false)
|
||||
.arg("--list")
|
||||
@ -824,7 +824,7 @@ fn group_attribute_on_module_unsorted() {
|
||||
.write("bar.just", "")
|
||||
.write("zee.just", "")
|
||||
.justfile(
|
||||
r#"
|
||||
r"
|
||||
[group('alpha')]
|
||||
mod zee
|
||||
|
||||
@ -841,7 +841,7 @@ fn group_attribute_on_module_unsorted() {
|
||||
mod bar
|
||||
|
||||
c:
|
||||
"#,
|
||||
",
|
||||
)
|
||||
.test_round_trip(false)
|
||||
.arg("--list")
|
||||
@ -871,7 +871,7 @@ fn group_attribute_on_module_list_submodule() {
|
||||
.write("bar.just", "e:")
|
||||
.write("zee.just", "f:")
|
||||
.justfile(
|
||||
r#"
|
||||
r"
|
||||
[group('alpha')]
|
||||
mod zee
|
||||
|
||||
@ -888,7 +888,7 @@ fn group_attribute_on_module_list_submodule() {
|
||||
mod bar
|
||||
|
||||
c:
|
||||
"#,
|
||||
",
|
||||
)
|
||||
.test_round_trip(false)
|
||||
.arg("--list")
|
||||
@ -921,7 +921,7 @@ fn group_attribute_on_module_list_submodule_unsorted() {
|
||||
.write("bar.just", "e:")
|
||||
.write("zee.just", "f:")
|
||||
.justfile(
|
||||
r#"
|
||||
r"
|
||||
[group('alpha')]
|
||||
mod zee
|
||||
|
||||
@ -938,7 +938,7 @@ fn group_attribute_on_module_list_submodule_unsorted() {
|
||||
mod bar
|
||||
|
||||
c:
|
||||
"#,
|
||||
",
|
||||
)
|
||||
.test_round_trip(false)
|
||||
.arg("--list")
|
||||
@ -970,10 +970,10 @@ fn bad_module_attribute_fails() {
|
||||
Test::new()
|
||||
.write("foo.just", "")
|
||||
.justfile(
|
||||
r#"
|
||||
r"
|
||||
[no-cd]
|
||||
mod foo
|
||||
"#,
|
||||
",
|
||||
)
|
||||
.test_round_trip(false)
|
||||
.arg("--list")
|
||||
@ -987,11 +987,11 @@ fn empty_doc_attribute_on_module() {
|
||||
Test::new()
|
||||
.write("foo.just", "")
|
||||
.justfile(
|
||||
r#"
|
||||
r"
|
||||
# Suppressed comment
|
||||
[doc]
|
||||
mod foo
|
||||
"#,
|
||||
",
|
||||
)
|
||||
.test_round_trip(false)
|
||||
.arg("--list")
|
||||
|
@ -30,12 +30,12 @@ test! {
|
||||
|
||||
test! {
|
||||
name: recipe_has_doc_comment,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
# This is a doc comment
|
||||
[no-exit-message]
|
||||
hello:
|
||||
@exit 100
|
||||
"#,
|
||||
",
|
||||
args: ("--list"),
|
||||
stdout: "
|
||||
Available recipes:
|
||||
@ -45,67 +45,67 @@ hello:
|
||||
|
||||
test! {
|
||||
name: unknown_attribute,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
# This is a doc comment
|
||||
[unknown-attribute]
|
||||
hello:
|
||||
@exit 100
|
||||
"#,
|
||||
stderr: r#"
|
||||
",
|
||||
stderr: r"
|
||||
error: Unknown attribute `unknown-attribute`
|
||||
——▶ justfile:2:2
|
||||
│
|
||||
2 │ [unknown-attribute]
|
||||
│ ^^^^^^^^^^^^^^^^^
|
||||
"#,
|
||||
",
|
||||
status: EXIT_FAILURE,
|
||||
}
|
||||
|
||||
test! {
|
||||
name: empty_attribute,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
# This is a doc comment
|
||||
[]
|
||||
hello:
|
||||
@exit 100
|
||||
"#,
|
||||
stderr: r#"
|
||||
",
|
||||
stderr: r"
|
||||
error: Expected identifier, but found ']'
|
||||
——▶ justfile:2:2
|
||||
│
|
||||
2 │ []
|
||||
│ ^
|
||||
"#,
|
||||
",
|
||||
status: EXIT_FAILURE,
|
||||
}
|
||||
|
||||
test! {
|
||||
name: extraneous_attribute_before_comment,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
[no-exit-message]
|
||||
# This is a doc comment
|
||||
hello:
|
||||
@exit 100
|
||||
"#,
|
||||
stderr: r#"
|
||||
",
|
||||
stderr: r"
|
||||
error: Extraneous attribute
|
||||
——▶ justfile:1:1
|
||||
│
|
||||
1 │ [no-exit-message]
|
||||
│ ^
|
||||
"#,
|
||||
",
|
||||
|
||||
status: EXIT_FAILURE,
|
||||
}
|
||||
|
||||
test! {
|
||||
name: extraneous_attribute_before_empty_line,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
[no-exit-message]
|
||||
|
||||
hello:
|
||||
@exit 100
|
||||
"#,
|
||||
",
|
||||
stderr: "
|
||||
error: Extraneous attribute
|
||||
——▶ justfile:1:1
|
||||
@ -118,13 +118,13 @@ hello:
|
||||
|
||||
test! {
|
||||
name: shebang_exit_message_suppressed,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
[no-exit-message]
|
||||
hello:
|
||||
#!/usr/bin/env bash
|
||||
echo 'Hello, World!'
|
||||
exit 100
|
||||
"#,
|
||||
",
|
||||
stdout: "Hello, World!\n",
|
||||
stderr: "",
|
||||
status: 100,
|
||||
|
@ -104,12 +104,12 @@ test! {
|
||||
|
||||
test! {
|
||||
name: default_arguments,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
set positional-arguments
|
||||
|
||||
foo bar='baz':
|
||||
echo $1
|
||||
"#,
|
||||
",
|
||||
args: (),
|
||||
stdout: "baz\n",
|
||||
stderr: "echo $1\n",
|
||||
@ -130,13 +130,13 @@ test! {
|
||||
|
||||
test! {
|
||||
name: variadic_arguments_are_separate,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
set positional-arguments
|
||||
|
||||
foo *bar:
|
||||
echo $1
|
||||
echo $2
|
||||
"#,
|
||||
",
|
||||
args: ("foo", "a", "b"),
|
||||
stdout: "a\nb\n",
|
||||
stderr: "echo $1\necho $2\n",
|
||||
|
@ -2,40 +2,40 @@ use super::*;
|
||||
|
||||
test! {
|
||||
name: no_stdout,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
default:
|
||||
@echo hello
|
||||
"#,
|
||||
",
|
||||
args: ("--quiet"),
|
||||
stdout: "",
|
||||
}
|
||||
|
||||
test! {
|
||||
name: stderr,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
default:
|
||||
@echo hello 1>&2
|
||||
"#,
|
||||
",
|
||||
args: ("--quiet"),
|
||||
stdout: "",
|
||||
}
|
||||
|
||||
test! {
|
||||
name: command_echoing,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
default:
|
||||
exit
|
||||
"#,
|
||||
",
|
||||
args: ("--quiet"),
|
||||
stdout: "",
|
||||
}
|
||||
|
||||
test! {
|
||||
name: error_messages,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
default:
|
||||
exit 100
|
||||
"#,
|
||||
",
|
||||
args: ("--quiet"),
|
||||
stdout: "",
|
||||
status: 100,
|
||||
@ -43,11 +43,11 @@ default:
|
||||
|
||||
test! {
|
||||
name: assignment_backtick_stderr,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
a := `echo hello 1>&2`
|
||||
default:
|
||||
exit 100
|
||||
"#,
|
||||
",
|
||||
args: ("--quiet"),
|
||||
stdout: "",
|
||||
status: 100,
|
||||
@ -55,11 +55,11 @@ default:
|
||||
|
||||
test! {
|
||||
name: interpolation_backtick_stderr,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
default:
|
||||
echo `echo hello 1>&2`
|
||||
exit 100
|
||||
"#,
|
||||
",
|
||||
args: ("--quiet"),
|
||||
stdout: "",
|
||||
status: 100,
|
||||
|
@ -216,13 +216,13 @@ test! {
|
||||
foo a=\t`echo blaaaaaah:
|
||||
echo {{a}}
|
||||
",
|
||||
stderr: r#"
|
||||
stderr: r"
|
||||
error: Unterminated backtick
|
||||
——▶ justfile:1:8
|
||||
│
|
||||
1 │ foo a= `echo blaaaaaah:
|
||||
│ ^
|
||||
"#,
|
||||
",
|
||||
status: EXIT_FAILURE,
|
||||
}
|
||||
|
||||
@ -266,13 +266,13 @@ test! {
|
||||
foo a=\t```echo blaaaaaah:
|
||||
echo {{a}}
|
||||
",
|
||||
stderr: r#"
|
||||
stderr: r"
|
||||
error: Unterminated backtick
|
||||
——▶ justfile:1:8
|
||||
│
|
||||
1 │ foo a= ```echo blaaaaaah:
|
||||
│ ^^^
|
||||
"#,
|
||||
",
|
||||
status: EXIT_FAILURE,
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ test! {
|
||||
|
||||
test! {
|
||||
name: indented_backtick_string_contents_indentation_removed,
|
||||
justfile: r#"
|
||||
justfile: r"
|
||||
a := ```
|
||||
printf '
|
||||
foo
|
||||
@ -322,7 +322,7 @@ test! {
|
||||
|
||||
@default:
|
||||
printf '{{a}}'
|
||||
"#,
|
||||
",
|
||||
stdout: "\n\nfoo\nbar",
|
||||
}
|
||||
|
||||
|
@ -197,6 +197,14 @@ impl Test {
|
||||
impl Test {
|
||||
#[track_caller]
|
||||
pub(crate) fn run(self) -> Output {
|
||||
fn compare<T: PartialEq + Debug>(name: &str, have: T, want: T) -> bool {
|
||||
let equal = have == want;
|
||||
if !equal {
|
||||
eprintln!("Bad {name}: {}", Comparison::new(&have, &want));
|
||||
}
|
||||
equal
|
||||
}
|
||||
|
||||
if let Some(justfile) = &self.justfile {
|
||||
let justfile = unindent(justfile);
|
||||
fs::write(self.justfile_path(), justfile).unwrap();
|
||||
@ -240,27 +248,21 @@ impl Test {
|
||||
.wait_with_output()
|
||||
.expect("failed to wait for just process");
|
||||
|
||||
fn compare<T: PartialEq + Debug>(name: &str, have: T, want: T) -> bool {
|
||||
let equal = have == want;
|
||||
if !equal {
|
||||
eprintln!("Bad {name}: {}", Comparison::new(&have, &want));
|
||||
}
|
||||
equal
|
||||
}
|
||||
|
||||
let output_stdout = str::from_utf8(&output.stdout).unwrap();
|
||||
let output_stderr = str::from_utf8(&output.stderr).unwrap();
|
||||
|
||||
if let Some(ref stdout_regex) = self.stdout_regex {
|
||||
if !stdout_regex.is_match(output_stdout) {
|
||||
panic!("Stdout regex mismatch:\n{output_stdout:?}\n!~=\n/{stdout_regex:?}/");
|
||||
}
|
||||
assert!(
|
||||
stdout_regex.is_match(output_stdout),
|
||||
"Stdout regex mismatch:\n{output_stdout:?}\n!~=\n/{stdout_regex:?}/",
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(ref stderr_regex) = self.stderr_regex {
|
||||
if !stderr_regex.is_match(output_stderr) {
|
||||
panic!("Stderr regex mismatch:\n{output_stderr:?}\n!~=\n/{stderr_regex:?}/");
|
||||
}
|
||||
assert!(
|
||||
stderr_regex.is_match(output_stderr),
|
||||
"Stderr regex mismatch:\n{output_stderr:?}\n!~=\n/{stderr_regex:?}/",
|
||||
);
|
||||
}
|
||||
|
||||
if !compare("status", output.status.code(), Some(self.status))
|
||||
@ -291,9 +293,12 @@ impl Test {
|
||||
.output()
|
||||
.expect("just invocation failed");
|
||||
|
||||
if !output.status.success() {
|
||||
panic!("dump failed: {} {:?}", output.status, output);
|
||||
}
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"dump failed: {} {:?}",
|
||||
output.status,
|
||||
output,
|
||||
);
|
||||
|
||||
let dumped = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
@ -310,9 +315,7 @@ impl Test {
|
||||
.output()
|
||||
.expect("just invocation failed");
|
||||
|
||||
if !output.status.success() {
|
||||
panic!("reparse failed: {}", output.status);
|
||||
}
|
||||
assert!(output.status.success(), "reparse failed: {}", output.status);
|
||||
|
||||
let reparsed = String::from_utf8(output.stdout).unwrap();
|
||||
|
||||
|
@ -28,7 +28,7 @@ fn justfile_without_working_directory() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
let output = Command::new(executable_path("just"))
|
||||
.arg("--justfile")
|
||||
.arg(&tmp.path().join("justfile"))
|
||||
.arg(tmp.path().join("justfile"))
|
||||
.output()?;
|
||||
|
||||
if !output.status.success() {
|
||||
@ -109,9 +109,9 @@ fn justfile_and_working_directory() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
let output = Command::new(executable_path("just"))
|
||||
.arg("--justfile")
|
||||
.arg(&tmp.path().join("justfile"))
|
||||
.arg(tmp.path().join("justfile"))
|
||||
.arg("--working-directory")
|
||||
.arg(&tmp.path().join("sub"))
|
||||
.arg(tmp.path().join("sub"))
|
||||
.output()?;
|
||||
|
||||
if !output.status.success() {
|
||||
@ -166,7 +166,7 @@ fn search_dir_parent() -> Result<(), Box<dyn Error>> {
|
||||
};
|
||||
|
||||
let output = Command::new(executable_path("just"))
|
||||
.current_dir(&tmp.path().join("child"))
|
||||
.current_dir(tmp.path().join("child"))
|
||||
.arg("../")
|
||||
.output()?;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user