Send all progress logging messages to stderr (#171)

- Change logging messages to go to stderr
- Updated tests to expect these messages in stderr instead of stdout
- Changed test_markdown_rendering to no longer rely on the tldr pages repo
This commit is contained in:
Dalton 2021-05-10 02:17:13 -05:00 committed by GitHub
commit 388deac079
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 19 deletions

View file

@ -163,7 +163,7 @@ fn clear_cache(quietly: bool) {
process::exit(1);
});
if !quietly {
println!("Successfully deleted cache.");
eprintln!("Successfully deleted cache.");
}
}
@ -178,7 +178,7 @@ fn update_cache(cache: &Cache, quietly: bool) {
process::exit(1);
});
if !quietly {
println!("Successfully updated cache.");
eprintln!("Successfully updated cache.");
}
}
@ -245,7 +245,7 @@ fn show_paths() {
fn create_config_and_exit() {
match make_default_config() {
Ok(config_file_path) => {
println!(
eprintln!(
"Successfully created seed config file here: {}",
config_file_path.to_str().unwrap()
);
@ -491,9 +491,9 @@ fn main() {
process::exit(0);
} else {
if !args.flag_quiet {
println!("Page {} not found in cache", &command);
println!("Try updating with `tldr --update`, or submit a pull request to:");
println!("https://github.com/tldr-pages/tldr");
eprintln!("Page {} not found in cache", &command);
eprintln!("Try updating with `tldr --update`, or submit a pull request to:");
eprintln!("https://github.com/tldr-pages/tldr");
}
process::exit(1);
}

View file

@ -144,7 +144,7 @@ fn test_update_cache() {
.args(&["--update"])
.assert()
.success()
.stdout(contains("Successfully updated cache."));
.stderr(contains("Successfully updated cache."));
testenv.command().args(&["sl"]).assert().success();
}
@ -227,7 +227,7 @@ fn test_setup_seed_config() {
.args(&["--seed-config"])
.assert()
.success()
.stdout(contains("Successfully created seed config file"));
.stderr(contains("Successfully created seed config file here"));
}
#[test]
@ -284,12 +284,7 @@ fn test_os_specific_page() {
fn test_markdown_rendering() {
let testenv = TestEnv::new();
testenv
.command()
.args(&["--update"])
.assert()
.success()
.stdout(contains("Successfully updated cache."));
testenv.add_entry("tar", include_str!("tar-markdown.expected"));
let expected = include_str!("tar-markdown.expected");
testenv
@ -410,7 +405,7 @@ fn test_spaces_find_command() {
.args(&["--update"])
.assert()
.success()
.stdout(contains("Successfully updated cache."));
.stderr(contains("Successfully updated cache."));
testenv
.command()
@ -428,7 +423,7 @@ fn test_pager_flag_enable() {
.args(&["--update"])
.assert()
.success()
.stdout(contains("Successfully updated cache."));
.stderr(contains("Successfully updated cache."));
testenv
.command()
@ -497,9 +492,9 @@ fn test_autoupdate_cache() {
let assert = testenv.command().args(&["--list"]).assert().success();
let pred = contains("Successfully updated cache");
if expected {
assert.stdout(pred)
assert.stderr(pred)
} else {
assert.stdout(pred.not())
assert.stderr(pred.not())
};
};
@ -618,7 +613,7 @@ fn test_pager_warning() {
.args(&["--update"])
.assert()
.success()
.stdout(contains("Successfully updated cache."));
.stderr(contains("Successfully updated cache."));
// Regular call should not show a "pager flag not available on windows" warning
testenv