Skip to content

Commit

Permalink
using insta for snapshot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
amitu committed Oct 24, 2024
1 parent bd14a97 commit 7577d38
Show file tree
Hide file tree
Showing 16 changed files with 176 additions and 490 deletions.
95 changes: 69 additions & 26 deletions v0.5/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions v0.5/fastn-p1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ logos.workspace = true
lalrpop-util.workspace = true

[dev-dependencies]
itertools.workspace = true
serde_json.workspace = true
insta = { version = "1.38", features = ["yaml", "glob"] }

[build-dependencies]
lalrpop.workspace = true
lalrpop.workspace = true

[profile.dev.package]
insta.opt-level = 3
similar.opt-level = 3
31 changes: 22 additions & 9 deletions v0.5/fastn-p1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ mod lexer;
pub mod parse_v2;
mod parser_v3;
mod section;
#[cfg(test)]
mod test;
mod token;

use lalrpop_util::lalrpop_mod;
Expand Down Expand Up @@ -156,11 +154,26 @@ pub enum SingleError {
// HeaderNotFound,
}

// #[test]
fn grammar_test() {
let input = "-- foo bar():";
let lexer = fastn_p1::lexer::Lexer::new(input);
let parser = fastn_p1::grammar::SectionParser::new();
let ast = parser.parse(input, lexer).unwrap();
dbg!(ast);
#[cfg(test)]
mod test {
// #[test]
fn grammar_test() {
let input = "-- foo bar():";
let lexer = fastn_p1::lexer::Lexer::new(input);
let parser = fastn_p1::grammar::SectionParser::new();
let ast = parser.parse(input, lexer).unwrap();
dbg!(ast);
}

#[test]
fn test_parse_output() {
insta::glob!("..", "t/*.ftd", |path| {
let s = {
let mut s = std::fs::read_to_string(&path).unwrap();
s.push('\n');
s
};
insta::assert_yaml_snapshot!(fastn_p1::ParseOutput::new("foo", &s));
})
}
}
1 change: 1 addition & 0 deletions v0.5/fastn-p1/src/snapshots/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.snap linguist-generated
24 changes: 24 additions & 0 deletions v0.5/fastn-p1/src/snapshots/[email protected]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions v0.5/fastn-p1/src/snapshots/[email protected]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions v0.5/fastn-p1/src/snapshots/[email protected]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions v0.5/fastn-p1/src/snapshots/[email protected]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 0 additions & 62 deletions v0.5/fastn-p1/src/test/mod.rs

This file was deleted.

Loading

0 comments on commit 7577d38

Please sign in to comment.