From a53aa8657f84a0452ab167332d9292c50d252c4d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 07 2019 14:41:35 +0000 Subject: Fix runtests.py so it works in containers Basically in a container we want to mount the results directory so the test results are exported outside of the container. This means, the results directory cannot be deleted or created from inside the container. So if we can delete it, let's just remove all the files it contains so we start fresh. Signed-off-by: Pierre-Yves Chibon --- diff --git a/runtests.py b/runtests.py index cb55090..74a9e13 100755 --- a/runtests.py +++ b/runtests.py @@ -293,9 +293,17 @@ def do_run(args): ) return 1 else: - shutil.rmtree(args.results) - - os.mkdir(args.results) + try: + shutil.rmtree(args.results) + os.mkdir(args.results) + except: + print( + "Could not delete the %s directory, it will be " + "wiped clean" % args.results) + for content in os.listdir(args.results): + os.remove(content) + else: + os.mkdir(args.results) print("Pre-flight checks passed")