Skip to content

Commit 4632fe9

Browse files
committed
refactor(fixtures): Move to snapbox with SVGs
1 parent e9b445c commit 4632fe9

28 files changed

+868
-227
lines changed

Cargo.lock

+403-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,22 @@ anstyle = "1.0.4"
2828
unicode-width = "0.1.11"
2929

3030
[dev-dependencies]
31+
annotate-snippets = { path = ".", features = ["testing-colors"] }
3132
criterion = "0.5.1"
3233
difference = "2.0.0"
3334
glob = "0.3.1"
3435
serde = { version = "1.0.197", features = ["derive"] }
36+
snapbox = { version = "0.5.8", features = ["diff", "harness", "path", "term-svg"] }
3537
toml = "0.5.11"
3638

3739
[[bench]]
3840
name = "simple"
3941
harness = false
4042

43+
[[test]]
44+
name = "fixtures"
45+
harness = false
46+
4147
[features]
4248
default = []
4349
testing-colors = []

tests/diff/mod.rs

-63
This file was deleted.
File renamed without changes.

tests/fixtures/main.rs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
mod deserialize;
2+
3+
use crate::deserialize::Fixture;
4+
use annotate_snippets::{Renderer, Snippet};
5+
use snapbox::data::DataFormat;
6+
use snapbox::Data;
7+
use std::error::Error;
8+
9+
fn main() {
10+
snapbox::harness::Harness::new("tests/fixtures/", setup, test)
11+
.select(["*/*.toml"])
12+
.action_env("SNAPSHOTS")
13+
.test();
14+
}
15+
16+
fn setup(input_path: std::path::PathBuf) -> snapbox::harness::Case {
17+
let name = input_path.file_name().unwrap().to_str().unwrap().to_owned();
18+
let expected = input_path.with_extension("svg");
19+
snapbox::harness::Case {
20+
name,
21+
fixture: input_path,
22+
expected,
23+
}
24+
}
25+
26+
fn test(input_path: &std::path::Path) -> Result<Data, Box<dyn Error>> {
27+
let src = std::fs::read_to_string(input_path)?;
28+
let (renderer, snippet): (Renderer, Snippet<'_>) =
29+
toml::from_str(&src).map(|a: Fixture| (a.renderer.into(), a.snippet.into()))?;
30+
let actual = renderer.render(snippet).to_string();
31+
Ok(Data::from(actual).coerce_to(DataFormat::TermSvg))
32+
}

tests/fixtures/no-color/issue_52.svg

+35
Loading

tests/fixtures/no-color/issue_52.txt

-7
This file was deleted.

tests/fixtures/no-color/issue_9.svg

+45
Loading

tests/fixtures/no-color/issue_9.txt

-12
This file was deleted.
Loading

tests/fixtures/no-color/multiline_annotation.txt

-14
This file was deleted.
Loading

tests/fixtures/no-color/multiline_annotation2.txt

-9
This file was deleted.
Loading

tests/fixtures/no-color/multiline_annotation3.txt

-9
This file was deleted.

0 commit comments

Comments
 (0)