diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:03:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:03:36 +0000 |
commit | 17d40c6057c88f4c432b0d7bac88e1b84cb7e67f (patch) | |
tree | 3f66c4a5918660bb8a758ab6cda5ff8ee4f6cdcd /vendor/annotate-snippets-0.8.0/tests/fixtures_test.rs | |
parent | Adding upstream version 1.64.0+dfsg1. (diff) | |
download | rustc-upstream/1.65.0+dfsg1.tar.xz rustc-upstream/1.65.0+dfsg1.zip |
Adding upstream version 1.65.0+dfsg1.upstream/1.65.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | vendor/annotate-snippets-0.8.0/tests/fixtures_test.rs | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/vendor/annotate-snippets-0.8.0/tests/fixtures_test.rs b/vendor/annotate-snippets-0.8.0/tests/fixtures_test.rs deleted file mode 100644 index e471521f2..000000000 --- a/vendor/annotate-snippets-0.8.0/tests/fixtures_test.rs +++ /dev/null @@ -1,45 +0,0 @@ -mod diff; -mod snippet; - -use crate::snippet::SnippetDef; -use annotate_snippets::{display_list::DisplayList, snippet::Snippet}; -use glob::glob; -use std::{error::Error, fs::File, io, io::prelude::*}; - -fn read_file(path: &str) -> Result<String, io::Error> { - let mut f = File::open(path)?; - let mut s = String::new(); - (f.read_to_string(&mut s))?; - Ok(s.trim_end().to_string()) -} - -fn read_fixture<'de>(src: &'de str) -> Result<Snippet<'de>, Box<dyn Error>> { - Ok(toml::from_str(src).map(|a: SnippetDef| a.into())?) -} - -#[test] -fn test_fixtures() { - for entry in glob("./tests/fixtures/no-color/**/*.toml").expect("Failed to read glob pattern") { - let p = entry.expect("Error while getting an entry"); - - let path_in = p.to_str().expect("Can't print path"); - let path_out = path_in.replace(".toml", ".txt"); - - let src = read_file(&path_in).expect("Failed to read file"); - let snippet = read_fixture(&src).expect("Failed to read file"); - let expected_out = read_file(&path_out).expect("Failed to read file"); - - let dl = DisplayList::from(snippet); - let actual_out = dl.to_string(); - println!("{}", expected_out); - println!("{}", actual_out.trim_end()); - - assert_eq!( - expected_out, - actual_out.trim_end(), - "\n\n\nWhile parsing: {}\nThe diff is:\n\n\n{}\n\n\n", - path_in, - diff::get_diff(expected_out.as_str(), actual_out.as_str()) - ); - } -} |