From 388deac0794dcbaa0ceddc69d95e2208a6316466 Mon Sep 17 00:00:00 2001 From: Dalton Date: Mon, 10 May 2021 02:17:13 -0500 Subject: [PATCH] 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 --- src/main.rs | 12 ++++++------ tests/lib.rs | 21 ++++++++------------- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2a92f7a..67b6421 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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); } diff --git a/tests/lib.rs b/tests/lib.rs index b80b84f..831478f 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -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