Use similar to diff expected and actual output in filetests (#4282)
This commit is contained in:
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -561,6 +561,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"memmap2",
|
"memmap2",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
|
"similar",
|
||||||
"target-lexicon",
|
"target-lexicon",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
@@ -2599,6 +2600,12 @@ dependencies = [
|
|||||||
"rand_core 0.6.3",
|
"rand_core 0.6.3",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "similar"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2e24979f63a11545f5f2c60141afe249d4f19f84581ea2138065e400941d83d3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slice-group-by"
|
name = "slice-group-by"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
|||||||
@@ -25,3 +25,4 @@ num_cpus = "1.8.0"
|
|||||||
target-lexicon = "0.12"
|
target-lexicon = "0.12"
|
||||||
thiserror = "1.0.15"
|
thiserror = "1.0.15"
|
||||||
anyhow = "1.0.32"
|
anyhow = "1.0.32"
|
||||||
|
similar = "2.1.0"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ use cranelift_codegen::binemit::CodeInfo;
|
|||||||
use cranelift_codegen::ir;
|
use cranelift_codegen::ir;
|
||||||
use cranelift_reader::{TestCommand, TestOption};
|
use cranelift_reader::{TestCommand, TestOption};
|
||||||
use log::info;
|
use log::info;
|
||||||
|
use similar::TextDiff;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
@@ -102,17 +103,15 @@ fn check_precise_output(text: &str, context: &Context) -> Result<()> {
|
|||||||
"compilation of function on line {} does not match\n\
|
"compilation of function on line {} does not match\n\
|
||||||
the text expectation\n\
|
the text expectation\n\
|
||||||
\n\
|
\n\
|
||||||
expected:\n\
|
{}\n\
|
||||||
{:#?}\n\
|
|
||||||
actual:\n\
|
|
||||||
{:#?}\n\
|
|
||||||
\n\
|
\n\
|
||||||
This test assertion can be automatically updated by setting the\n\
|
This test assertion can be automatically updated by setting the\n\
|
||||||
CRANELIFT_TEST_BLESS=1 environment variable when running this test.
|
CRANELIFT_TEST_BLESS=1 environment variable when running this test.
|
||||||
",
|
",
|
||||||
context.details.location.line_number,
|
context.details.location.line_number,
|
||||||
expected,
|
TextDiff::from_slices(&expected, &actual)
|
||||||
actual,
|
.unified_diff()
|
||||||
|
.header("expected", "actual")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user