Only print fallback message when verbose (#1510)

This commit is contained in:
Casey Rodarmor 2023-01-13 13:36:52 -08:00 committed by GitHub
parent 7aff35a37b
commit 3b989ae955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 33 deletions

View File

@ -116,7 +116,7 @@ impl Subcommand {
}, },
Err(err) => return Err(err.into()), Err(err) => return Err(err.into()),
Ok(search) => { Ok(search) => {
if config.verbosity.loud() && path != starting_path { if config.verbosity.loquacious() && path != starting_path {
eprintln!( eprintln!(
"Trying {}", "Trying {}",
starting_path starting_path

View File

@ -35,7 +35,34 @@ fn fallback_from_subdir_message() {
), ),
) )
.args(["sub/bar"]) .args(["sub/bar"])
.stderr(path("Trying ../justfile\necho bar\n")) .stderr(path("echo bar\n"))
.stdout("bar\n")
.run();
}
#[test]
fn fallback_from_subdir_verbose_message() {
Test::new()
.justfile("bar:\n echo bar")
.write(
"sub/justfile",
unindent(
"
set fallback
@foo:
echo foo
",
),
)
.args(["--verbose", "sub/bar"])
.stderr(path(
"
Trying ../justfile
===> Running recipe `bar`...
echo bar
",
))
.stdout("bar\n") .stdout("bar\n")
.run(); .run();
} }
@ -61,13 +88,11 @@ fn runs_recipe_in_parent_if_not_found_in_current() {
) )
.args(["foo"]) .args(["foo"])
.current_dir("bar") .current_dir("bar")
.stderr(format!( .stderr(
" "
Trying ..{}justfile
echo root echo root
", ",
MAIN_SEPARATOR )
))
.stdout("root\n") .stdout("root\n")
.run(); .run();
} }
@ -93,13 +118,11 @@ fn setting_accepts_value() {
) )
.args(["foo"]) .args(["foo"])
.current_dir("bar") .current_dir("bar")
.stderr(format!( .stderr(
" "
Trying ..{}justfile
echo root echo root
", ",
MAIN_SEPARATOR )
))
.stdout("root\n") .stdout("root\n")
.run(); .run();
} }
@ -120,16 +143,14 @@ fn print_error_from_parent_if_recipe_not_found_in_current() {
.justfile("foo:\n echo {{bar}}") .justfile("foo:\n echo {{bar}}")
.args(["foo"]) .args(["foo"])
.current_dir("bar") .current_dir("bar")
.stderr(format!( .stderr(
" "
Trying ..{}justfile
error: Variable `bar` not defined error: Variable `bar` not defined
| |
2 | echo {{{{bar}}}} 2 | echo {{bar}}
| ^^^ | ^^^
", ",
MAIN_SEPARATOR )
))
.status(EXIT_FAILURE) .status(EXIT_FAILURE)
.run(); .run();
} }
@ -179,13 +200,11 @@ fn works_with_provided_search_directory() {
) )
.args(["./foo"]) .args(["./foo"])
.stdout("root\n") .stdout("root\n")
.stderr(format!( .stderr(
" "
Trying ..{}justfile
echo root echo root
", ",
MAIN_SEPARATOR )
))
.current_dir("bar") .current_dir("bar")
.run(); .run();
} }
@ -260,13 +279,11 @@ fn prints_correct_error_message_when_recipe_not_found() {
.args(["foo"]) .args(["foo"])
.current_dir("bar") .current_dir("bar")
.status(EXIT_FAILURE) .status(EXIT_FAILURE)
.stderr(format!( .stderr(
" "
Trying ..{}justfile
error: Justfile does not contain recipe `foo`. error: Justfile does not contain recipe `foo`.
", ",
MAIN_SEPARATOR, )
))
.run(); .run();
} }
@ -300,14 +317,11 @@ fn multiple_levels_of_fallback_work() {
.args(["baz"]) .args(["baz"])
.current_dir("a/b") .current_dir("a/b")
.stdout("root\n") .stdout("root\n")
.stderr(format!( .stderr(
" "
Trying ..{}justfile
Trying ..{}..{}justfile
echo root echo root
", ",
MAIN_SEPARATOR, MAIN_SEPARATOR, MAIN_SEPARATOR )
))
.run(); .run();
} }
@ -338,14 +352,12 @@ fn stop_fallback_when_fallback_is_false() {
) )
.args(["baz"]) .args(["baz"])
.current_dir("a/b") .current_dir("a/b")
.stderr(format!( .stderr(
" "
Trying ..{}justfile
error: Justfile does not contain recipe `baz`. error: Justfile does not contain recipe `baz`.
Did you mean `bar`? Did you mean `bar`?
", ",
MAIN_SEPARATOR )
))
.status(EXIT_FAILURE) .status(EXIT_FAILURE)
.run(); .run();
} }

View File

@ -20,7 +20,7 @@ pub(crate) use {
fs, fs,
io::Write, io::Write,
iter, iter,
path::{Path, PathBuf, MAIN_SEPARATOR}, path::{Path, PathBuf},
process::{Command, Stdio}, process::{Command, Stdio},
str, str,
}, },