From f1ae1701550f3c20e7a24336c27edcca365fa17a Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Fri, 21 Jun 2024 12:37:53 -0500 Subject: [PATCH] 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. --- printf/src/tests.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/printf/src/tests.rs b/printf/src/tests.rs index 2a57d7df1..7968c2dbe 100644 --- a/printf/src/tests.rs +++ b/printf/src/tests.rs @@ -342,6 +342,10 @@ fn test_ptr() { } #[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() { // Basic form, handling of exponent/precision for 0 assert_fmt1!("%a", 0.0, "0x0p+0"); @@ -448,6 +452,10 @@ fn test_float() { } #[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() { // correctness in DBL_DIG places assert_fmt1!("%.15g", 1.23456789012345, "1.23456789012345"); @@ -583,8 +591,12 @@ fn test_prefixes() { assert_eq!(sprintf_check!("%ls", "cs"), "cs"); } -#[allow(clippy::approx_constant)] #[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() { assert_fmt!("%*s", -10, "hello" => "hello "); assert_fmt!("%*s", -5, "world" => "world"); @@ -692,6 +704,10 @@ fn test_errors() { } #[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_printf_loc<'a>(expected: &str, locale: &Locale, format: &str, arg: impl ToArg<'a>) { let mut target = String::new();