dsa-ou / allowed

Check if a program only uses a subset of the Python language.
https://dsa-ou.github.io/allowed/
BSD 3-Clause "New" or "Revised" License
10 stars 6 forks source link

Testing script prints "\n" as literal, not escape character #31

Closed densnow closed 9 months ago

densnow commented 10 months ago

The echo commands in tests.sh currently print the "\n" characters as literals on Linux e.g.

sample.py\n---
\nsample.py -m\n---
\nsample.ipynb\n---
\nsample.ipynb -m\n---

I believe we just need to use the -e flag with echo to fix this e.g

echo -e "sample.py\n---"
jurassic-squid commented 10 months ago

@densnow I can fix this on my open pull request if you like? If not, I had planned on working on the tests as my next issue, so could fix it after current changes have been merged.

densnow commented 10 months ago

@jurassic-squid It might be better to fix this when working on the tests if they are going to be changed soon anyway.

I have just been reading that the -e flag for echo is not POSIX compliant, so might not work on Mac and is probably not the best choice for this anyway. Out of interest what OS are you on, and is this error occurring for you?

jurassic-squid commented 10 months ago

Yes, I'm getting the same issue. I'm using a WSL environment (Ubuntu). printf may give more consistent output across platforms.

I had hoped to use pytest for the 'upgraded' test suite, but of course that is up to everyone else. If we do that then we won't need to worry.

densnow commented 10 months ago

Ok thanks. We'll just leave for now and close the issue when the testing is changed.

mwermelinger commented 10 months ago

Getting the same behaviour on macOS. Strange, why did it work before?