p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

[p5.js 2.0 Bug Report]: IO loadTable test failed

Open madhav2348 opened this issue 6 months ago • 6 comments

Most appropriate sub-area of p5.js?

  • [ ] Accessibility
  • [ ] Color
  • [ ] Core/Environment/Rendering
  • [ ] Data
  • [ ] DOM
  • [ ] Events
  • [ ] Image
  • [ ] IO
  • [ ] Math
  • [ ] Typography
  • [ ] Utilities
  • [ ] WebGL
  • [ ] Build process
  • [x] Unit testing
  • [ ] Internationalization
  • [ ] Friendly errors
  • [ ] Other (specify if possible)

p5.js version

No response

Web browser and version

No response

Operating system

Windows

Steps to reproduce this

Steps:

  1. run command npm test

Snippet:


CSV files should handle escaped quotes and returns within quoted fields
AssertionError: expected 'David,\r\nSr. "the boss"' to equal 'David,\nSr. "the boss"'
 - /test/unit/io/loadTable.js:87:12
- Expected
+ Received

- David,
+ David,

  Sr. "the boss"

madhav2348 avatar May 31 '25 08:05 madhav2348

Hi @madhav2348 , Thanks so much for reporting this. Btw, I am unable to reproduce this issue in the dev-2.0 branch. Can you just confirm if it fails with the latest build of p5.js in dev-2.0 branch?

perminder-17 avatar Jun 02 '25 01:06 perminder-17

Hi @perminder-17,I’ve also tried running the tests on the latest dev-2.0 branch and I am not able to reproduce this issue either. @madhav2348 can you provide a more detailed explanation and steps to reproduce the problem.

VANSH3104 avatar Jun 03 '25 15:06 VANSH3104

I'm sure it's dev-2.0 branch. I install npm packages using npm ci and before starting any changes, I run npm test, where I sometimes test timeout happen in in WebGL which is mention it #7869 and another test failed in visual test #7823 . With the following test fail


 FAIL |unit|  test/unit/io/loadTable.js > loadTable > CSV files should handle escaped quotes and returns within quoted fields
AssertionError: expected 'David,\r\nSr. "the boss"' to equal 'David,\nSr. "the boss"'

- Expected
+ Received

- David,
+ David,
  Sr. "the boss"

 ❯ test/unit/io/loadTable.js:87:12
     85|     const table = await mockP5Prototype.loadTable(validFile);
     86|     assert.equal(table.getRowCount(), 4);
     87|     assert.equal(table.getRow(3).get(0), 'David,\nSr. "the boss"');
       |            ^
     88|   });
     89| });

Image

madhav2348 avatar Jun 04 '25 00:06 madhav2348

Thanks for the update @madhav2348 and also thanks for raising this one.

CC: @davepagurek , Is this test a flaky test? Since when I ran on my syste (ubuntu-latest) the test for loadTable didn't failed.

Image

Do you have any ideas?

perminder-17 avatar Jun 04 '25 01:06 perminder-17

Since my system is Windows, it may vary on OS. If not able to reproduce the error, then let me know to close it, or you could, because only my system is generating it
Thankyou

madhav2348 avatar Jun 04 '25 01:06 madhav2348

It seems the difference is around line ending where windows parse new line as \r\n while unix parse as \n. @perminder-17 Not sure if you are testing on Windows? If it is indeed line ending error, it can possibly be fixed either in the test with regex testing for both line endings, or force line endings in loadTable()'s implementation to always parse as \n.

limzykenneth avatar Jun 09 '25 12:06 limzykenneth

Also ran into this when making a PR on windows.

While the tests ended up completing successfully in CI/CD, it could be very confusing to a first time contributor, especially with how contribution guidelines stress the importance of checking that tests complete successfully.

nking07049925 avatar Jul 09 '25 16:07 nking07049925

If this test is loading a file, then I think git checks out files using platform-local line endings unless specified otherwise. We specify line endings for some formats here: https://github.com/processing/p5.js/blob/8760fba4f69931c2a1f83fc05f30b151e0add538/.gitattributes#L6-L7

Maybe we need to do the same for the format of the file being loaded?

(edit: also maybe for .mjs since we have some of those too)

davepagurek avatar Jul 09 '25 17:07 davepagurek