The intent of this script is to hunt down all
"*/testResults/*.xml" files and touch them, so that our build system doesn't issue errors that the files are too old (it's entirely intentional that tests are only re-run when the libraries they change have been modified)
import fnmatch import os import time matches =  # Find all xml files (1) for root, dirnames, filenames in os.walk('.'): for filename in fnmatch.filter(filenames, '*.xml'): matches.append(os.path.join(root, filename)) # filter to only the ones in a "/testResults/" folder (2) tests = [k for k in matches if "\\testResults\\" in k] t = time.time() # touch them for test in tests: os.utime(test,(t,t))
Is there a simpler way to achieve this? Specifically to perform steps (1) and (2) in a single process, rather than having to filter the matches array? An alternative solution would be to just recursively find all folders called "/testResults/" and list the files within them.
This script would also find "blah/testResults/blah2/result.xml" - I'm not worried about that, as the testResults folders will only contain test result xml files (but not all xml files are test results!)
This runs on Windows.