Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 027c95b

Browse files
authored
Merge pull request #86 from Muscraft/use-snapbox-for-testing
refactor(fixtures): Move to snapbox with SVGs
2 parents e9b445c + ad80183 commit 027c95b

28 files changed

+867
-227
lines changed

‎Cargo.lock‎

Lines changed: 402 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,17 @@ criterion = "0.5.1"
3232
difference = "2.0.0"
3333
glob = "0.3.1"
3434
serde = { version = "1.0.197", features = ["derive"] }
35+
snapbox = { version = "0.5.8", features = ["diff", "harness", "path", "term-svg"] }
3536
toml = "0.5.11"
3637

3738
[[bench]]
3839
name = "simple"
3940
harness = false
4041

42+
[[test]]
43+
name = "fixtures"
44+
harness = false
45+
4146
[features]
4247
default = []
4348
testing-colors = []

‎tests/diff/mod.rs‎

Lines changed: 0 additions & 63 deletions
This file was deleted.
File renamed without changes.

‎tests/fixtures/main.rs‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
#[cfg(not(windows))]
11+
snapbox::harness::Harness::new("tests/fixtures/", setup, test)
12+
.select(["*/*.toml"])
13+
.action_env("SNAPSHOTS")
14+
.test();
15+
}
16+
17+
fn setup(input_path: std::path::PathBuf) -> snapbox::harness::Case {
18+
let name = input_path.file_name().unwrap().to_str().unwrap().to_owned();
19+
let expected = input_path.with_extension("svg");
20+
snapbox::harness::Case {
21+
name,
22+
fixture: input_path,
23+
expected,
24+
}
25+
}
26+
27+
fn test(input_path: &std::path::Path) -> Result<Data, Box<dyn Error>> {
28+
let src = std::fs::read_to_string(input_path)?;
29+
let (renderer, snippet): (Renderer, Snippet<'_>) =
30+
toml::from_str(&src).map(|a: Fixture| (a.renderer.into(), a.snippet.into()))?;
31+
let actual = renderer.render(snippet).to_string();
32+
Ok(Data::from(actual).coerce_to(DataFormat::TermSvg))
33+
}

‎tests/fixtures/no-color/issue_52.svg‎

Lines changed: 35 additions & 0 deletions
Loading[フレーム]

‎tests/fixtures/no-color/issue_52.txt‎

Lines changed: 0 additions & 7 deletions
This file was deleted.

‎tests/fixtures/no-color/issue_9.svg‎

Lines changed: 45 additions & 0 deletions
Loading[フレーム]

‎tests/fixtures/no-color/issue_9.txt‎

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /