[p5.js 2.0 Bug Report]: IO loadTable test failed
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:
- 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"
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?
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.
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| });
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.
Do you have any ideas?
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
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.
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.
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)