test: rewrite doc test

Line numbering has changed in Rust 1.71 in the doc tests, due to an
extra inserted `#[allow(unused_extern_crates)]` line.

Don't test for the exact line number anymore.

Signed-off-by: Harald Hoyer <harald@hoyer.xyz>
This commit is contained in:
Harald Hoyer 2023-07-27 13:28:15 +02:00
parent 376e133836
commit 95c5a02d50
Signed by: harald
GPG key ID: 900F3C4971086004

View file

@ -60,17 +60,16 @@
//! fn main() {
//! if let Err(e) = process_config_file() {
//! eprintln!("Error:\n{:?}", e);
//! # assert_eq!(
//! # format!("{:?}\n", e),
//! # "\
//! # src/lib.rs:16:51: read the config file\n\
//! # Caused by:\n\
//! # src/lib.rs:9:47: Reading file: \"foo.txt\"\n\
//! # Caused by:\n\
//! # Os { code: 2, kind: NotFound, message: \"No such file or directory\" }\n\
//! # ",
//! # );
//! # let s = format!("{:?}", e);
//! # let lines = s.lines().collect::<Vec<_>>();
//! # assert_eq!(lines.len(), 5);
//! # assert!(lines[0].starts_with("src/lib.rs:"));
//! # assert_eq!(lines[1], "Caused by:");
//! # assert!(lines[2].starts_with("src/lib.rs:"));
//! # assert_eq!(lines[3], "Caused by:");
//! # assert_eq!(lines[4], "Os { code: 2, kind: NotFound, message: \"No such file or directory\" }");
//! }
//! # else { panic!(); }
//! }
//! ```
//!