Skip to content

Commit

Permalink
updating snapshot tests to use new simple_txtar API
Browse files Browse the repository at this point in the history
  • Loading branch information
sminez committed Jun 24, 2024
1 parent c9ecbcf commit cf6424e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ x11rb = { version = "0.13", features = ["randr"], optional = true }

[dev-dependencies]
penrose_ui = { path = "crates/penrose_ui" }
serde_json = "1"
simple_test_case = "1"
pretty_assertions = "1.4.0"
quickcheck = "1"
quickcheck_macros = "1"
serde_json = "1"
simple_test_case = "1"
simple_txtar = "1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
simple_txtar = "0.1.0"
pretty_assertions = "1.4.0"
13 changes: 9 additions & 4 deletions tests/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use penrose::{
pure::{geometry::Rect, Stack},
};
use simple_test_case::dir_cases;
use simple_txtar::Archive;
use simple_txtar::{Archive, Builder};
use std::fs;

const R_SCREEN: Rect = Rect::new(0, 0, 1920, 1200);
Expand Down Expand Up @@ -49,14 +49,19 @@ fn stringified_positions(layout: &str, n: usize) -> String {
#[ignore = "un-ignore to update test data"]
fn update_snapshot_data() {
for layout in LAYOUTS {
let mut archive = format!("-- layout --\n{layout}\n");
let mut archive = Builder::new();
archive.file(("layout", layout));

for n in 1..=MAX_CLIENTS {
let expected = stringified_positions(layout, n);
archive.push_str(&format!("-- {n} --\n{expected}"));
archive.file((n.to_string(), expected));
}

fs::write(format!("tests/data/layout/snapshots/{layout}"), archive).unwrap();
fs::write(
format!("tests/data/layout/snapshots/{layout}"),
archive.build().to_string(),
)
.unwrap();
}
}

Expand Down

0 comments on commit cf6424e

Please sign in to comment.