Open GrygrFlzr opened 5 months ago
Never seen this [wrt Highlight.js] in all my years of maintainer-ship (on Mac OS X). That said an indiscriminate filter would be fine. It would also need to be applied to the checkAutoDetect.js
script... a PR would be welcome.
I usually put .DS_Store in my .gitignore file and delete all the files in the repo. They won't come back
Edit: It's already in the .gitignore folder, so deleting the files will be fine if they are there.
Would anyone here like to pick up this issue and build a fix?
Summary macOS occasionally generates
.DS_Store
files to store metadata about a directory for its builtin Finder application. Unfortunately, this can sometimes happen in atest/detect
directory and generate erroneous detect test cases. Once the file exists, it's pretty hard to permanently remove it, as macOS will almost instantly regenerate the file if it is manually removed byrm -f .DS_Store
or by other means.Reproduction Steps Unfortunately, I cannot seem to reliably trigger the heuristic that generates the .DS_Store file, so instead one can emulate the behavior by doing the following:
highlight.js
repositoryecho '[hello]' > test/detect/1c/.DS_Store
from the repository rootnode ./tools/build.js -t node
npm run test
AssertionError: .DS_Store should be detected as 1c, but was angelscript
Expected behavior Since the user has little control over
.DS_Store
files, skip.DS_Store
files when iterating through the directory here: https://github.com/highlightjs/highlight.js/blob/e964bec6c8d72d263042ab37ae196baa79f49c47/test/detect/index.js#L20-L22Additional context There are several ways to approach the problem: __1. Indiscriminately skip all
.DS_Store
files__This is the easiest to implement, effectively hardcoding a blocklist of
.DS_Store
files. If someone decided to make a language that used the.DS_Store
extension, they can still just name the detect test file something liketestcase.txt
, since the current test runner does not care about file extensions.__2. Only skip all
.DS_Store
files on macOS__This does not skip
.DS_Store
on other platforms. You could also optimize it into a one-time check for other platforms:The main drawback is that it technically causes inconsistent behavior between platforms (where the test only ignores the file on macOS), so the indiscriminate block suggested in (1) may be preferable.
3. Do nothing This kinda sucks but since nobody reported this before I guess it's not a very common issue.