[llvm-lit] remove %t files before running a test
Tzafrir Poupko
tzafrir11 at gmail.com
Tue May 19 03:16:48 PDT 2015
ping
Following James review, I'm attaching the original patch again.
Can someone with commit access commit this?
Tzafrir
On Thu, May 14, 2015 at 8:00 PM, Tzafrir Poupko <tzafrir11 at gmail.com> wrote:
> Hi,
>
> I think the original was clearer as well.
> Could you commit it for me please? I don't have commit access.
> Should I send it again?
>
> Tzafrir
> On May 14, 2015 6:20 PM, "James Molloy" <james at jamesmolloy.co.uk> wrote:
>
>> Hi,
>>
>> OK, your original patch was clearer. I'd prefer to go with that.
>>
>> Cheers,
>>
>> James
>>
>> On Thu, 14 May 2015 at 15:34 Tzafrir Poupko <tzafrir11 at gmail.com> wrote:
>>
>>> Hi James,
>>>
>>> As far as I can tell rmtree() does not support removing symbolic links
>>> or matching files by pattern.
>>> Since i would like to support removal of patterns such as %t , %t.txt
>>> and %t/filename I don't see how rmtree is useful by itself
>>>
>>> Attached another patch option implementing the file scanning in python
>>> instead of calling rm -rf
>>>
>>> On Thu, May 14, 2015 at 4:00 PM, James Molloy <james at jamesmolloy.co.uk>
>>> wrote:
>>>
>>>> Hi Tzafrir,
>>>>
>>>> In which case, just using shutil.rmtree() should be sufficient:
>>>> https://docs.python.org/2/library/shutil.html#shutil.rmtree
>>>>
>>>> Cheers,
>>>>
>>>> James
>>>>
>>>> On Thu, 14 May 2015 at 13:57 Tzafrir Poupko <tzafrir11 at gmail.com>
>>>> wrote:
>>>>
>>>>> Hi James,
>>>>>
>>>>> There are 2 reasons for the -f
>>>>>
>>>>> 1. This is what is done currently by more then 300 tests and I
>>>>> wouldn't like to change this.
>>>>> 2. Using -f suppresses error messages that will happen when no
>>>>> temporary file exists
>>>>>
>>>>> Since there is no standard function in python to delete files and
>>>>> directories matching a pattern
>>>>> I thought using rm -rf would be a better solution then implementing my
>>>>> own.
>>>>>
>>>>> Tzafrir
>>>>>
>>>>> On Thu, May 14, 2015 at 3:27 PM, James Molloy <james at jamesmolloy.co.uk
>>>>> > wrote:
>>>>>
>>>>>> Hi Tzafrir,
>>>>>>
>>>>>> This sounds like a good idea to me.
>>>>>>
>>>>>> + subprocess.call(['rm','-rf',path+"*"])
>>>>>>
>>>>>>
>>>>>>
>>>>>> This is super dangerous. Why the -f ?
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> James
>>>>>>
>>>>>> On Thu, 14 May 2015 at 13:22 Tzafrir Poupko <tzafrir11 at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Before running a test, purge all %t files used by previous tests.
>>>>>>> Remove any custom file used in test which was prefixed by %t.
>>>>>>> There are over 300 clang tests that run "rm -rf %t" as first run
>>>>>>> command, this patch will make it automaticlly.
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> llvm-commits mailing list
>>>>>>> llvm-commits at cs.uiuc.edu
>>>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>>>>>
>>>>>>
>>>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150519/9217e8f0/attachment.html>
-------------- next part --------------
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index f4f72b2..8a52b7e 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -520,6 +520,8 @@ def _runShTest(test, litConfig, useExternalSh,
script, tmpBase, execdir):
# Create the output directory if it does not already exist.
lit.util.mkdir_p(os.path.dirname(tmpBase))
+ # Remove all temporary files relevant to this test if any exists
+ lit.util.purge(tmpBase + '.tmp')
if useExternalSh:
res = executeScript(test, litConfig, tmpBase, script, execdir)
diff --git a/llvm/utils/lit/lit/util.py b/llvm/utils/lit/lit/util.py
index 08f7b71..efbdfa1 100644
--- a/llvm/utils/lit/lit/util.py
+++ b/llvm/utils/lit/lit/util.py
@@ -60,6 +60,11 @@ def mkdir_p(path):
if e.errno != errno.EEXIST:
raise
+def purge(path):
+ """purge(path) - Remove all files and folders starting with this path
+ prefix"""
+ subprocess.call(['rm','-rf',path+"*"])
+
def capture(args, env=None):
"""capture(command) - Run the given command (or argv list) in a shell and
return the standard output."""
More information about the llvm-commits
mailing list