Browse Source

Remove /tmp assumption from runtests.js

Use 'tmp' package for auto-deleting temporary filenames.  This should be
portable to e.g. Windows.
pull/368/head
Sami Vaarala 9 years ago
parent
commit
9d13222e6d
  1. 6
      runtests/package.json
  2. 12
      runtests/runtests.js

6
runtests/package.json

@ -7,12 +7,12 @@
"email": "sami.vaarala@iki.fi" "email": "sami.vaarala@iki.fi"
}, },
"dependencies": { "dependencies": {
"optimist": "~0.3.5", "MD5": "~1.0.0",
"async": "~0.2.4", "async": "~0.2.4",
"optimist": "~0.3.5",
"tmp": "0.0.27",
"xml2js": "~0.2.4", "xml2js": "~0.2.4",
"MD5": "~1.0.0",
"yamljs": "~0.2.1" "yamljs": "~0.2.1"
}, },
"main": "runtests.js" "main": "runtests.js"
} }

12
runtests/runtests.js

@ -8,7 +8,7 @@
var fs = require('fs'), var fs = require('fs'),
path = require('path'), path = require('path'),
// temp = require('temp'), tmp = require('tmp'),
child_process = require('child_process'), child_process = require('child_process'),
async = require('async'), async = require('async'),
xml2js = require('xml2js'), xml2js = require('xml2js'),
@ -33,12 +33,12 @@ var knownIssues;
* Utils. * Utils.
*/ */
// FIXME: placeholder; for some reason 'temp' didn't work // Generate temporary filename, file will be autodeleted on exit unless
var tmpCount = 0; // deleted explicitly. See: https://www.npmjs.com/package/tmp
var tmpUniq = process.pid || Math.floor(Math.random() * 1e6);
function mkTempName(ext) { function mkTempName(ext) {
return '/tmp/runtests-' + tmpUniq + '-' + (++tmpCount) + (ext !== undefined ? ext : ''); var fn = tmp.tmpNameSync({ keep: false, prefix: 'tmp-runtests-' });
console.log('mkTempName -> ' + fn);
return fn;
} }
function safeUnlinkSync(filePath) { function safeUnlinkSync(filePath) {

Loading…
Cancel
Save