Browse Source

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 <pingou@pingoured.fr>
Pierre-Yves Chibon 5 years ago
parent
commit
a53aa8657f
1 changed files with 11 additions and 3 deletions
  1. 11 3
      runtests.py

+ 11 - 3
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")