From 5497f4ce1552174b623dea17c9425f1d1298907d Mon Sep 17 00:00:00 2001 From: Sakthipriyan Vairamani Date: Fri, 28 Aug 2015 01:38:10 +0530 Subject: [PATCH 1/2] test: use tmpDir instead of fixturesDir This test was using fixturesDir to create temp files to test. This patch replaces that with tmpDir and uses `assert` module to test. --- test/sequential/test-regress-GH-3739.js | 45 +++++++++---------------- 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/test/sequential/test-regress-GH-3739.js b/test/sequential/test-regress-GH-3739.js index cc16b22dc44c46..aef54c3ea6c7c4 100644 --- a/test/sequential/test-regress-GH-3739.js +++ b/test/sequential/test-regress-GH-3739.js @@ -1,46 +1,31 @@ 'use strict'; -var common = require('../common'), - assert = require('assert'), - fs = require('fs'), - path = require('path'); -var dir = path.resolve(common.fixturesDir), - dirs = []; +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); + +var dir = path.resolve(common.tmpDir); + +// Make sure that the tmp directory is clean +common.refreshTmpDir(); // Make a long path. for (var i = 0; i < 50; i++) { - dir = dir + '/123456790'; + dir = dir + '/1234567890'; try { fs.mkdirSync(dir, '0777'); } catch (e) { - if (e.code == 'EEXIST') { - // Ignore; - } else { - cleanup(); + if (e.code !== 'EEXIST') { throw e; } } - dirs.push(dir); } -// Test existsSync -var r = common.fileExists(dir); -if (r !== true) { - cleanup(); - throw new Error('fs.accessSync returned false'); -} +// Test if file exists synchronously +assert(common.fileExists(dir), 'Directory is not accessible'); -// Text exists +// Test if file exists asynchronously fs.access(dir, function(err) { - cleanup(); - if (err) { - throw new Error('fs.access reported false'); - } + assert(!err, 'Directory is not accessible'); }); - -// Remove all created directories -function cleanup() { - for (var i = dirs.length - 1; i >= 0; i--) { - fs.rmdirSync(dirs[i]); - } -} From 14d0206ab656eb0f4bb44330bfcafd048a62afe7 Mon Sep 17 00:00:00 2001 From: Sakthipriyan Vairamani Date: Fri, 28 Aug 2015 03:20:11 +0530 Subject: [PATCH 2/2] Moving to parallel --- test/{sequential => parallel}/test-regress-GH-3739.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{sequential => parallel}/test-regress-GH-3739.js (100%) diff --git a/test/sequential/test-regress-GH-3739.js b/test/parallel/test-regress-GH-3739.js similarity index 100% rename from test/sequential/test-regress-GH-3739.js rename to test/parallel/test-regress-GH-3739.js