aboutsummaryrefslogtreecommitdiff
path: root/node_modules/tmp/test
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-27 17:36:13 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-27 17:36:13 +0200
commit5f466137ad6ac596600e3ff53c9b786815398445 (patch)
treef914c221874f0b16bf3def7ac01d59d1a99a3b0b /node_modules/tmp/test
parentc9f5ac8e763eda19aa0564179300cfff76785435 (diff)
node_modules, clean up package.json
Diffstat (limited to 'node_modules/tmp/test')
-rw-r--r--node_modules/tmp/test/base.js149
-rw-r--r--node_modules/tmp/test/dir-sync-test.js230
-rw-r--r--node_modules/tmp/test/dir-test.js225
-rw-r--r--node_modules/tmp/test/file-sync-test.js190
-rw-r--r--node_modules/tmp/test/file-test.js191
-rw-r--r--node_modules/tmp/test/graceful-sync.js20
-rw-r--r--node_modules/tmp/test/graceful.js15
-rw-r--r--node_modules/tmp/test/issue62-sync.js27
-rw-r--r--node_modules/tmp/test/issue62.js27
-rw-r--r--node_modules/tmp/test/keep-sync.js12
-rw-r--r--node_modules/tmp/test/keep.js11
-rw-r--r--node_modules/tmp/test/name-test.js82
-rw-r--r--node_modules/tmp/test/spawn-sync.js32
-rw-r--r--node_modules/tmp/test/spawn.js32
-rw-r--r--node_modules/tmp/test/symlinkme/file.js0
-rw-r--r--node_modules/tmp/test/unsafe-sync.js30
-rw-r--r--node_modules/tmp/test/unsafe.js30
17 files changed, 0 insertions, 1303 deletions
diff --git a/node_modules/tmp/test/base.js b/node_modules/tmp/test/base.js
deleted file mode 100644
index a77f3a566..000000000
--- a/node_modules/tmp/test/base.js
+++ /dev/null
@@ -1,149 +0,0 @@
-var
- assert = require('assert'),
- path = require('path'),
- exec = require('child_process').exec,
- tmp = require('../lib/tmp');
-
-// make sure that we do not test spam the global tmp
-tmp.TMP_DIR = './tmp';
-
-
-function _spawnTestWithError(testFile, params, cb) {
- _spawnTest(true, testFile, params, cb);
-}
-
-function _spawnTestWithoutError(testFile, params, cb) {
- _spawnTest(false, testFile, params, cb);
-}
-
-function _spawnTest(passError, testFile, params, cb) {
- var
- node_path = process.argv[0],
- command = [ node_path, path.join(__dirname, testFile) ].concat(params).join(' ');
-
- exec(command, function _execDone(err, stdout, stderr) {
- if (passError) {
- if (err) {
- return cb(err);
- } else if (stderr.length > 0) {
- return cb(stderr.toString());
- }
- }
-
- return cb(null, stdout.toString());
- });
-}
-
-function _testStat(stat, mode) {
- assert.equal(stat.uid, process.getuid(), 'should have the same UID');
- assert.equal(stat.gid, process.getgid(), 'should have the same GUID');
- assert.equal(stat.mode, mode);
-}
-
-function _testPrefix(prefix) {
- return function _testPrefixGenerated(err, name) {
- assert.equal(path.basename(name).slice(0, prefix.length), prefix, 'should have the provided prefix');
- };
-}
-
-function _testPrefixSync(prefix) {
- return function _testPrefixGeneratedSync(result) {
- if (result instanceof Error) {
- throw result;
- }
- _testPrefix(prefix)(null, result.name, result.fd);
- };
-}
-
-function _testPostfix(postfix) {
- return function _testPostfixGenerated(err, name) {
- assert.equal(name.slice(name.length - postfix.length, name.length), postfix, 'should have the provided postfix');
- };
-}
-
-function _testPostfixSync(postfix) {
- return function _testPostfixGeneratedSync(result) {
- if (result instanceof Error) {
- throw result;
- }
- _testPostfix(postfix)(null, result.name, result.fd);
- };
-}
-
-function _testKeep(type, keep, cb) {
- _spawnTestWithError('keep.js', [ type, keep ], cb);
-}
-
-function _testKeepSync(type, keep, cb) {
- _spawnTestWithError('keep-sync.js', [ type, keep ], cb);
-}
-
-function _testGraceful(type, graceful, cb) {
- _spawnTestWithoutError('graceful.js', [ type, graceful ], cb);
-}
-
-function _testGracefulSync(type, graceful, cb) {
- _spawnTestWithoutError('graceful-sync.js', [ type, graceful ], cb);
-}
-
-function _assertName(err, name) {
- assert.isString(name);
- assert.isNotZero(name.length, 'an empty string is not a valid name');
-}
-
-function _assertNameSync(result) {
- if (result instanceof Error) {
- throw result;
- }
- var name = typeof(result) == 'string' ? result : result.name;
- _assertName(null, name);
-}
-
-function _testName(expected){
- return function _testNameGenerated(err, name) {
- assert.equal(expected, name, 'should have the provided name');
- };
-}
-
-function _testNameSync(expected){
- return function _testNameGeneratedSync(result) {
- if (result instanceof Error) {
- throw result;
- }
- _testName(expected)(null, result.name, result.fd);
- };
-}
-
-function _testUnsafeCleanup(unsafe, cb) {
- _spawnTestWithoutError('unsafe.js', [ 'dir', unsafe ], cb);
-}
-
-function _testIssue62(cb) {
- _spawnTestWithoutError('issue62.js', [], cb);
-}
-
-function _testUnsafeCleanupSync(unsafe, cb) {
- _spawnTestWithoutError('unsafe-sync.js', [ 'dir', unsafe ], cb);
-}
-
-function _testIssue62Sync(cb) {
- _spawnTestWithoutError('issue62-sync.js', [], cb);
-}
-
-module.exports.testStat = _testStat;
-module.exports.testPrefix = _testPrefix;
-module.exports.testPrefixSync = _testPrefixSync;
-module.exports.testPostfix = _testPostfix;
-module.exports.testPostfixSync = _testPostfixSync;
-module.exports.testKeep = _testKeep;
-module.exports.testKeepSync = _testKeepSync;
-module.exports.testGraceful = _testGraceful;
-module.exports.testGracefulSync = _testGracefulSync;
-module.exports.assertName = _assertName;
-module.exports.assertNameSync = _assertNameSync;
-module.exports.testName = _testName;
-module.exports.testNameSync = _testNameSync;
-module.exports.testUnsafeCleanup = _testUnsafeCleanup;
-module.exports.testIssue62 = _testIssue62;
-module.exports.testUnsafeCleanupSync = _testUnsafeCleanupSync;
-module.exports.testIssue62Sync = _testIssue62Sync;
diff --git a/node_modules/tmp/test/dir-sync-test.js b/node_modules/tmp/test/dir-sync-test.js
deleted file mode 100644
index 091a03e58..000000000
--- a/node_modules/tmp/test/dir-sync-test.js
+++ /dev/null
@@ -1,230 +0,0 @@
-var
- vows = require('vows'),
- assert = require('assert'),
-
- path = require('path'),
- fs = require('fs'),
- existsSync = fs.existsSync || path.existsSync,
-
- tmp = require('../lib/tmp.js'),
- Test = require('./base.js');
-
-
-function _testDir(mode) {
- return function _testDirGenerated(result) {
- assert.ok(existsSync(result.name), 'should exist');
-
- var stat = fs.statSync(result.name);
- assert.ok(stat.isDirectory(), 'should be a directory');
-
- Test.testStat(stat, mode);
- };
-}
-
-vows.describe('Synchronous directory creation').addBatch({
- 'when using without parameters': {
- topic: function () {
- return tmp.dirSync();
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should be a directory': _testDir(040700),
- 'should have the default prefix': Test.testPrefixSync('tmp-')
- },
-
- 'when using with prefix': {
- topic: function () {
- return tmp.dirSync({ prefix: 'something' });
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should be a directory': _testDir(040700),
- 'should have the provided prefix': Test.testPrefixSync('something')
- },
-
- 'when using with postfix': {
- topic: function () {
- return tmp.dirSync({ postfix: '.txt' });
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should be a directory': _testDir(040700),
- 'should have the provided postfix': Test.testPostfixSync('.txt')
- },
-
- 'when using template': {
- topic: function () {
- return tmp.dirSync({ template: path.join(tmp.tmpdir, 'clike-XXXXXX-postfix') });
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should be a directory': _testDir(040700),
- 'should have the provided prefix': Test.testPrefixSync('clike-'),
- 'should have the provided postfix': Test.testPostfixSync('-postfix')
- },
-
- 'when using name': {
- topic: function () {
- return tmp.dirSync({ name: 'using-name' });
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should have the provided name': Test.testNameSync(path.join(tmp.tmpdir, 'using-name')),
- 'should be a directory': function (result) {
- _testDir(040700)(result);
- result.removeCallback();
- assert.ok(!existsSync(result.name), 'Directory should be removed');
- }
- },
-
- 'when using multiple options': {
- topic: function () {
- return tmp.dirSync({ prefix: 'foo', postfix: 'bar', mode: 0750 });
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should be a directory': _testDir(040750),
- 'should have the provided prefix': Test.testPrefixSync('foo'),
- 'should have the provided postfix': Test.testPostfixSync('bar')
- },
-
- 'when using multiple options and mode': {
- topic: function () {
- return tmp.dirSync({ prefix: 'complicated', postfix: 'options', mode: 0755 });
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should be a directory': _testDir(040755),
- 'should have the provided prefix': Test.testPrefixSync('complicated'),
- 'should have the provided postfix': Test.testPostfixSync('options')
- },
-
- 'no tries': {
- topic: function () {
- try {
- return tmp.dirSync({ tries: -1 });
- }
- catch (e) {
- return e;
- }
- },
-
- 'should return with an error': function (topic) {
- assert.instanceOf(topic, Error);
- }
- },
-
- 'keep testing': {
- topic: function () {
- Test.testKeepSync('dir', '1', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a dir': function (err, name) {
- _testDir(040700)({ name: name });
- fs.rmdirSync(name);
- }
- },
-
- 'unlink testing': {
- topic: function () {
- Test.testKeepSync('dir', '0', this.callback);
- },
-
- 'should not return with error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should not exist': function (err, name) {
- assert.ok(!existsSync(name), 'Directory should be removed');
- }
- },
-
- 'non graceful testing': {
- topic: function () {
- Test.testGracefulSync('dir', '0', this.callback);
- },
-
- 'should not return with error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a dir': function (err, name) {
- _testDir(040700)({ name: name });
- fs.rmdirSync(name);
- }
- },
-
- 'graceful testing': {
- topic: function () {
- Test.testGracefulSync('dir', '1', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should not exist': function (err, name) {
- assert.ok(!existsSync(name), 'Directory should be removed');
- }
- },
-
- 'unsafeCleanup === true': {
- topic: function () {
- Test.testUnsafeCleanupSync('1', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should not exist': function (err, name) {
- assert.ok(!existsSync(name), 'Directory should be removed');
- },
- 'should remove symlinked dir': function(err, name) {
- assert.ok(
- !existsSync(name + '/symlinkme-target'),
- 'should remove target'
- );
- },
- 'should not remove contents of symlink dir': function(err, name) {
- assert.ok(
- existsSync(__dirname + '/symlinkme/file.js'),
- 'should not remove symlinked directory\'s content'
- );
- }
- },
-
- 'unsafeCleanup === true with issue62 structure': {
- topic: function () {
- Test.testIssue62Sync(this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should not exist': function (err, name) {
- assert.ok(!existsSync(name), 'Directory should be removed');
- }
- },
-
- 'unsafeCleanup === false': {
- topic: function () {
- Test.testUnsafeCleanupSync('0', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a directory': function (err, name) {
- _testDir(040700)({name:name});
- // make sure that everything gets cleaned up
- fs.unlinkSync(path.join(name, 'should-be-removed.file'));
- fs.unlinkSync(path.join(name, 'symlinkme-target'));
- fs.rmdirSync(name);
- }
- },
-
- 'remove callback': {
- topic: function () {
- return tmp.dirSync();
- },
-
- 'should return with a name': Test.assertNameSync,
- 'removeCallback should remove directory': function (result) {
- result.removeCallback();
- assert.ok(!existsSync(result.name), 'Directory should be removed');
- }
- }
-}).exportTo(module);
diff --git a/node_modules/tmp/test/dir-test.js b/node_modules/tmp/test/dir-test.js
deleted file mode 100644
index 9f2c282b3..000000000
--- a/node_modules/tmp/test/dir-test.js
+++ /dev/null
@@ -1,225 +0,0 @@
-var
- vows = require('vows'),
- assert = require('assert'),
-
- path = require('path'),
- fs = require('fs'),
- existsSync = fs.existsSync || path.existsSync,
-
- tmp = require('../lib/tmp.js'),
- Test = require('./base.js');
-
-
-function _testDir(mode) {
- return function _testDirGenerated(err, name) {
- assert.ok(existsSync(name), 'should exist');
-
- var stat = fs.statSync(name);
- assert.ok(stat.isDirectory(), 'should be a directory');
-
- Test.testStat(stat, mode);
- };
-}
-
-vows.describe('Directory creation').addBatch({
- 'when using without parameters': {
- topic: function () {
- tmp.dir(this.callback);
- },
-
- 'should be a directory': _testDir(040700),
- 'should have the default prefix': Test.testPrefix('tmp-')
- },
-
- 'when using with prefix': {
- topic: function () {
- tmp.dir({ prefix: 'something' }, this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a directory': _testDir(040700),
- 'should have the provided prefix': Test.testPrefix('something')
- },
-
- 'when using with postfix': {
- topic: function () {
- tmp.dir({ postfix: '.txt' }, this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a directory': _testDir(040700),
- 'should have the provided postfix': Test.testPostfix('.txt')
- },
-
- 'when using template': {
- topic: function () {
- tmp.dir({ template: path.join(tmp.tmpdir, 'clike-XXXXXX-postfix') }, this.callback);
- },
-
- 'should not return with error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a directory': _testDir(040700),
- 'should have the provided prefix': Test.testPrefix('clike-'),
- 'should have the provided postfix': Test.testPostfix('-postfix')
- },
-
- 'when using name': {
- topic: function () {
- tmp.dir({ name: 'using-name' }, this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a directory': _testDir(040700),
- 'should have the provided name': Test.testName(path.join(tmp.tmpdir, 'using-name'))
- },
-
- 'when using multiple options': {
- topic: function () {
- tmp.dir({ prefix: 'foo', postfix: 'bar', mode: 0750 }, this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a directory': _testDir(040750),
- 'should have the provided prefix': Test.testPrefix('foo'),
- 'should have the provided postfix': Test.testPostfix('bar')
- },
-
- 'when using multiple options and mode': {
- topic: function () {
- tmp.dir({ prefix: 'complicated', postfix: 'options', mode: 0755 }, this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a directory': _testDir(040755),
- 'should have the provided prefix': Test.testPrefix('complicated'),
- 'should have the provided postfix': Test.testPostfix('options')
- },
-
- 'no tries': {
- topic: function () {
- tmp.dir({ tries: -1 }, this.callback);
- },
-
- 'should return with an error': assert.isObject
- },
-
- 'keep testing': {
- topic: function () {
- Test.testKeep('dir', '1', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a dir': function (err, name) {
- _testDir(040700)(err, name);
- fs.rmdirSync(name);
- }
- },
-
- 'unlink testing': {
- topic: function () {
- Test.testKeep('dir', '0', this.callback);
- },
-
- 'should not return with error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should not exist': function (err, name) {
- assert.ok(!existsSync(name), 'Directory should be removed');
- }
- },
-
- 'non graceful testing': {
- topic: function () {
- Test.testGraceful('dir', '0', this.callback);
- },
-
- 'should not return with error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a dir': function (err, name) {
- _testDir(040700)(err, name);
- fs.rmdirSync(name);
- }
- },
-
- 'graceful testing': {
- topic: function () {
- Test.testGraceful('dir', '1', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should not exist': function (err, name) {
- assert.ok(!existsSync(name), 'Directory should be removed');
- }
- },
-
- 'unsafeCleanup === true': {
- topic: function () {
- Test.testUnsafeCleanup('1', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should not exist': function (err, name) {
- assert.ok(!existsSync(name), 'Directory should be removed');
- },
- 'should remove symlinked dir': function(err, name) {
- assert.ok(
- !existsSync(name + '/symlinkme-target'),
- 'should remove target'
- );
- },
- 'should not remove contents of symlink dir': function(err, name) {
- assert.ok(
- existsSync(__dirname + '/symlinkme/file.js'),
- 'should not remove symlinked directory\'s content'
- );
- }
- },
-
- 'unsafeCleanup === true with issue62 structure': {
- topic: function () {
- Test.testIssue62(this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should not exist': function (err, name) {
- assert.ok(!existsSync(name), 'Directory should be removed');
- }
- },
-
- 'unsafeCleanup === false': {
- topic: function () {
- Test.testUnsafeCleanup('0', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a directory': function (err, name) {
- _testDir(040700)(err, name);
- // make sure that everything gets cleaned up
- fs.unlinkSync(path.join(name, 'should-be-removed.file'));
- fs.unlinkSync(path.join(name, 'symlinkme-target'));
- fs.rmdirSync(name);
- }
- },
-
- 'remove callback': {
- topic: function () {
- tmp.dir(this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'removeCallback should remove directory': function (_err, name, removeCallback) {
- removeCallback();
- assert.ok(!existsSync(name), 'Directory should be removed');
- }
- }
-}).exportTo(module);
diff --git a/node_modules/tmp/test/file-sync-test.js b/node_modules/tmp/test/file-sync-test.js
deleted file mode 100644
index 44c1d22f5..000000000
--- a/node_modules/tmp/test/file-sync-test.js
+++ /dev/null
@@ -1,190 +0,0 @@
-var
- vows = require('vows'),
- assert = require('assert'),
-
- path = require('path'),
- fs = require('fs'),
- existsSync = fs.existsSync || path.existsSync,
-
- tmp = require('../lib/tmp.js'),
- Test = require('./base.js');
-
-
-function _testFile(mode, fdTest) {
- return function _testFileGenerated(result) {
- assert.ok(existsSync(result.name), 'should exist');
-
- var stat = fs.statSync(result.name);
- assert.equal(stat.size, 0, 'should have zero size');
- assert.ok(stat.isFile(), 'should be a file');
-
- Test.testStat(stat, mode);
-
- // check with fstat as well (fd checking)
- if (fdTest) {
- var fstat = fs.fstatSync(result.fd);
- assert.deepEqual(fstat, stat, 'fstat results should be the same');
-
- var data = new Buffer('something');
- assert.equal(fs.writeSync(result.fd, data, 0, data.length, 0), data.length, 'should be writable');
- assert.ok(!fs.closeSync(result.fd), 'should not return with error');
- }
- };
-}
-
-vows.describe('Synchronous file creation').addBatch({
- 'when using without parameters': {
- topic: function () {
- return tmp.fileSync();
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should be a file': _testFile(0100600, true),
- 'should have the default prefix': Test.testPrefixSync('tmp-'),
- 'should have the default postfix': Test.testPostfixSync('.tmp')
- },
-
- 'when using with prefix': {
- topic: function () {
- return tmp.fileSync({ prefix: 'something' });
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should be a file': _testFile(0100600, true),
- 'should have the provided prefix': Test.testPrefixSync('something')
- },
-
- 'when using with postfix': {
- topic: function () {
- return tmp.fileSync({ postfix: '.txt' });
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should be a file': _testFile(0100600, true),
- 'should have the provided postfix': Test.testPostfixSync('.txt')
- },
-
- 'when using template': {
- topic: function () {
- return tmp.fileSync({ template: path.join(tmp.tmpdir, 'clike-XXXXXX-postfix') });
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should be a file': _testFile(0100600, true),
- 'should have the provided prefix': Test.testPrefixSync('clike-'),
- 'should have the provided postfix': Test.testPostfixSync('-postfix')
- },
-
- 'when using name': {
- topic: function () {
- return tmp.fileSync({ name: 'using-name.tmp' });
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should have the provided name': Test.testNameSync(path.join(tmp.tmpdir, 'using-name.tmp')),
- 'should be a file': function (result) {
- _testFile(0100600, true);
- fs.unlinkSync(result.name);
- }
- },
-
- 'when using multiple options': {
- topic: function () {
- return tmp.fileSync({ prefix: 'foo', postfix: 'bar', mode: 0640 });
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should be a file': _testFile(0100640, true),
- 'should have the provided prefix': Test.testPrefixSync('foo'),
- 'should have the provided postfix': Test.testPostfixSync('bar')
- },
-
- 'when using multiple options and mode': {
- topic: function () {
- return tmp.fileSync({ prefix: 'complicated', postfix: 'options', mode: 0644 });
- },
-
- 'should return with a name': Test.assertNameSync,
- 'should be a file': _testFile(0100644, true),
- 'should have the provided prefix': Test.testPrefixSync('complicated'),
- 'should have the provided postfix': Test.testPostfixSync('options')
- },
-
- 'no tries': {
- topic: function () {
- try {
- return tmp.fileSync({ tries: -1 });
- }
- catch (e) {
- return e;
- }
- },
-
- 'should return with an error': function (topic) {
- assert.instanceOf(topic, Error);
- }
- },
-
- 'keep testing': {
- topic: function () {
- Test.testKeepSync('file', '1', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a file': function (err, name) {
- _testFile(0100600, false)({name:name});
- fs.unlinkSync(name);
- }
- },
-
- 'unlink testing': {
- topic: function () {
- Test.testKeepSync('file', '0', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should not exist': function (err, name) {
- assert.ok(!existsSync(name), 'File should be removed');
- }
- },
-
- 'non graceful testing': {
- topic: function () {
- Test.testGracefulSync('file', '0', this.callback);
- },
-
- 'should not return with error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a file': function (err, name) {
- _testFile(0100600, false)({name:name});
- fs.unlinkSync(name);
- }
- },
-
- 'graceful testing': {
- topic: function () {
- Test.testGracefulSync('file', '1', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should not exist': function (err, name) {
- assert.ok(!existsSync(name), 'File should be removed');
- }
- },
-
- 'remove callback': {
- topic: function () {
- return tmp.fileSync();
- },
-
- 'should return with a name': Test.assertNameSync,
- 'removeCallback should remove file': function (result) {
- result.removeCallback();
- assert.ok(!existsSync(result.name), 'File should be removed');
- }
- }
-
-}).exportTo(module);
diff --git a/node_modules/tmp/test/file-test.js b/node_modules/tmp/test/file-test.js
deleted file mode 100644
index b710859c0..000000000
--- a/node_modules/tmp/test/file-test.js
+++ /dev/null
@@ -1,191 +0,0 @@
-var
- vows = require('vows'),
- assert = require('assert'),
-
- path = require('path'),
- fs = require('fs'),
- existsSync = fs.existsSync || path.existsSync,
-
- tmp = require('../lib/tmp.js'),
- Test = require('./base.js');
-
-
-function _testFile(mode, fdTest) {
- return function _testFileGenerated(err, name, fd) {
- assert.ok(existsSync(name), 'should exist');
-
- var stat = fs.statSync(name);
- assert.equal(stat.size, 0, 'should have zero size');
- assert.ok(stat.isFile(), 'should be a file');
-
- Test.testStat(stat, mode);
-
- // check with fstat as well (fd checking)
- if (fdTest) {
- var fstat = fs.fstatSync(fd);
- assert.deepEqual(fstat, stat, 'fstat results should be the same');
-
- var data = new Buffer('something');
- assert.equal(fs.writeSync(fd, data, 0, data.length, 0), data.length, 'should be writable');
- assert.ok(!fs.closeSync(fd), 'should not return with error');
- }
- };
-}
-
-vows.describe('File creation').addBatch({
- 'when using without parameters': {
- topic: function () {
- tmp.file(this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a file': _testFile(0100600, true),
- 'should have the default prefix': Test.testPrefix('tmp-'),
- 'should have the default postfix': Test.testPostfix('.tmp')
- },
-
- 'when using with prefix': {
- topic: function () {
- tmp.file({ prefix: 'something' }, this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a file': _testFile(0100600, true),
- 'should have the provided prefix': Test.testPrefix('something')
- },
-
- 'when using with postfix': {
- topic: function () {
- tmp.file({ postfix: '.txt' }, this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a file': _testFile(0100600, true),
- 'should have the provided postfix': Test.testPostfix('.txt')
- },
-
- 'when using template': {
- topic: function () {
- tmp.file({ template: path.join(tmp.tmpdir, 'clike-XXXXXX-postfix') }, this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a file': _testFile(0100600, true),
- 'should have the provided prefix': Test.testPrefix('clike-'),
- 'should have the provided postfix': Test.testPostfix('-postfix')
- },
-
- 'when using name': {
- topic: function () {
- tmp.file({ name: 'using-name.tmp' }, this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should have the provided name': Test.testName(path.join(tmp.tmpdir, 'using-name.tmp')),
- 'should be a file': function (err, name) {
- _testFile(0100600, true);
- fs.unlinkSync(name);
- }
- },
-
- 'when using multiple options': {
- topic: function () {
- tmp.file({ prefix: 'foo', postfix: 'bar', mode: 0640 }, this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a file': _testFile(0100640, true),
- 'should have the provided prefix': Test.testPrefix('foo'),
- 'should have the provided postfix': Test.testPostfix('bar')
- },
-
- 'when using multiple options and mode': {
- topic: function () {
- tmp.file({ prefix: 'complicated', postfix: 'options', mode: 0644 }, this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a file': _testFile(0100644, true),
- 'should have the provided prefix': Test.testPrefix('complicated'),
- 'should have the provided postfix': Test.testPostfix('options')
- },
-
- 'no tries': {
- topic: function () {
- tmp.file({ tries: -1 }, this.callback);
- },
-
- 'should not be created': assert.isObject
- },
-
- 'keep testing': {
- topic: function () {
- Test.testKeep('file', '1', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a file': function (err, name) {
- _testFile(0100600, false)(err, name, null);
- fs.unlinkSync(name);
- }
- },
-
- 'unlink testing': {
- topic: function () {
- Test.testKeep('file', '0', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should not exist': function (err, name) {
- assert.ok(!existsSync(name), 'File should be removed');
- }
- },
-
- 'non graceful testing': {
- topic: function () {
- Test.testGraceful('file', '0', this.callback);
- },
-
- 'should not return with error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should be a file': function (err, name) {
- _testFile(0100600, false)(err, name, null);
- fs.unlinkSync(name);
- }
- },
-
- 'graceful testing': {
- topic: function () {
- Test.testGraceful('file', '1', this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'should not exist': function (err, name) {
- assert.ok(!existsSync(name), 'File should be removed');
- }
- },
-
- 'remove callback': {
- topic: function () {
- tmp.file(this.callback);
- },
-
- 'should not return with an error': assert.isNull,
- 'should return with a name': Test.assertName,
- 'removeCallback should remove file': function (_err, name, _fd, removeCallback) {
- removeCallback();
- assert.ok(!existsSync(name), 'File should be removed');
- }
- }
-
-}).exportTo(module);
diff --git a/node_modules/tmp/test/graceful-sync.js b/node_modules/tmp/test/graceful-sync.js
deleted file mode 100644
index 37766ffa6..000000000
--- a/node_modules/tmp/test/graceful-sync.js
+++ /dev/null
@@ -1,20 +0,0 @@
-var
- tmp = require('../lib/tmp'),
- spawn = require('./spawn-sync');
-
-var graceful = spawn.arg;
-
-if (graceful) {
- tmp.setGracefulCleanup();
-}
-
-try {
- var result = spawn.tmpFunction();
- spawn.out(result.name, function () {
- throw new Error('Thrown on purpose');
- });
-}
-catch (e) {
- spawn.err(e, spawn.exit);
-}
-
diff --git a/node_modules/tmp/test/graceful.js b/node_modules/tmp/test/graceful.js
deleted file mode 100644
index dbe554e1c..000000000
--- a/node_modules/tmp/test/graceful.js
+++ /dev/null
@@ -1,15 +0,0 @@
-var
- tmp = require('../lib/tmp'),
- spawn = require('./spawn');
-
-var graceful = spawn.arg;
-
-if (graceful) {
- tmp.setGracefulCleanup();
-}
-
-spawn.tmpFunction(function (err, name) {
- spawn.out(name, function () {
- throw new Error('Thrown on purpose');
- });
-});
diff --git a/node_modules/tmp/test/issue62-sync.js b/node_modules/tmp/test/issue62-sync.js
deleted file mode 100644
index 94840c66d..000000000
--- a/node_modules/tmp/test/issue62-sync.js
+++ /dev/null
@@ -1,27 +0,0 @@
-
-var
- fs = require('fs'),
- join = require('path').join,
- spawn = require('./spawn-sync');
-
-try {
- var result = spawn.tmpFunction({ unsafeCleanup: true });
- try {
- // creates structure from issue 62
- // https://github.com/raszi/node-tmp/issues/62
-
- fs.mkdirSync(join(result.name, 'issue62'));
-
- ['foo', 'bar'].forEach(function(subdir) {
- fs.mkdirSync(join(result.name, 'issue62', subdir));
- fs.writeFileSync(join(result.name, 'issue62', subdir, 'baz.txt'), '');
- });
-
- spawn.out(result.name, spawn.exit);
- } catch (e) {
- spawn.err(e.toString(), spawn.exit);
- }
-}
-catch (e) {
- spawn.err(e, spawn.exit);
-}
diff --git a/node_modules/tmp/test/issue62.js b/node_modules/tmp/test/issue62.js
deleted file mode 100644
index 004e19077..000000000
--- a/node_modules/tmp/test/issue62.js
+++ /dev/null
@@ -1,27 +0,0 @@
-var
- fs = require('fs'),
- join = require('path').join,
- spawn = require('./spawn');
-
-spawn.tmpFunction({ unsafeCleanup: true }, function (err, name) {
- if (err) {
- spawn.err(err, spawn.exit);
- return;
- }
-
- try {
- // creates structure from issue 62
- // https://github.com/raszi/node-tmp/issues/62
-
- fs.mkdirSync(join(name, 'issue62'));
-
- ['foo', 'bar'].forEach(function(subdir) {
- fs.mkdirSync(join(name, 'issue62', subdir));
- fs.writeFileSync(join(name, 'issue62', subdir, 'baz.txt'), '');
- });
-
- spawn.out(name, spawn.exit);
- } catch (e) {
- spawn.err(e.toString(), spawn.exit);
- }
-});
diff --git a/node_modules/tmp/test/keep-sync.js b/node_modules/tmp/test/keep-sync.js
deleted file mode 100644
index 6cd8b186a..000000000
--- a/node_modules/tmp/test/keep-sync.js
+++ /dev/null
@@ -1,12 +0,0 @@
-var spawn = require('./spawn-sync');
-
-var keep = spawn.arg;
-
-try {
- var result = spawn.tmpFunction({ keep: keep });
- spawn.out(result.name, spawn.exit);
-}
-catch (e) {
- spawn.err(err, spawn.exit);
-}
-
diff --git a/node_modules/tmp/test/keep.js b/node_modules/tmp/test/keep.js
deleted file mode 100644
index 9538605dd..000000000
--- a/node_modules/tmp/test/keep.js
+++ /dev/null
@@ -1,11 +0,0 @@
-var spawn = require('./spawn');
-
-var keep = spawn.arg;
-
-spawn.tmpFunction({ keep: keep }, function (err, name) {
- if (err) {
- spawn.err(err, spawn.exit);
- } else {
- spawn.out(name, spawn.exit);
- }
-});
diff --git a/node_modules/tmp/test/name-test.js b/node_modules/tmp/test/name-test.js
deleted file mode 100644
index a242c21b2..000000000
--- a/node_modules/tmp/test/name-test.js
+++ /dev/null
@@ -1,82 +0,0 @@
-var
- vows = require('vows'),
- assert = require('assert'),
-
- path = require('path'),
-
- tmp = require('../lib/tmp.js'),
- Test = require('./base.js');
-
-vows.describe('Name creation').addBatch({
- 'when using without parameters': {
- topic: function () {
- tmp.tmpName(this.callback);
- },
-
- 'should not return with error': assert.isNull,
- 'should have the default prefix': Test.testPrefix('tmp-')
- },
-
- 'when using with prefix': {
- topic: function () {
- tmp.tmpName({ prefix: 'something' }, this.callback);
- },
-
- 'should not return with error': assert.isNull,
- 'should have the provided prefix': Test.testPrefix('something')
- },
-
- 'when using with postfix': {
- topic: function () {
- tmp.tmpName({ postfix: '.txt' }, this.callback);
- },
-
- 'should not return with error': assert.isNull,
- 'should have the provided postfix': Test.testPostfix('.txt')
-
- },
-
- 'when using template': {
- topic: function () {
- tmp.tmpName({ template: path.join(tmp.tmpdir, 'clike-XXXXXX-postfix') }, this.callback);
- },
-
- 'should not return with error': assert.isNull,
- 'should have the provided prefix': Test.testPrefix('clike-'),
- 'should have the provided postfix': Test.testPostfix('-postfix'),
- 'should have template filled': function (err, name) {
- assert.isTrue(/[a-zA-Z0-9]{6}/.test(name));
- }
- },
-
- 'when using multiple options': {
- topic: function () {
- tmp.tmpName({ prefix: 'foo', postfix: 'bar', tries: 5 }, this.callback);
- },
-
- 'should not return with error': assert.isNull,
- 'should have the provided prefix': Test.testPrefix('foo'),
- 'should have the provided postfix': Test.testPostfix('bar')
- },
-
- 'no tries': {
- topic: function () {
- tmp.tmpName({ tries: -1 }, this.callback);
- },
-
- 'should fail': function (err, name) {
- assert.isObject(err);
- }
- },
-
- 'tries not numeric': {
- topic: function () {
- tmp.tmpName({ tries: 'hello'}, this.callback);
- },
-
- 'should fail': function (err, name) {
- assert.isObject(err);
- }
- }
-
-}).exportTo(module);
diff --git a/node_modules/tmp/test/spawn-sync.js b/node_modules/tmp/test/spawn-sync.js
deleted file mode 100644
index bde2db469..000000000
--- a/node_modules/tmp/test/spawn-sync.js
+++ /dev/null
@@ -1,32 +0,0 @@
-var
- fs = require('fs'),
- tmp = require('../lib/tmp');
-
-function _writeSync(stream, str, cb) {
- var flushed = stream.write(str);
- if (flushed) {
- return cb(null);
- }
-
- stream.once('drain', function _flushed() {
- cb(null);
- });
-}
-
-module.exports.out = function (str, cb) {
- _writeSync(process.stdout, str, cb);
-};
-
-module.exports.err = function (str, cb) {
- _writeSync(process.stderr, str, cb);
-};
-
-module.exports.exit = function () {
- process.exit(0);
-};
-
-var type = process.argv[2];
-module.exports.tmpFunction = (type == 'file') ? tmp.fileSync : tmp.dirSync;
-
-var arg = (process.argv[3] && parseInt(process.argv[3], 10) === 1) ? true : false;
-module.exports.arg = arg;
diff --git a/node_modules/tmp/test/spawn.js b/node_modules/tmp/test/spawn.js
deleted file mode 100644
index 6468eb39e..000000000
--- a/node_modules/tmp/test/spawn.js
+++ /dev/null
@@ -1,32 +0,0 @@
-var
- fs = require('fs'),
- tmp = require('../lib/tmp');
-
-function _writeSync(stream, str, cb) {
- var flushed = stream.write(str);
- if (flushed) {
- return cb(null);
- }
-
- stream.once('drain', function _flushed() {
- cb(null);
- });
-}
-
-module.exports.out = function (str, cb) {
- _writeSync(process.stdout, str, cb);
-};
-
-module.exports.err = function (str, cb) {
- _writeSync(process.stderr, str, cb);
-};
-
-module.exports.exit = function () {
- process.exit(0);
-};
-
-var type = process.argv[2];
-module.exports.tmpFunction = (type == 'file') ? tmp.file : tmp.dir;
-
-var arg = (process.argv[3] && parseInt(process.argv[3], 10) === 1) ? true : false;
-module.exports.arg = arg;
diff --git a/node_modules/tmp/test/symlinkme/file.js b/node_modules/tmp/test/symlinkme/file.js
deleted file mode 100644
index e69de29bb..000000000
--- a/node_modules/tmp/test/symlinkme/file.js
+++ /dev/null
diff --git a/node_modules/tmp/test/unsafe-sync.js b/node_modules/tmp/test/unsafe-sync.js
deleted file mode 100644
index 97717d05d..000000000
--- a/node_modules/tmp/test/unsafe-sync.js
+++ /dev/null
@@ -1,30 +0,0 @@
-var
- fs = require('fs'),
- join = require('path').join,
- spawn = require('./spawn-sync');
-
-var unsafe = spawn.arg;
-
-try {
- var result = spawn.tmpFunction({ unsafeCleanup: unsafe });
- try {
- // file that should be removed
- var fd = fs.openSync(join(result.name, 'should-be-removed.file'), 'w');
- fs.closeSync(fd);
-
- // in tree source
- var symlinkSource = join(__dirname, 'symlinkme');
- // testing target
- var symlinkTarget = join(result.name, 'symlinkme-target');
-
- // symlink that should be removed but the contents should be preserved.
- fs.symlinkSync(symlinkSource, symlinkTarget, 'dir');
-
- spawn.out(result.name, spawn.exit);
- } catch (e) {
- spawn.err(e.toString(), spawn.exit);
- }
-}
-catch (e) {
- spawn.err(err, spawn.exit);
-}
diff --git a/node_modules/tmp/test/unsafe.js b/node_modules/tmp/test/unsafe.js
deleted file mode 100644
index 73e4fb34e..000000000
--- a/node_modules/tmp/test/unsafe.js
+++ /dev/null
@@ -1,30 +0,0 @@
-var
- fs = require('fs'),
- join = require('path').join,
- spawn = require('./spawn');
-
-var unsafe = spawn.arg;
-spawn.tmpFunction({ unsafeCleanup: unsafe }, function (err, name) {
- if (err) {
- spawn.err(err, spawn.exit);
- return;
- }
-
- try {
- // file that should be removed
- var fd = fs.openSync(join(name, 'should-be-removed.file'), 'w');
- fs.closeSync(fd);
-
- // in tree source
- var symlinkSource = join(__dirname, 'symlinkme');
- // testing target
- var symlinkTarget = join(name, 'symlinkme-target');
-
- // symlink that should be removed but the contents should be preserved.
- fs.symlinkSync(symlinkSource, symlinkTarget, 'dir');
-
- spawn.out(name, spawn.exit);
- } catch (e) {
- spawn.err(e.toString(), spawn.exit);
- }
-});