[PATCH] D34732: Clean temp directories before running lit

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 18:50:59 PDT 2017


zturner added a comment.

In https://reviews.llvm.org/D34732#793239, @hfinkel wrote:

> > More sinister is that leaked files from previous runs can lead to false positives in tests.
>
> I've also seen this problem; thanks for working on a fix.
>
> Does this always remove the entire Output directory if you're only running a subset of the tests?


No, I actually tried to be smart about it.  The following pseudocode describes the algorithm used

  paths = list(unique_set(<all output paths>))
  sort(paths, by number of components in path ascending)
  for (path in paths) {
    if exists(path)
      rmtree(path)
    mkdir(path)
  }

the unique'ifying is because you have have `A/foo.test` and `A/bar.test` which are both in `A`.  Sorting by number of components in path is because otherwise you might do something like

  rmtree("foo/bar")
  mkdir("foo/bar")
  rmtree("foo")
  mkdir("foo")

and then `foo/bar` is gone too.  So we rmtree the highest level folder that must be rmtree'd first, and we only ever remove trees that are necessary to remove based on the subset of tests you're running.


https://reviews.llvm.org/D34732





More information about the llvm-commits mailing list