Bug 1480879 - Report errors creating directory (other than File exists), r=jonco
authorSteve Fink <sfink@mozilla.com>
Thu, 02 Aug 2018 13:01:02 -0700
changeset 489830 3a02fd73f28641c2150ebe8d8e4529769e871b96
parent 489829 47d9c24f99d74b69396b503ba00b36e15dd9ef3c
child 489831 4ddc76989782be51553a2fb904c7c6284908fa72
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersjonco
bugs1480879
milestone64.0a1
Bug 1480879 - Report errors creating directory (other than File exists), r=jonco
js/src/devtools/rootAnalysis/run-test.py
--- a/js/src/devtools/rootAnalysis/run-test.py
+++ b/js/src/devtools/rootAnalysis/run-test.py
@@ -71,31 +71,34 @@ if not cfg.sixgill_plugin:
 
 subprocess.check_call([cfg.js, '-e', 'if (!getBuildConfiguration()["has-ctypes"]) quit(1)'])
 
 
 def binpath(prog):
     return os.path.join(cfg.sixgill_bin, prog)
 
 
-outroot = os.path.join(testdir, 'out')
+def make_dir(dirname, exist_ok=True):
+    try:
+        os.mkdir(dirname)
+    except OSError as e:
+        if exist_ok and e.strerror == 'File exists':
+            pass
+        else:
+            raise
 
-try:
-    os.mkdir(outroot)
-except OSError:
-    pass
+
+outroot = os.path.join(testdir, 'out')
+make_dir(outroot)
 
 for name in cfg.tests:
     name = os.path.basename(name)
     indir = os.path.join(testdir, name)
     outdir = os.path.join(outroot, name)
-    try:
-        os.mkdir(outdir)
-    except OSError:
-        pass
+    make_dir(outdir)
 
     test = Test(indir, outdir, cfg, verbose=cfg.verbose)
 
     os.chdir(outdir)
     for xdb in glob("*.xdb"):
         os.unlink(xdb)
     if cfg.verbose:
         print("Running test %s" % name)