highlightjs / highlight.js

JavaScript syntax highlighter with language auto-detection and zero dependencies.
https://highlightjs.org/
BSD 3-Clause "New" or "Revised" License
23.3k stars 3.52k forks source link

Fix markup tests not executing correctly on Windows #3969

Closed nixxquality closed 5 months ago

nixxquality commented 5 months ago

I was trying to make a pull request for a separate issue but I noticed that the markup tests aren't executed on my Windows machine.

Following the test files, I found an issue with the usage of glob. Per their documentation:

Note Glob patterns should always use / as a path separator, even on Windows systems, as \ is used to escape glob characters. If you wish to use \ as a path separator instead of using it as an escape character on Windows platforms, you may set windowsPathsNoEscape:true in the options. In this mode, special glob characters cannot be escaped, making it impossible to match a literal * ? and so on in filenames.

This is not the case in the test executor. https://github.com/highlightjs/highlight.js/blob/200c09c30c5b8fc1afe62388024f66019052b73a/test/markup/index.js#L15-L19 On Windows, filePath ends up something like ...\Code\highlight.js\test\markup\erlang\*.expect.txt, which means that the * gets escaped.

Adding the recommended option solves the problem, as expected, and because we're not trying to match any literals * or ? this shouldn't cause any other issues.

github-actions[bot] commented 5 months ago

Build Size Report

Changes to minified artifacts in /build, after gzip compression.

3 files changed

Total change +9 B

View Changes | file | base | pr | diff | | --- | --- | --- | --- | | es/core.min.js | 8.17 KB | 8.17 KB | +3 B | | es/highlight.min.js | 8.17 KB | 8.17 KB | +3 B | | highlight.min.js | 8.2 KB | 8.21 KB | +3 B |