From cf6424e8d62dcecdfbd5dfcb1c425ee0f04483e8 Mon Sep 17 00:00:00 2001 From: Innes Anderson-Morrison Date: Mon, 24 Jun 2024 07:38:13 +0100 Subject: [PATCH] updating snapshot tests to use new simple_txtar API --- Cargo.toml | 8 ++++---- tests/layout.rs | 13 +++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8968c69c..33f7364c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/tests/layout.rs b/tests/layout.rs index 13ad73ef..859bfb75 100644 --- a/tests/layout.rs +++ b/tests/layout.rs @@ -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); @@ -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(); } }