thomasjo / atom-latex

Compile LaTeX or knitr documents from within Atom
https://atom.io/packages/latex
MIT License
223 stars 42 forks source link

Fix incorrect glob pattern used to populate list of generated files. #463

Closed thomasjo closed 2 years ago

thomasjo commented 6 years ago

Bug discovered by @Doekab in #462. This bug has been around for a very long time, but somehow nobody has encountered it before now. The basis gist of the bug is as follows;

  1. Given that file.tex is a valid LaTeX document that compiles, and that the build process produces some auxiliary files, of which one is file.pdf.
  2. Rename file.pdf to file x.pdf.
  3. When executing the latex:clean command, the renamed file x.pdf is incorrectly cleaned due to the overzealous glob pattern.

The proposed fix is simply replacing the very greedy glob pattern with a slightly less greedy pattern that only does wildcard matching on file extensions. Note that strictly speaking, the proposed fix is probably still susceptible to issues with files named e.g. file.some.thing.log, but that will have to be verified and fixed at some later stage.

thomasjo commented 6 years ago

As a side note, while working on this I noticed that our clean-related tests are quite lacking, and due to the use of the mocked getGeneratedFileList implementation is likely hiding many other bugs. We should strongly reconsider how and when we're mocking crucial infrastructure. At the very least, if we want to keep the current mock, we should add several positive and negative test that only target Composer.getGeneratedFileList to ensure we're fully covering all scenarios.