Llvm-lit temporary files already exist (original) (raw)
I made a lit test and added this starting command:
; RUN: ls -l %t*
I saw that there are a lot of temporary files that match the %t prefix from previous runs. Is there a reason that llvm-lit does not automatically remove temporary files before running test commands?
Endill June 7, 2024, 4:39pm 2
I was wondering if llvm-lit could be modified so that all files starting with %t can be automatically deleted before executing commands in the testcase. My reasoning is that no testcase should require a pre-existing temporary file, and it is better for llvm-lit to do the deletion than for all or many testcases to add code to do the deletion.
I want this change because I mistakenly thought a testcase I was developing was passing, but it was only passing due to a leftover temporary file from a previous run.
To me, that seems more like an exception:
$ grep -rn "rm -f" llvm/test/ | wc -l
346
$ grep -rn "rm -f" clang/test/ | wc -l
137
And there are way more than a few hundred tests in the codebase:
$ grep -rn "\-o %t" ../llvm/test/ | wc -l
7682
$ grep -rn "\-o %t" ../clang/test/ | wc -l
6953
jh7370 June 10, 2024, 7:56am 5
Whilst I completely sympathize with your situation, deleting files takes time, which is not ideal for fast iterating on tests (admittedly, I haven’t attempted to measure how long) - note that CI will pick up the case, since it does a clean test cycle as I understand it, so it shouldn’t result in a (long-term) breakage in tree (ideally pre-commit CI will pick it up, but that assumes the test is actually run by one of the pre-commit configurations).
If it doesn’t already exist, I’d support this as a configurable option in lit at least. If performance concerns aren’t significant, I’d consider it being on by default, but I think we’d need to get some measurements first before it was enabled automatically.
Endill June 10, 2024, 8:58am 6
You should grep for rm -rf %t
as well. I see 1362 hits in Clang.