Modify tests for more deterministic behavior (#1081)

* Modified tests to use insta's assert_yaml_snapshot

* Sort maps to have a deterministic behaviour

---------

Co-authored-by: Luni-4 <luni-4@hotmail.it>
This commit is contained in:
Michael 2024-01-08 15:16:40 +01:00 коммит произвёл GitHub
Родитель 56f182ac57
Коммит 64e146f6d3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 14 добавлений и 15 удалений

Просмотреть файл

@ -38,7 +38,7 @@ tree-sitter-mozcpp = { path = "./tree-sitter-mozcpp", version = "=0.20.2" }
tree-sitter-mozjs = { path = "./tree-sitter-mozjs", version = "=0.20.1" }
[dev-dependencies]
insta = { version = "1.29.0", features = ["yaml", "json"] }
insta = { version = "1.29.0", features = ["yaml", "json", "redactions"] }
pretty_assertions = "^1.3"
[profile.dev.package.insta]

Просмотреть файл

@ -44,21 +44,20 @@ fn act_on_file(path: PathBuf, cfg: &Config) -> std::io::Result<()> {
.join(path.strip_prefix(Path::new(REPO)).unwrap())
.parent()
.unwrap(),
prepend_module_to_snapshot => false
prepend_module_to_snapshot => false,
sort_maps => true,
}, {
// Redact away the name since paths are different on windows.
let value = format!(
"{:#.3?}",
FuncSpace {
name: None,
..funcspace_struct
}
);
insta::assert_snapshot!(
insta::assert_yaml_snapshot!(
path.file_name().unwrap().to_string_lossy().as_ref(),
value,
"funcspace_struct"
funcspace_struct,
{
// Round floating point values to three decimal places since the can differ from
// system to system.
".spaces[].**.metrics.*.*" => insta::rounded_redaction(3),
".metrics.*.*" => insta::rounded_redaction(3),
// Redact away the name since paths are different on different systems.
".name" => "[filepath]",
}
);
});

@ -1 +1 @@
Subproject commit 1da112c4d2487e8e0f53fa7781006f13ac6ff0ea
Subproject commit bb3c007765985ef5f4c4c585465f5ffd8e16e877