lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
28.84k stars 1.29k forks source link

ppc64le: A test (Image metadata) fails but only sometimes #4169

Closed sumitd2 closed 1 month ago

sumitd2 commented 1 month ago

I am building and testing the latest tagged version of sharp on IBM Power (ppc64le). This is the output of npm test:

  1191 passing (15s)
  6 pending
  1 failing

  1) Image metadata
       transform to invalid ICC profile emits warning:

      AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected

+ 'Invalid profile'
- 'read gave 2 warnings'
      + expected - actual

      -Invalid profile
      +read gave 2 warnings

      at Context.<anonymous> (test/unit/metadata.js:625:12)

Is this test known to be flaky? Can you help me debug it? Thank you.

lovell commented 1 month ago

Yes, this test inspects the emitted warning message, which is a known source of flakiness.

https://github.com/lovell/sharp/blob/10c6f474d9293325b07017148832bb1ccf1cdde0/test/unit/metadata.js#L644-L647

libvips treats warnings more like a log rather than linking them to a particular image. sharp tries to improve this a little bit with a mutex, but you might still get the "wrong" warning when tests are run in parallel.

https://github.com/lovell/sharp/blob/10c6f474d9293325b07017148832bb1ccf1cdde0/src/common.cc#L743-L745

To make things a bit less flaky, perhaps the test could store all of the warnings received and verify at least one of them matches the expected message?

sumitd2 commented 1 month ago

@lovell Thanks for the confirmation. You can close it from my side.

lovell commented 1 month ago

Hopefully made a bit less flaky by commit https://github.com/lovell/sharp/commit/f7ed9b7fb6a884bce4faacbbb46150d600eb4fff