diff options
author | Dan Liew <daniel.liew@imperial.ac.uk> | 2014-05-11 16:20:02 +0100 |
---|---|---|
committer | Dan Liew <daniel.liew@imperial.ac.uk> | 2014-05-11 16:20:02 +0100 |
commit | cd11f6d30926112f8171c0af1601d80c0e414292 (patch) | |
tree | 8e3d95e609a5517a48056df3811f11566143f87f /Test | |
parent | ace1c44ae9db1c21b6a6945ed1fd34d8c0340f47 (diff) |
Added script for cleaning up temporary files created by both the lit
and legacy (batch file) testing infrastructures. This unfortunately
is required if switching between infrastructures because both systems
create a file named "Output". However for lit it is a directory and
for the legacy system this is a simple text file.
Diffstat (limited to 'Test')
-rwxr-xr-x | Test/clean.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Test/clean.py b/Test/clean.py new file mode 100755 index 00000000..37166b61 --- /dev/null +++ b/Test/clean.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +""" +This is a convenient script to delete temporary files created by the lit and +legacy testing infrastructure. Both systems use the same name for Output +unfortunately so this script needs to be run before switching to the other +infrastructure. +""" +import logging +import os +import shutil +import sys + +_name = 'Output' + +def main(): + logging.basicConfig(level=logging.INFO) + root = os.path.abspath(os.path.dirname(__file__)) + logging.info('Cleaning "{}"'.format(root)) + count = 0 + + for (dirpath, dirnames, filenames) in os.walk(root): + rmpath = os.path.join(dirpath, _name) + if _name in dirnames: + logging.info('Deleting lit temporary directory "{}"'.format(rmpath)) + shutil.rmtree(rmpath) + count += 1 + elif _name in filenames: + logging.info('Deleting batch testing output file "{}"'.format(os.path.join(dirpath, _name))) + os.remove(rmpath) + count += 1 + + logging.info('\n\nDONE: Removed {}'.format(count)) + +if __name__ == '__main__': + sys.exit(main()) |