printf: Ignore some floating point tests under i586

A few specific tests fail under i586 due to its inherent floating point
inaccuracy issues (rust-lang/rust#114479), so ignore these tests if certain
are met.

We have specific integration tests elsewhere in fish to check that even under
i586 we get mostly sane results, so this is OK. I tried to modify the assert
macros to check for a loose string match (up to one character difference) or an
f64 abs diff of less than epsilon, but it was a lot of code with little value
and increased the friction to contributing to the tests. Also, let's just
acknowledge the fact that all of i686, let alone i586 specifically, is a dead
end and not worth investing such time and effort into so long as it more or less
"works".

Closes #10474.
This commit is contained in:
Mahmoud Al-Qudsi 2024-06-21 12:37:53 -05:00
parent 7d1942a023
commit f1ae170155

View File

@ -342,6 +342,10 @@ fn test_ptr() {
} }
#[test] #[test]
#[cfg_attr(
all(target_arch = "x86", not(target_feature = "sse2")),
ignore = "i586 has inherent accuracy issues, see rust-lang/rust#114479"
)]
fn test_float() { fn test_float() {
// Basic form, handling of exponent/precision for 0 // Basic form, handling of exponent/precision for 0
assert_fmt1!("%a", 0.0, "0x0p+0"); assert_fmt1!("%a", 0.0, "0x0p+0");
@ -448,6 +452,10 @@ fn test_float() {
} }
#[test] #[test]
#[cfg_attr(
all(target_arch = "x86", not(target_feature = "sse2")),
ignore = "i586 has inherent accuracy issues, see rust-lang/rust#114479"
)]
fn test_float_g() { fn test_float_g() {
// correctness in DBL_DIG places // correctness in DBL_DIG places
assert_fmt1!("%.15g", 1.23456789012345, "1.23456789012345"); assert_fmt1!("%.15g", 1.23456789012345, "1.23456789012345");
@ -583,8 +591,12 @@ fn test_prefixes() {
assert_eq!(sprintf_check!("%ls", "cs"), "cs"); assert_eq!(sprintf_check!("%ls", "cs"), "cs");
} }
#[allow(clippy::approx_constant)]
#[test] #[test]
#[cfg_attr(
all(target_arch = "x86", not(target_feature = "sse2")),
ignore = "i586 has inherent accuracy issues, see rust-lang/rust#114479"
)]
#[allow(clippy::approx_constant)]
fn negative_precision_width() { fn negative_precision_width() {
assert_fmt!("%*s", -10, "hello" => "hello "); assert_fmt!("%*s", -10, "hello" => "hello ");
assert_fmt!("%*s", -5, "world" => "world"); assert_fmt!("%*s", -5, "world" => "world");
@ -692,6 +704,10 @@ fn test_errors() {
} }
#[test] #[test]
#[cfg_attr(
all(target_arch = "x86", not(target_feature = "sse2")),
ignore = "i586 has inherent accuracy issues, see rust-lang/rust#114479"
)]
fn test_locale() { fn test_locale() {
fn test_printf_loc<'a>(expected: &str, locale: &Locale, format: &str, arg: impl ToArg<'a>) { fn test_printf_loc<'a>(expected: &str, locale: &Locale, format: &str, arg: impl ToArg<'a>) {
let mut target = String::new(); let mut target = String::new();