cargo test fails for hello1 and hello2 cases in 02_echor
Issue Description:
When running cargo test for the hello1 and hello2 cases in the 02_echor code, the tests fail with the following error:
---- hello2 stdout ----
thread 'hello2' panicked at 'Unexpected stdout, failed diff original var
├── original: Hello there
├── diff:
└── var as str: Hello there
thread 'hello1' panicked at 'Unexpected stdout, failed diff original var
├── original: Hello there
├── diff:
└── var as str: Hello there
I've been improving the test output by using "pretty_assertions::assert_eq". Switch to one of the "clap_v4*" branches and use those tests. Note you will need to update Cargo.toml to use this crate.
If youre using a windows device and it happend while following the chapter (of an older version of the book) you could edit print!("{}{}", text.join(" "), if omit_newline { "" } else { "\n" }); and change it to print!("{}{}", text.join(" "), if omit_newline { "" } else { "\r\n" }); within the main function. That sorted it out for me while following the chapter.
In case someone else runs into this issue, I have the version of the book that follows clap v2 and using a mac, I was running into the same issue but realized my mistake. I traced it back to the code in src/main.rs. Instead of print!(...), I mistyped println!(...), causing an additional \n character to be added to the standard output.