mirror of
https://github.com/YaLTeR/niri.git
synced 2025-10-06 00:23:14 +02:00
Switch from k9 to insta for snapshot testing
We'll need some advanced features from insta.
This commit is contained in:
85
Cargo.lock
generated
85
Cargo.lock
generated
@@ -714,16 +714,6 @@ version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
|
||||
[[package]]
|
||||
name = "colored"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "combine"
|
||||
version = "4.6.7"
|
||||
@@ -743,6 +733,18 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "console"
|
||||
version = "0.15.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea3c6ecd8059b57859df5c69830340ed3c41d30e3da0c1cbed90a96ac853041b"
|
||||
dependencies = [
|
||||
"encode_unicode",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "convert_case"
|
||||
version = "0.6.0"
|
||||
@@ -1018,6 +1020,12 @@ version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
|
||||
|
||||
[[package]]
|
||||
name = "encode_unicode"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
|
||||
|
||||
[[package]]
|
||||
name = "enumflags2"
|
||||
version = "0.7.10"
|
||||
@@ -1878,6 +1886,18 @@ version = "1.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd4f5b4d1c00331c5245163aacfe5f20be75b564c7112d45893d4ae038119eb0"
|
||||
|
||||
[[package]]
|
||||
name = "insta"
|
||||
version = "1.41.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e9ffc4d4892617c50a928c52b2961cb5174b6fc6ebf252b2fac9d21955c48b8"
|
||||
dependencies = [
|
||||
"console",
|
||||
"lazy_static",
|
||||
"linked-hash-map",
|
||||
"similar",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.13"
|
||||
@@ -1982,23 +2002,6 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "k9"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "088bcebb5b68b1b14b64d7f05b0f802719250b97fdc0338ec42529ea777ed614"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"colored",
|
||||
"diff",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"proc-macro2",
|
||||
"regex",
|
||||
"syn 2.0.86",
|
||||
"terminal_size 0.2.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "keyframe"
|
||||
version = "1.1.1"
|
||||
@@ -2203,6 +2206,12 @@ dependencies = [
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
version = "0.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.3.8"
|
||||
@@ -2325,7 +2334,7 @@ dependencies = [
|
||||
"supports-color",
|
||||
"supports-hyperlinks",
|
||||
"supports-unicode",
|
||||
"terminal_size 0.1.17",
|
||||
"terminal_size",
|
||||
"textwrap",
|
||||
"thiserror",
|
||||
"unicode-width",
|
||||
@@ -2409,7 +2418,7 @@ dependencies = [
|
||||
"git-version",
|
||||
"glam",
|
||||
"input",
|
||||
"k9",
|
||||
"insta",
|
||||
"keyframe",
|
||||
"libc",
|
||||
"libdisplay-info",
|
||||
@@ -2448,7 +2457,7 @@ version = "0.1.10"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"csscolorparser",
|
||||
"k9",
|
||||
"insta",
|
||||
"knuffel",
|
||||
"miette",
|
||||
"niri-ipc",
|
||||
@@ -3628,6 +3637,12 @@ version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
||||
|
||||
[[package]]
|
||||
name = "similar"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1de1d4f81173b03af4c0cbed3c898f6bff5b870e4a7f5d6f4057d62a7a4b686e"
|
||||
|
||||
[[package]]
|
||||
name = "siphasher"
|
||||
version = "0.3.11"
|
||||
@@ -3899,16 +3914,6 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "terminal_size"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237"
|
||||
dependencies = [
|
||||
"rustix 0.37.27",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.15.2"
|
||||
|
@@ -14,7 +14,7 @@ rust-version = "1.80"
|
||||
anyhow = "1.0.93"
|
||||
bitflags = "2.6.0"
|
||||
clap = { version = "4.5.20", features = ["derive"] }
|
||||
k9 = "0.12.0"
|
||||
insta = "1.41.1"
|
||||
serde = { version = "1.0.214", features = ["derive"] }
|
||||
serde_json = "1.0.132"
|
||||
tracing = { version = "0.1.40", features = ["max_level_trace", "release_max_level_debug"] }
|
||||
@@ -107,7 +107,7 @@ features = [
|
||||
|
||||
[dev-dependencies]
|
||||
approx = "0.5.1"
|
||||
k9.workspace = true
|
||||
insta.workspace = true
|
||||
proptest = "1.5.0"
|
||||
proptest-derive = { version = "0.5.0", features = ["boxed_union"] }
|
||||
xshell = "0.2.6"
|
||||
@@ -138,6 +138,10 @@ lto = "thin"
|
||||
# knuffel with chomsky generates a metric ton of debuginfo.
|
||||
debug = false
|
||||
|
||||
[profile.dev.package]
|
||||
insta.opt-level = 3
|
||||
similar.opt-level = 3
|
||||
|
||||
[package.metadata.generate-rpm]
|
||||
version = "0.1.10"
|
||||
assets = [
|
||||
|
@@ -19,6 +19,6 @@ tracing.workspace = true
|
||||
tracy-client.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
k9.workspace = true
|
||||
insta.workspace = true
|
||||
miette = { version = "5.10.0", features = ["fancy"] }
|
||||
pretty_assertions = "1.4.1"
|
||||
|
@@ -2933,7 +2933,7 @@ pub fn set_miette_hook() -> Result<(), miette::InstallError> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use k9::snapshot;
|
||||
use insta::assert_debug_snapshot;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use super::*;
|
||||
@@ -3833,9 +3833,9 @@ mod tests {
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
snapshot!(
|
||||
assert_debug_snapshot!(
|
||||
names,
|
||||
r#"
|
||||
@r#"
|
||||
[
|
||||
"Unknown A A | DP-3",
|
||||
"A Unknown A | DP-3",
|
||||
|
@@ -212,16 +212,16 @@ fn format_diagonal(diagonal_inches: f64) -> String {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use k9::snapshot;
|
||||
use insta::assert_snapshot;
|
||||
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_format_diagonal() {
|
||||
snapshot!(format_diagonal(12.11), "12.1″");
|
||||
snapshot!(format_diagonal(13.28), "13.3″");
|
||||
snapshot!(format_diagonal(15.6), "15.6″");
|
||||
snapshot!(format_diagonal(23.2), "23″");
|
||||
snapshot!(format_diagonal(24.8), "25″");
|
||||
assert_snapshot!(format_diagonal(12.11), @"12.1″");
|
||||
assert_snapshot!(format_diagonal(13.28), @"13.3″");
|
||||
assert_snapshot!(format_diagonal(15.6), @"15.6″");
|
||||
assert_snapshot!(format_diagonal(23.2), @"23″");
|
||||
assert_snapshot!(format_diagonal(24.8), @"25″");
|
||||
}
|
||||
}
|
||||
|
@@ -59,7 +59,7 @@ pub fn closest_representable_scale(scale: f64) -> f64 {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use k9::snapshot;
|
||||
use insta::assert_snapshot;
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -70,37 +70,37 @@ mod tests {
|
||||
#[test]
|
||||
fn test_guess_monitor_scale() {
|
||||
// Librem 5; not enough logical area when scaled
|
||||
snapshot!(check((65, 129), (720, 1440)), "1.5");
|
||||
assert_snapshot!(check((65, 129), (720, 1440)), @"1.5");
|
||||
// OnePlus 6
|
||||
snapshot!(check((68, 144), (1080, 2280)), "2.5");
|
||||
assert_snapshot!(check((68, 144), (1080, 2280)), @"2.5");
|
||||
// Google Pixel 6a
|
||||
snapshot!(check((64, 142), (1080, 2400)), "2.5");
|
||||
assert_snapshot!(check((64, 142), (1080, 2400)), @"2.5");
|
||||
// 13" MacBook Retina
|
||||
snapshot!(check((286, 179), (2560, 1600)), "1.75");
|
||||
assert_snapshot!(check((286, 179), (2560, 1600)), @"1.75");
|
||||
// Surface Laptop Studio
|
||||
snapshot!(check((303, 202), (2400, 1600)), "1.5");
|
||||
assert_snapshot!(check((303, 202), (2400, 1600)), @"1.5");
|
||||
// Dell XPS 9320
|
||||
snapshot!(check((290, 180), (3840, 2400)), "2.5");
|
||||
assert_snapshot!(check((290, 180), (3840, 2400)), @"2.5");
|
||||
// Lenovo ThinkPad X1 Yoga Gen 6
|
||||
snapshot!(check((300, 190), (3840, 2400)), "2.5");
|
||||
assert_snapshot!(check((300, 190), (3840, 2400)), @"2.5");
|
||||
// Generic 23" 1080p
|
||||
snapshot!(check((509, 286), (1920, 1080)), "1.0");
|
||||
assert_snapshot!(check((509, 286), (1920, 1080)), @"1");
|
||||
// Generic 23" 4K
|
||||
snapshot!(check((509, 286), (3840, 2160)), "1.75");
|
||||
assert_snapshot!(check((509, 286), (3840, 2160)), @"1.75");
|
||||
// Generic 27" 4K
|
||||
snapshot!(check((598, 336), (3840, 2160)), "1.5");
|
||||
assert_snapshot!(check((598, 336), (3840, 2160)), @"1.5");
|
||||
// Generic 32" 4K
|
||||
snapshot!(check((708, 398), (3840, 2160)), "1.25");
|
||||
assert_snapshot!(check((708, 398), (3840, 2160)), @"1.25");
|
||||
// Generic 25" 4K; ideal scale is 1.60, should round to 1.5 and 1.0
|
||||
snapshot!(check((554, 312), (3840, 2160)), "1.5");
|
||||
assert_snapshot!(check((554, 312), (3840, 2160)), @"1.5");
|
||||
// Generic 23.5" 4K; ideal scale is 1.70, should round to 1.75 and 2.0
|
||||
snapshot!(check((522, 294), (3840, 2160)), "1.75");
|
||||
assert_snapshot!(check((522, 294), (3840, 2160)), @"1.75");
|
||||
// Lenovo Legion 7 Gen 7 AMD 16"
|
||||
snapshot!(check((340, 210), (2560, 1600)), "1.5");
|
||||
assert_snapshot!(check((340, 210), (2560, 1600)), @"1.5");
|
||||
// Acer Nitro XV320QU LV 31.5"
|
||||
snapshot!(check((700, 390), (2560, 1440)), "1.0");
|
||||
assert_snapshot!(check((700, 390), (2560, 1440)), @"1");
|
||||
// Surface Pro 6
|
||||
snapshot!(check((260, 170), (2736, 1824)), "2.0");
|
||||
assert_snapshot!(check((260, 170), (2736, 1824)), @"2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -110,11 +110,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_round_scale() {
|
||||
snapshot!(closest_representable_scale(1.3), "1.3");
|
||||
snapshot!(closest_representable_scale(1.31), "1.3083333333333333");
|
||||
snapshot!(closest_representable_scale(1.32), "1.3166666666666667");
|
||||
snapshot!(closest_representable_scale(1.33), "1.3333333333333333");
|
||||
snapshot!(closest_representable_scale(1.34), "1.3416666666666666");
|
||||
snapshot!(closest_representable_scale(1.35), "1.35");
|
||||
assert_snapshot!(closest_representable_scale(1.3), @"1.3");
|
||||
assert_snapshot!(closest_representable_scale(1.31), @"1.3083333333333333");
|
||||
assert_snapshot!(closest_representable_scale(1.32), @"1.3166666666666667");
|
||||
assert_snapshot!(closest_representable_scale(1.33), @"1.3333333333333333");
|
||||
assert_snapshot!(closest_representable_scale(1.34), @"1.3416666666666666");
|
||||
assert_snapshot!(closest_representable_scale(1.35), @"1.35");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user