From 2d114213227717cdd0f5db006c5fb700e8eb9502 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 6 Apr 2016 22:28:11 -0700 Subject: [PATCH 1/3] tools: remove unneeded temp directory handling The handling of temp directory creation happens in common.js now so there is no need to test the creation of the temp directory in test.py. --- tools/test.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tools/test.py b/tools/test.py index 3cd2778930c8ab..22382d1c7a7773 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1562,15 +1562,8 @@ def Main(): for rule in globally_unused_rules: print "Rule for '%s' was not used." % '/'.join([str(s) for s in rule.path]) - tempdir = os.environ.get('NODE_TEST_DIR') or options.temp_dir - if tempdir: - try: - os.makedirs(tempdir) - os.environ['NODE_TEST_DIR'] = tempdir - except OSError as exception: - if exception.errno != errno.EEXIST: - print "Could not create the temporary directory", options.temp_dir - sys.exit(1) + if not os.environ.get('NODE_TEST_DIR') and options.temp_dir: + os.environ['NODE_TEST_DIR'] = options.temp_dir if options.report: PrintReport(all_cases) From 911097570bb025a17ff11aaaefa8f93ebbae45e9 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 7 Apr 2016 21:31:55 -0700 Subject: [PATCH 2/3] fixup: add mkdirp --- test/common.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test/common.js b/test/common.js index 6fb357ba2586a2..ab98732ded13c7 100644 --- a/test/common.js +++ b/test/common.js @@ -71,9 +71,35 @@ function rmdirSync(p, originalEr) { } } +function mkdirp(p, made) { + if (!made) + made = null; + + try { + fs.mkdirSync(p); + made = made || p; + } catch (err0) { + if (err0.code === 'ENOENT') { + made = mkdirp(path.dirname(p), made); + mkdirp(p, made); + return made; + } + + var stat; + try { + stat = fs.statSync(p); + } catch (err1) { + throw err0; + } + if (!stat.isDirectory()) + throw err0; + } + return made; +} + exports.refreshTmpDir = function() { rimrafSync(exports.tmpDir); - fs.mkdirSync(exports.tmpDir); + mkdirp(exports.tmpDir); }; if (process.env.TEST_THREAD_ID) { From 8e71f8ef562a85a0bba1888c3d67381b75229d74 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 7 Apr 2016 21:34:43 -0700 Subject: [PATCH 3/3] fixup: mkdirp() -> mkdirpSync() --- test/common.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/common.js b/test/common.js index ab98732ded13c7..b1e950e1bc7c97 100644 --- a/test/common.js +++ b/test/common.js @@ -71,7 +71,7 @@ function rmdirSync(p, originalEr) { } } -function mkdirp(p, made) { +function mkdirpSync(p, made) { if (!made) made = null; @@ -80,8 +80,8 @@ function mkdirp(p, made) { made = made || p; } catch (err0) { if (err0.code === 'ENOENT') { - made = mkdirp(path.dirname(p), made); - mkdirp(p, made); + made = mkdirpSync(path.dirname(p), made); + mkdirpSync(p, made); return made; } @@ -99,7 +99,7 @@ function mkdirp(p, made) { exports.refreshTmpDir = function() { rimrafSync(exports.tmpDir); - mkdirp(exports.tmpDir); + mkdirpSync(exports.tmpDir); }; if (process.env.TEST_THREAD_ID) {