Merge pull request #44 from humphd/node-tests

Begin to port Node.js tests, break tests into smaller files using require
This commit is contained in:
Alan K 2013-11-27 11:09:11 -08:00
commit 3d171b867d
34 changed files with 3099 additions and 2692 deletions

111
dist/idbfs.js vendored
View File

@ -7001,7 +7001,7 @@ define("encoding-indexes", function(){});
global['TextDecoder'] = global['TextDecoder'] || TextDecoder;
}(this));
define("encoding", function(){});
define("encoding", ["encoding-indexes"], function(){});
// Copyright Joyent, Inc. and other Node contributors.
//
@ -7547,13 +7547,12 @@ define('src/providers/providers',['require','src/providers/indexeddb','src/provi
};
});
define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','src/path','src/path','src/shared','src/shared','src/shared','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/providers/providers'],function(require) {
define('src/fs',['require','lodash','encoding','src/path','src/path','src/path','src/shared','src/shared','src/shared','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/error','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/constants','src/providers/providers'],function(require) {
var _ = require('lodash');
// TextEncoder and TextDecoder will either already be present, or use this shim.
// Because of the way the spec is defined, we need to get them off the global.
require('encoding-indexes');
require('encoding');
var normalize = require('src/path').normalize;
@ -8499,6 +8498,29 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
return O_FLAGS[flags];
}
// nullCheck from https://github.com/joyent/node/blob/master/lib/fs.js
function nullCheck(path, callback) {
if (('' + path).indexOf('\u0000') !== -1) {
var er = new Error('Path must be a string without null bytes.');
callback(er);
return false;
}
return true;
}
// node.js supports a calling pattern that leaves off a callback.
function maybeCallback(callback) {
if(typeof callback === "function") {
return callback;
}
return function(err) {
if(err) {
throw err;
}
};
}
/*
* FileSystem
*
@ -8613,6 +8635,8 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
FileSystem.providers = providers;
function _open(fs, context, path, flags, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error, fileNode) {
if(error) {
callback(error);
@ -8647,6 +8671,8 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
}
function _mkdir(context, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error) {
if(error) {
callback(error);
@ -8659,6 +8685,8 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
}
function _rmdir(context, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error) {
if(error) {
callback(error);
@ -8671,6 +8699,8 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
}
function _stat(context, name, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error, result) {
if(error) {
callback(error);
@ -8703,6 +8733,9 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
}
function _link(context, oldpath, newpath, callback) {
if(!nullCheck(oldpath, callback)) return;
if(!nullCheck(newpath, callback)) return;
function check_result(error) {
if(error) {
callback(error);
@ -8715,6 +8748,8 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
}
function _unlink(context, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error) {
if(error) {
callback(error);
@ -8753,12 +8788,13 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(!options) {
options = { encoding: null, flag: 'r' };
} else if(typeof options === "function") {
callback = options;
options = { encoding: null, flag: 'r' };
} else if(typeof options === "string") {
options = { encoding: options, flag: 'r' };
}
if(!nullCheck(path, callback)) return;
var flags = validate_flags(options.flag || 'r');
if(!flags) {
callback(new EInvalid('flags is not valid'));
@ -8828,17 +8864,22 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(!options) {
options = { encoding: 'utf8', flag: 'w' };
} else if(typeof options === "function") {
callback = options;
options = { encoding: 'utf8', flag: 'w' };
} else if(typeof options === "string") {
options = { encoding: options, flag: 'w' };
}
if(!nullCheck(path, callback)) return;
var flags = validate_flags(options.flag || 'w');
if(!flags) {
callback(new EInvalid('flags is not valid'));
}
data = data || '';
if(typeof data === "number") {
data = '' + data;
}
if(typeof data === "string" && options.encoding === 'utf8') {
data = new TextEncoder('utf-8').encode(data);
}
@ -8862,10 +8903,12 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
function _getxattr(path, name, callback) {
// TODO
// if(!nullCheck(path, callback)) return;
}
function _setxattr(path, name, value, callback) {
// TODO
// if(!nullCheck(path, callback)) return;
}
function _lseek(fs, context, fd, offset, whence, callback) {
@ -8918,6 +8961,8 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
}
function _readdir(context, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error, files) {
if(error) {
callback(error);
@ -8931,9 +8976,13 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
function _utimes(path, atime, mtime, callback) {
// TODO
// if(!nullCheck(path, callback)) return;
}
function _rename(context, oldpath, newpath, callback) {
if(!nullCheck(oldpath, callback)) return;
if(!nullCheck(newpath, callback)) return;
function check_result(error) {
if(error) {
callback(error);
@ -8954,6 +9003,9 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
}
function _symlink(context, srcpath, dstpath, callback) {
if(!nullCheck(srcpath, callback)) return;
if(!nullCheck(dstpath, callback)) return;
function check_result(error) {
if(error) {
callback(error);
@ -8966,6 +9018,8 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
}
function _readlink(context, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error, result) {
if(error) {
callback(error);
@ -8982,6 +9036,8 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
}
function _lstat(fs, context, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error, result) {
if(error) {
callback(error);
@ -8996,10 +9052,12 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
function _truncate(path, length, callback) {
// TODO
// if(!nullCheck(path, callback)) return;
}
function _ftruncate(fd, length, callback) {
// TODO
// if(!nullCheck(path, callback)) return;
}
@ -9007,7 +9065,10 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
* Public API for FileSystem
*/
FileSystem.prototype.open = function(path, flags, callback) {
FileSystem.prototype.open = function(path, flags, mode, callback) {
// We support the same signature as node with a `mode` arg, but
// ignore it. Find the callback.
callback = maybeCallback(arguments[arguments.length - 1]);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9018,9 +9079,14 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.close = function(fd, callback) {
_close(this, fd, callback);
_close(this, fd, maybeCallback(callback));
};
FileSystem.prototype.mkdir = function(path, callback) {
FileSystem.prototype.mkdir = function(path, mode, callback) {
// Support passing a mode arg, but we ignore it internally for now.
if(typeof mode === 'function') {
callback = mode;
}
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9031,6 +9097,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.rmdir = function(path, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9041,6 +9108,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.stat = function(path, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9051,6 +9119,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.fstat = function(fd, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9061,6 +9130,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.link = function(oldpath, newpath, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9071,6 +9141,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.unlink = function(path, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9081,16 +9152,23 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.read = function(fd, buffer, offset, length, position, callback) {
// Follow how node.js does this
callback = maybeCallback(callback);
function wrapper(err, bytesRead) {
// Retain a reference to buffer so that it can't be GC'ed too soon.
callback(err, bytesRead || 0, buffer);
}
var fs = this;
var error = fs.queueOrRun(
function() {
var context = fs.provider.getReadWriteContext();
_read(fs, context, fd, buffer, offset, length, position, callback);
_read(fs, context, fd, buffer, offset, length, position, wrapper);
}
);
if(error) callback(error);
};
FileSystem.prototype.readFile = function(path, options, callback) {
FileSystem.prototype.readFile = function(path, options, callback_) {
var callback = maybeCallback(arguments[arguments.length - 1]);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9101,6 +9179,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.write = function(fd, buffer, offset, length, position, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9111,7 +9190,8 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.writeFile = function(path, data, options, callback) {
FileSystem.prototype.writeFile = function(path, data, options, callback_) {
var callback = maybeCallback(arguments[arguments.length - 1]);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9122,6 +9202,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.lseek = function(fd, offset, whence, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9132,6 +9213,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.readdir = function(path, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9142,6 +9224,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.rename = function(oldpath, newpath, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9152,6 +9235,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.readlink = function(path, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9161,7 +9245,9 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
);
if(error) callback(error);
};
FileSystem.prototype.symlink = function(srcpath, dstpath, callback) {
FileSystem.prototype.symlink = function(srcpath, dstpath, type, callback_) {
// Follow node.js in allowing the `type` arg to be passed, but we ignore it.
var callback = maybeCallback(arguments[arguments.length - 1]);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -9172,6 +9258,7 @@ define('src/fs',['require','lodash','encoding-indexes','encoding','src/path','sr
if(error) callback(error);
};
FileSystem.prototype.lstat = function(path, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {

6
dist/idbfs.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -43,10 +43,16 @@ module.exports = function(grunt) {
wrap: {
startFile: 'build/wrap.start',
endFile: 'build/wrap.end'
}
}
}
},
shim: {
// TextEncoder and TextDecoder shims. encoding-indexes must get loaded first.
"encoding": {
deps: ["encoding-indexes"]
}
}
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');

107
src/fs.js
View File

@ -4,7 +4,6 @@ define(function(require) {
// TextEncoder and TextDecoder will either already be present, or use this shim.
// Because of the way the spec is defined, we need to get them off the global.
require('encoding-indexes');
require('encoding');
var normalize = require('src/path').normalize;
@ -950,6 +949,29 @@ define(function(require) {
return O_FLAGS[flags];
}
// nullCheck from https://github.com/joyent/node/blob/master/lib/fs.js
function nullCheck(path, callback) {
if (('' + path).indexOf('\u0000') !== -1) {
var er = new Error('Path must be a string without null bytes.');
callback(er);
return false;
}
return true;
}
// node.js supports a calling pattern that leaves off a callback.
function maybeCallback(callback) {
if(typeof callback === "function") {
return callback;
}
return function(err) {
if(err) {
throw err;
}
};
}
/*
* FileSystem
*
@ -1064,6 +1086,8 @@ define(function(require) {
FileSystem.providers = providers;
function _open(fs, context, path, flags, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error, fileNode) {
if(error) {
callback(error);
@ -1098,6 +1122,8 @@ define(function(require) {
}
function _mkdir(context, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error) {
if(error) {
callback(error);
@ -1110,6 +1136,8 @@ define(function(require) {
}
function _rmdir(context, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error) {
if(error) {
callback(error);
@ -1122,6 +1150,8 @@ define(function(require) {
}
function _stat(context, name, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error, result) {
if(error) {
callback(error);
@ -1154,6 +1184,9 @@ define(function(require) {
}
function _link(context, oldpath, newpath, callback) {
if(!nullCheck(oldpath, callback)) return;
if(!nullCheck(newpath, callback)) return;
function check_result(error) {
if(error) {
callback(error);
@ -1166,6 +1199,8 @@ define(function(require) {
}
function _unlink(context, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error) {
if(error) {
callback(error);
@ -1204,12 +1239,13 @@ define(function(require) {
if(!options) {
options = { encoding: null, flag: 'r' };
} else if(typeof options === "function") {
callback = options;
options = { encoding: null, flag: 'r' };
} else if(typeof options === "string") {
options = { encoding: options, flag: 'r' };
}
if(!nullCheck(path, callback)) return;
var flags = validate_flags(options.flag || 'r');
if(!flags) {
callback(new EInvalid('flags is not valid'));
@ -1279,17 +1315,22 @@ define(function(require) {
if(!options) {
options = { encoding: 'utf8', flag: 'w' };
} else if(typeof options === "function") {
callback = options;
options = { encoding: 'utf8', flag: 'w' };
} else if(typeof options === "string") {
options = { encoding: options, flag: 'w' };
}
if(!nullCheck(path, callback)) return;
var flags = validate_flags(options.flag || 'w');
if(!flags) {
callback(new EInvalid('flags is not valid'));
}
data = data || '';
if(typeof data === "number") {
data = '' + data;
}
if(typeof data === "string" && options.encoding === 'utf8') {
data = new TextEncoder('utf-8').encode(data);
}
@ -1313,10 +1354,12 @@ define(function(require) {
function _getxattr(path, name, callback) {
// TODO
// if(!nullCheck(path, callback)) return;
}
function _setxattr(path, name, value, callback) {
// TODO
// if(!nullCheck(path, callback)) return;
}
function _lseek(fs, context, fd, offset, whence, callback) {
@ -1369,6 +1412,8 @@ define(function(require) {
}
function _readdir(context, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error, files) {
if(error) {
callback(error);
@ -1382,9 +1427,13 @@ define(function(require) {
function _utimes(path, atime, mtime, callback) {
// TODO
// if(!nullCheck(path, callback)) return;
}
function _rename(context, oldpath, newpath, callback) {
if(!nullCheck(oldpath, callback)) return;
if(!nullCheck(newpath, callback)) return;
function check_result(error) {
if(error) {
callback(error);
@ -1405,6 +1454,9 @@ define(function(require) {
}
function _symlink(context, srcpath, dstpath, callback) {
if(!nullCheck(srcpath, callback)) return;
if(!nullCheck(dstpath, callback)) return;
function check_result(error) {
if(error) {
callback(error);
@ -1417,6 +1469,8 @@ define(function(require) {
}
function _readlink(context, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error, result) {
if(error) {
callback(error);
@ -1433,6 +1487,8 @@ define(function(require) {
}
function _lstat(fs, context, path, callback) {
if(!nullCheck(path, callback)) return;
function check_result(error, result) {
if(error) {
callback(error);
@ -1447,10 +1503,12 @@ define(function(require) {
function _truncate(path, length, callback) {
// TODO
// if(!nullCheck(path, callback)) return;
}
function _ftruncate(fd, length, callback) {
// TODO
// if(!nullCheck(path, callback)) return;
}
@ -1458,7 +1516,10 @@ define(function(require) {
* Public API for FileSystem
*/
FileSystem.prototype.open = function(path, flags, callback) {
FileSystem.prototype.open = function(path, flags, mode, callback) {
// We support the same signature as node with a `mode` arg, but
// ignore it. Find the callback.
callback = maybeCallback(arguments[arguments.length - 1]);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1469,9 +1530,14 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.close = function(fd, callback) {
_close(this, fd, callback);
_close(this, fd, maybeCallback(callback));
};
FileSystem.prototype.mkdir = function(path, callback) {
FileSystem.prototype.mkdir = function(path, mode, callback) {
// Support passing a mode arg, but we ignore it internally for now.
if(typeof mode === 'function') {
callback = mode;
}
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1482,6 +1548,7 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.rmdir = function(path, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1492,6 +1559,7 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.stat = function(path, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1502,6 +1570,7 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.fstat = function(fd, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1512,6 +1581,7 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.link = function(oldpath, newpath, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1522,6 +1592,7 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.unlink = function(path, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1532,16 +1603,23 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.read = function(fd, buffer, offset, length, position, callback) {
// Follow how node.js does this
callback = maybeCallback(callback);
function wrapper(err, bytesRead) {
// Retain a reference to buffer so that it can't be GC'ed too soon.
callback(err, bytesRead || 0, buffer);
}
var fs = this;
var error = fs.queueOrRun(
function() {
var context = fs.provider.getReadWriteContext();
_read(fs, context, fd, buffer, offset, length, position, callback);
_read(fs, context, fd, buffer, offset, length, position, wrapper);
}
);
if(error) callback(error);
};
FileSystem.prototype.readFile = function(path, options, callback) {
FileSystem.prototype.readFile = function(path, options, callback_) {
var callback = maybeCallback(arguments[arguments.length - 1]);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1552,6 +1630,7 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.write = function(fd, buffer, offset, length, position, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1562,7 +1641,8 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.writeFile = function(path, data, options, callback) {
FileSystem.prototype.writeFile = function(path, data, options, callback_) {
var callback = maybeCallback(arguments[arguments.length - 1]);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1573,6 +1653,7 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.lseek = function(fd, offset, whence, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1583,6 +1664,7 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.readdir = function(path, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1593,6 +1675,7 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.rename = function(oldpath, newpath, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1603,6 +1686,7 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.readlink = function(path, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1612,7 +1696,9 @@ define(function(require) {
);
if(error) callback(error);
};
FileSystem.prototype.symlink = function(srcpath, dstpath, callback) {
FileSystem.prototype.symlink = function(srcpath, dstpath, type, callback_) {
// Follow node.js in allowing the `type` arg to be passed, but we ignore it.
var callback = maybeCallback(arguments[arguments.length - 1]);
var fs = this;
var error = fs.queueOrRun(
function() {
@ -1623,6 +1709,7 @@ define(function(require) {
if(error) callback(error);
};
FileSystem.prototype.lstat = function(path, callback) {
callback = maybeCallback(callback);
var fs = this;
var error = fs.queueOrRun(
function() {

View File

@ -8,49 +8,9 @@
<link rel="stylesheet" type="text/css" href="../tools/jasmine-1.3.1/jasmine.css">
<script type="text/javascript" src="../tools/jasmine-1.3.1/jasmine.js"></script>
<script type="text/javascript" src="../tools/jasmine-1.3.1/jasmine-html.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src="../dist/idbfs.js"></script>
<!-- include spec files here... -->
<!--script type="text/javascript" src="spec/SpecHelper.js"></script-->
<script type="text/javascript" src="common.js"></script>
<script type="text/javascript" src="spec/providers.spec.js"></script>
<script type="text/javascript" src="spec/providers.indexeddb.spec.js"></script>
<script type="text/javascript" src="spec/providers.memory.spec.js"></script>
<script type="text/javascript" src="spec/idbfs.spec.js"></script>
<script type="text/javascript">
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
<script src="../lib/require.js" data-main="require-config"></script>
</head>
<body>
</body>
</html>

47
tests/require-config.js Normal file
View File

@ -0,0 +1,47 @@
/**
* Assembles fs.js at runtime in the browswer, as well as all test
* spec files. Add spec files to the list in test-manifest.js
*/
require.config({
paths: {
"tests": "../tests",
"src": "../src",
"spec": "../tests/spec",
"IDBFS": "../src/fs"
},
baseUrl: "../lib",
optimize: "none",
shim: {
// TextEncoder and TextDecoder shims. encoding-indexes must get loaded first.
"encoding": {
deps: ["encoding-indexes"]
}
}
});
require(["tests/test-manifest"], function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
});

View File

@ -0,0 +1,50 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.close', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.close).toEqual('function');
});
it('should release the file descriptor', function() {
var complete = false;
var _error;
var that = this;
var buffer = new Uint8Array(0);
that.fs.open('/myfile', 'w+', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.close(fd, function(error) {
that.fs.read(fd, buffer, 0, buffer.length, undefined, function(error, result) {
_error = error;
complete = true;
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
});
});
});
});

103
tests/spec/fs.link.spec.js Normal file
View File

@ -0,0 +1,103 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.link', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.link).toEqual('function');
});
it('should create a link to an existing file', function() {
var complete = false;
var _error, _oldstats, _newstats;
var that = this;
that.fs.open('/myfile', 'w+', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.close(fd, function(error) {
if(error) throw error;
that.fs.link('/myfile', '/myotherfile', function(error) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
if(error) throw error;
_oldstats = result;
that.fs.stat('/myotherfile', function(error, result) {
if(error) throw error;
_newstats = result;
complete = true;
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_newstats.node).toEqual(_oldstats.node);
expect(_newstats.nlinks).toEqual(2);
expect(_newstats).toEqual(_oldstats);
});
});
it('should not follow symbolic links', function () {
var complete = false;
var _error, _oldstats, _linkstats, _newstats;
var that = this;
that.fs.stat('/', function (error, result) {
if (error) throw error;
_oldstats = result;
that.fs.symlink('/', '/myfileLink', function (error) {
if (error) throw error;
that.fs.link('/myfileLink', '/myotherfile', function (error) {
if (error) throw error;
that.fs.lstat('/myfileLink', function (error, result) {
if (error) throw error;
_linkstats = result;
that.fs.lstat('/myotherfile', function (error, result) {
if (error) throw error;
_newstats = result;
complete = true;
});
});
});
});
});
waitsFor(function () {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function () {
expect(_error).toEqual(null);
expect(_newstats.node).toEqual(_linkstats.node);
expect(_newstats.node).toNotEqual(_oldstats.node);
expect(_newstats.nlinks).toEqual(2);
expect(_newstats).toEqual(_linkstats);
});
});
});
});

231
tests/spec/fs.lseek.spec.js Normal file
View File

@ -0,0 +1,231 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.lseek', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.lseek).toEqual('function');
});
it('should not follow symbolic links', function () {
var complete = false;
var _error, _stats;
var that = this;
that.fs.open('/myfile', 'w', function (error, result) {
if (error) throw error;
var fd = result;
that.fs.close(fd, function (error) {
if (error) throw error;
that.fs.symlink('/myfile', '/myFileLink', function (error) {
if (error) throw error;
that.fs.rename('/myFileLink', '/myOtherFileLink', function (error) {
if (error) throw error;
that.fs.stat('/myfile', function (error, result) {
_error1 = error;
that.fs.lstat('/myFileLink', function (error, result) {
_error2 = error;
that.fs.stat('/myOtherFileLink', function (error, result) {
if (error) throw error;
_stats = result;
complete = true;
});
});
});
});
});
});
});
waitsFor(function () {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function () {
expect(_error1).toEqual(null);
expect(_error2).toBeDefined();
expect(_stats.nlinks).toEqual(1);
});
});
it('should set the current position if whence is SET', function() {
var complete = false;
var _error, _result, _stats;
var that = this;
var offset = 3;
var buffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
var result_buffer = new Uint8Array(buffer.length + offset);
that.fs.open('/myfile', 'w+', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error;
that.fs.lseek(fd, offset, 'SET', function(error, result) {
_error = error;
_result = result;
that.fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error;
that.fs.read(fd, result_buffer, 0, result_buffer.length, 0, function(error, result) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
if(error) throw error;
_stats = result;
complete = true;
});
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(offset);
expect(_stats.size).toEqual(offset + buffer.length);
var expected = new Uint8Array([1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8]);
expect(typed_array_equal(result_buffer, expected)).toEqual(true);
});
});
it('should update the current position if whence is CUR', function() {
var complete = false;
var _error, _result, _stats;
var that = this;
var offset = -2;
var buffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
var result_buffer = new Uint8Array(2 * buffer.length + offset);
that.fs.open('/myfile', 'w+', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error;
that.fs.lseek(fd, offset, 'CUR', function(error, result) {
_error = error;
_result = result;
that.fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error;
that.fs.read(fd, result_buffer, 0, result_buffer.length, 0, function(error, result) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
if(error) throw error;
_stats = result;
complete = true;
});
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(offset + buffer.length);
expect(_stats.size).toEqual(offset + 2 * buffer.length);
var expected = new Uint8Array([1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8]);
expect(typed_array_equal(result_buffer, expected)).toEqual(true);
});
});
it('should update the current position if whence is END', function() {
var complete = false;
var _error, _result, _stats;
var that = this;
var offset = 5;
var buffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
var result_buffer;
that.fs.open('/myfile', 'w+', function(error, result) {
if(error) throw error;
var fd1 = result;
that.fs.write(fd1, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error;
that.fs.open('/myfile', 'w+', function(error, result) {
if(error) throw error;
var fd2 = result;
that.fs.lseek(fd2, offset, 'END', function(error, result) {
_error = error;
_result = result;
that.fs.write(fd2, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
if(error) throw error;
_stats = result;
result_buffer = new Uint8Array(_stats.size);
that.fs.read(fd2, result_buffer, 0, result_buffer.length, 0, function(error, result) {
if(error) throw error;
complete = true;
});
});
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(offset + buffer.length);
expect(_stats.size).toEqual(offset + 2 * buffer.length);
var expected = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8]);
expect(typed_array_equal(result_buffer, expected)).toEqual(true);
});
});
});
});

View File

@ -0,0 +1,92 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.lstat', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.lstat).toEqual('function');
});
it('should return an error if path does not exist', function() {
var complete = false;
var _error, _result;
this.fs.lstat('/tmp', function(error, result) {
_error = error;
_result = result;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).not.toBeDefined();
});
});
it('should return a stat object if path is not a symbolic link', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.lstat('/', function(error, result) {
_error = error;
_result = result;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toBeDefined();
});
});
it('should return a stat object if path is a symbolic link', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.symlink('/', '/mylink', function(error) {
if(error) throw error;
that.fs.lstat('/mylink', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toBeDefined();
});
});
});
});

View File

@ -0,0 +1,89 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.mkdir', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.mkdir).toEqual('function');
});
it('should return an error if part of the parent path does not exist', function() {
var complete = false;
var _error;
var that = this;
that.fs.mkdir('/tmp/mydir', function(error) {
_error = error;
complete = true;
});
waitsFor(function() {
return complete;
}, 'stat to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
});
});
it('should return an error if the path already exists', function() {
var complete = false;
var _error;
var that = this;
that.fs.mkdir('/', function(error) {
_error = error;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
});
});
it('should make a new directory', function() {
var complete = false;
var _error, _result, _stat;
var that = this;
that.fs.mkdir('/tmp', function(error, result) {
_error = error;
_result = result;
that.fs.stat('/tmp', function(error, result) {
_stat = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).not.toBeDefined();
expect(_stat).toBeDefined();
});
});
});
});

175
tests/spec/fs.open.spec.js Normal file
View File

@ -0,0 +1,175 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.open', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.open).toEqual('function');
});
it('should return an error if the parent path does not exist', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.open('/tmp/myfile', 'w+', function(error, result) {
_error = error;
_result = result;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).not.toBeDefined();
});
});
it('should return an error when flagged for read and the path does not exist', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.open('/myfile', 'r+', function(error, result) {
_error = error;
_result = result;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).not.toBeDefined();
});
});
it('should return an error when flagged for write and the path is a directory', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.mkdir('/tmp', function(error) {
if(error) throw error;
that.fs.open('/tmp', 'w', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).not.toBeDefined();
});
});
it('should return an error when flagged for append and the path is a directory', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.mkdir('/tmp', function(error) {
if(error) throw error;
that.fs.open('/tmp', 'a', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).not.toBeDefined();
});
});
it('should return a unique file descriptor', function() {
var complete1 = false;
var complete2 = false;
var _error, _result1, _result2;
var that = this;
that.fs.open('/file1', 'w+', function(error, fd) {
if(error) throw error;
_error = error;
_result1 = fd;
complete1 = true;
});
that.fs.open('/file2', 'w+', function(error, fd) {
if(error) throw error;
_error = error;
_result2 = fd;
complete2 = true;
});
waitsFor(function() {
return complete1 && complete2;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result1).toBeDefined();
expect(_result2).toBeDefined();
expect(_result1).not.toEqual(_result2);
});
});
it('should create a new file when flagged for write', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.open('/myfile', 'w', function(error, result) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toBeDefined();
});
});
});
});

View File

@ -0,0 +1,98 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.read', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.read).toEqual('function');
});
it('should read data from a file', function() {
var complete = false;
var _error, _result;
var that = this;
var wbuffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
var rbuffer = new Uint8Array(wbuffer.length);
that.fs.open('/myfile', 'w+', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.write(fd, wbuffer, 0, wbuffer.length, 0, function(error, result) {
if(error) throw error;
that.fs.read(fd, rbuffer, 0, rbuffer.length, 0, function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(rbuffer.length);
expect(typed_array_equal(wbuffer, rbuffer)).toEqual(true);
});
});
it('should update the current file position', function() {
var complete = false;
var _error, _result;
var that = this;
var wbuffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
var rbuffer = new Uint8Array(wbuffer.length);
_result = 0;
that.fs.open('/myfile', 'w+', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.write(fd, wbuffer, 0, wbuffer.length, 0, function(error, result) {
if(error) throw error;
that.fs.read(fd, rbuffer, 0, rbuffer.length / 2, undefined, function(error, result) {
if(error) throw error;
_result += result;
that.fs.read(fd, rbuffer, rbuffer.length / 2, rbuffer.length, undefined, function(error, result) {
if(error) throw error;
_result += result;
complete = true;
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(rbuffer.length);
expect(typed_array_equal(wbuffer.buffer, rbuffer.buffer)).toEqual(true);
});
});
});
});

View File

@ -0,0 +1,96 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.readdir', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.readdir).toEqual('function');
});
it('should return an error if the path does not exist', function() {
var complete = false;
var _error;
var that = this;
that.fs.readdir('/tmp/mydir', function(error) {
_error = error;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
});
});
it('should return a list of files from an existing directory', function() {
var complete = false;
var _error, _files;
var that = this;
that.fs.mkdir('/tmp', function(error) {
that.fs.readdir('/', function(error, result) {
_error = error;
_files = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_files.length).toEqual(1);
expect(_files[0]).toEqual('tmp');
});
});
it('should follow symbolic links', function() {
var complete = false;
var _error, _files;
var that = this;
that.fs.mkdir('/tmp', function(error) {
if(error) throw error;
that.fs.symlink('/', '/tmp/dirLink', function(error) {
if(error) throw error;
that.fs.readdir('/tmp/dirLink', function(error, result) {
_error = error;
_files = result;
complete = true;
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_files.length).toEqual(1);
expect(_files[0]).toEqual('tmp');
});
});
});
});

View File

@ -0,0 +1,87 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.readlink', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.readlink).toEqual('function');
});
it('should return an error if part of the parent destination path does not exist', function() {
var complete = false;
var _error;
var that = this;
that.fs.readlink('/tmp/mydir', function(error) {
_error = error;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
});
});
it('should return an error if the path is not a symbolic link', function() {
var complete = false;
var _error;
var that = this;
that.fs.readlink('/', function(error) {
_error = error;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
});
});
it('should return the contents of a symbolic link', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.symlink('/', '/myfile', function(error) {
if(error) throw error;
that.fs.readlink('/myfile', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual('/');
});
});
});
});

View File

@ -0,0 +1,63 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.rename', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.rename).toEqual('function');
});
it('should rename an existing file', function() {
var complete1 = false;
var complete2 = false;
var _error, _stats;
var that = this;
that.fs.open('/myfile', 'w+', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.close(fd, function(error) {
if(error) throw error;
that.fs.rename('/myfile', '/myotherfile', function(error) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
_error = error;
complete1 = true;
});
that.fs.stat('/myotherfile', function(error, result) {
if(error) throw error;
_stats = result;
complete2 = true;
});
});
});
});
waitsFor(function() {
return complete1 && complete2;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_stats.nlinks).toEqual(1);
});
});
});
});

162
tests/spec/fs.rmdir.spec.js Normal file
View File

@ -0,0 +1,162 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.rmdir', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.rmdir).toEqual('function');
});
it('should return an error if the path does not exist', function() {
var complete = false;
var _error;
var that = this;
that.fs.rmdir('/tmp/mydir', function(error) {
_error = error;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
});
});
it('should return an error if attempting to remove the root directory', function() {
var complete = false;
var _error;
var that = this;
that.fs.rmdir('/', function(error) {
_error = error;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
});
});
it('should return an error if the directory is not empty', function() {
var complete = false;
var _error;
var that = this;
that.fs.mkdir('/tmp', function(error) {
that.fs.mkdir('/tmp/mydir', function(error) {
that.fs.rmdir('/', function(error) {
_error = error;
complete = true;
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
});
});
it('should return an error if the path is not a directory', function() {
var complete = false;
var _error;
var that = this;
that.fs.mkdir('/tmp', function(error) {
that.fs.open('/tmp/myfile', 'w', function(error, fd) {
that.fs.close(fd, function(error) {
that.fs.rmdir('/tmp/myfile', function(error) {
_error = error;
complete = true;
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
});
});
it('should return an error if the path is a symbolic link', function () {
var complete = false;
var _error;
var that = this;
that.fs.mkdir('/tmp', function (error) {
that.fs.symlink('/tmp', '/tmp/myfile', function (error) {
that.fs.rmdir('/tmp/myfile', function (error) {
_error = error;
complete = true;
});
});
});
waitsFor(function () {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function () {
expect(_error).toBeDefined();
});
});
it('should remove an existing directory', function() {
var complete = false;
var _error, _stat;
var that = this;
that.fs.mkdir('/tmp', function(error) {
that.fs.rmdir('/tmp', function(error) {
_error = error;
that.fs.stat('/tmp', function(error, result) {
_stat = result;
complete = true;
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_stat).not.toBeDefined();
});
});
});
});

41
tests/spec/fs.spec.js Normal file
View File

@ -0,0 +1,41 @@
define(["IDBFS"], function(IDBFS) {
describe("fs", function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it("is an object", function() {
expect(typeof this.fs).toEqual('object');
});
it('should have a root directory', function() {
var complete = false;
var _result;
this.fs.stat('/', function(error, result) {
_result = result;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).toBeDefined();
});
});
});
});

147
tests/spec/fs.stat.spec.js Normal file
View File

@ -0,0 +1,147 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.stat', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.stat).toEqual('function');
});
it('should return an error if path does not exist', function() {
var complete = false;
var _error, _result;
this.fs.stat('/tmp', function(error, result) {
_error = error;
_result = result;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).not.toBeDefined();
});
});
it('should return a stat object if path exists', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.stat('/', function(error, result) {
_error = error;
_result = result;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).toBeDefined();
expect(_error).toEqual(null);
expect(_result['node']).toBeDefined();
expect(_result['dev']).toEqual(that.db_name);
expect(_result['size']).toBeDefined();
expect(_result['nlinks']).toEqual(jasmine.any(Number));
expect(_result['atime']).toEqual(jasmine.any(Number));
expect(_result['mtime']).toEqual(jasmine.any(Number));
expect(_result['ctime']).toEqual(jasmine.any(Number));
expect(_result['type']).toBeDefined();
});
});
it('should follow symbolic links and return a stat object for the resulting path', function() {
var complete = false;
var _error, _node, _result;
var that = this;
that.fs.open('/myfile', 'w', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.close(fd, function(error) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
if(error) throw error;
_node = result['node'];
that.fs.symlink('/myfile', '/myfilelink', function(error) {
if(error) throw error;
that.fs.stat('/myfilelink', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).toBeDefined();
expect(_node).toBeDefined();
expect(_error).toEqual(null);
expect(_result['node']).toEqual(_node);
});
});
it('should return a stat object for a valid descriptor', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.open('/myfile', 'w+', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.fstat(fd, function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).toBeDefined();
expect(_error).toEqual(null);
expect(_result['node']).toBeDefined();
expect(_result['dev']).toEqual(that.db_name);
expect(_result['size']).toBeDefined();
expect(_result['nlinks']).toEqual(jasmine.any(Number));
expect(_result['atime']).toEqual(jasmine.any(Number));
expect(_result['mtime']).toEqual(jasmine.any(Number));
expect(_result['ctime']).toEqual(jasmine.any(Number));
expect(_result['type']).toBeDefined();
});
});
});
});

View File

@ -0,0 +1,83 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.symlink', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.symlink).toEqual('function');
});
it('should return an error if part of the parent destination path does not exist', function() {
var complete = false;
var _error;
var that = this;
that.fs.symlink('/', '/tmp/mydir', function(error) {
_error = error;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
});
});
it('should return an error if the destination path already exists', function() {
var complete = false;
var _error;
var that = this;
that.fs.symlink('/tmp', '/', function(error) {
_error = error;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
});
});
it('should create a symlink', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.symlink('/', '/myfile', function(error, result) {
_error = error;
_result = result;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).not.toBeDefined();
});
});
});
});

View File

@ -0,0 +1,110 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.unlink', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.unlink).toEqual('function');
});
it('should remove a link to an existing file', function() {
var complete1 = false;
var complete2 = false;
var _error, _stats;
var that = this;
that.fs.open('/myfile', 'w+', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.close(fd, function(error) {
if(error) throw error;
that.fs.link('/myfile', '/myotherfile', function(error) {
if(error) throw error;
that.fs.unlink('/myfile', function(error) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
_error = error;
complete1 = true;
});
that.fs.stat('/myotherfile', function(error, result) {
if(error) throw error;
_stats = result;
complete2 = true;
});
});
});
});
});
waitsFor(function() {
return complete1 && complete2;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_stats.nlinks).toEqual(1);
});
});
it('should not follow symbolic links', function () {
var complete = false;
var _error, _stats1, _stats2;
var that = this;
that.fs.symlink('/', '/myFileLink', function (error) {
if (error) throw error;
that.fs.link('/myFileLink', '/myotherfile', function (error) {
if (error) throw error;
that.fs.unlink('/myFileLink', function (error) {
if (error) throw error;
that.fs.lstat('/myFileLink', function (error, result) {
_error = error;
that.fs.lstat('/myotherfile', function (error, result) {
if (error) throw error;
_stats1 = result;
that.fs.stat('/', function (error, result) {
if (error) throw error;
_stats2 = result;
complete = true;
});
});
});
});
});
});
waitsFor(function () {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function () {
expect(_error).toBeDefined();
expect(_stats1.nlinks).toEqual(1);
expect(_stats2.nlinks).toEqual(1);
});
});
});
});

100
tests/spec/fs.write.spec.js Normal file
View File

@ -0,0 +1,100 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.write', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.write).toEqual('function');
});
it('should write data to a file', function() {
var complete = false;
var _error, _result, _stats;
var that = this;
var buffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
that.fs.open('/myfile', 'w', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.write(fd, buffer, 0, buffer.length, 0, function(error, result) {
_error = error;
_result = result;
that.fs.stat('/myfile', function(error, result) {
if(error) throw error;
_stats = result;
complete = true;
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(buffer.length);
expect(_stats.size).toEqual(buffer.length);
});
});
it('should update the current file position', function() {
var complete = false;
var _error, _result, _stats;
var that = this;
var buffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
_result = 0;
that.fs.open('/myfile', 'w', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error;
_result += result;
that.fs.write(fd, buffer, 0, buffer.length, undefined, function(error, result) {
if(error) throw error;
_result += result;
that.fs.stat('/myfile', function(error, result) {
if(error) throw error;
_stats = result;
complete = true;
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(2 * buffer.length);
expect(_stats.size).toEqual(_result);
});
});
});
});

View File

@ -0,0 +1,183 @@
define(["IDBFS"], function(IDBFS) {
describe('fs.writeFile, fs.readFile', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should be a function', function() {
expect(typeof this.fs.writeFile).toEqual('function');
expect(typeof this.fs.readFile).toEqual('function');
});
it('should error when path is wrong to readFile', function() {
var complete = false;
var _error, _result;
var that = this;
var contents = "This is a file.";
that.fs.readFile('/no-such-file', 'utf8', function(error, data) {
_error = error;
_result = data;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).not.toBeDefined();
});
});
it('should write, read a utf8 file without specifying utf8 in writeFile', function() {
var complete = false;
var _error, _result;
var that = this;
var contents = "This is a file.";
that.fs.writeFile('/myfile', contents, function(error) {
if(error) throw error;
that.fs.readFile('/myfile', 'utf8', function(error2, data) {
if(error2) throw error2;
_result = data;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(contents);
});
});
it('should write, read a utf8 file with "utf8" option to writeFile', function() {
var complete = false;
var _error, _result;
var that = this;
var contents = "This is a file.";
that.fs.writeFile('/myfile', contents, 'utf8', function(error) {
if(error) throw error;
that.fs.readFile('/myfile', 'utf8', function(error2, data) {
if(error2) throw error2;
_result = data;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(contents);
});
});
it('should write, read a utf8 file with {encoding: "utf8"} option to writeFile', function() {
var complete = false;
var _error, _result;
var that = this;
var contents = "This is a file.";
that.fs.writeFile('/myfile', contents, { encoding: 'utf8' }, function(error) {
if(error) throw error;
that.fs.readFile('/myfile', 'utf8', function(error2, data) {
if(error2) throw error2;
_result = data;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(contents);
});
});
it('should write, read a binary file', function() {
var complete = false;
var _error, _result;
var that = this;
// String and utf8 binary encoded versions of the same thing:
var contents = "This is a file.";
var binary = new Uint8Array([84, 104, 105, 115, 32, 105, 115, 32, 97, 32, 102, 105, 108, 101, 46]);
that.fs.writeFile('/myfile', binary, function(error) {
if(error) throw error;
that.fs.readFile('/myfile', function(error2, data) {
if(error2) throw error2;
_result = data;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(binary);
});
});
it('should follow symbolic links', function () {
var complete = false;
var _result;
var that = this;
var contents = "This is a file.";
that.fs.writeFile('/myfile', '', { encoding: 'utf8' }, function(error) {
if(error) throw error;
that.fs.symlink('/myfile', '/myFileLink', function (error) {
if (error) throw error;
that.fs.writeFile('/myFileLink', contents, 'utf8', function (error) {
if (error) throw error;
that.fs.readFile('/myFileLink', 'utf8', function(error, data) {
if(error) throw error;
_result = data;
complete = true;
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).toEqual(contents);
});
});
});
});

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,74 @@
define(["IDBFS"], function(IDBFS) {
describe("node.js tests: https://github.com/joyent/node/blob/master/test/simple/test-fs-mkdir.js", function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
// Based on test1 from https://github.com/joyent/node/blob/master/test/simple/test-fs-mkdir.js
it('should create a dir without a mode arg', function() {
var _error, _result;
var complete = false;
var pathname = '/test1';
var fs = this.fs;
fs.mkdir(pathname, function(err) {
_error = err;
fs.stat(pathname, function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).toBeDefined();
expect(_error).toEqual(null);
});
});
// Based on test2 https://github.com/joyent/node/blob/master/test/simple/test-fs-mkdir.js
it('should create a dir with a mode arg', function() {
var _error, _result;
var complete = false;
var pathname = '/test2';
var fs = this.fs;
fs.mkdir(pathname, 511 /*=0777*/, function(err) {
_error = err;
fs.stat(pathname, function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).toBeDefined();
expect(_error).toEqual(null);
});
});
});
});

View File

@ -0,0 +1,77 @@
define(["IDBFS"], function(IDBFS) {
describe("node.js tests: https://github.com/joyent/node/blob/master/test/simple/test-fs-null-bytes.js", function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should reject paths with null bytes in them', function() {
var complete = false;
var checks = [];
var fnCount = 0;
var fnTotal = 16;
var expected = "Path must be a string without null bytes.";
var fs = this.fs;
// Make sure function fails with null path error in callback.
function check(fn) {
var args = Array.prototype.slice.call(arguments, 1);
args = args.concat(function(err) {
checks.push(function(){
expect(err).toBeDefined();
expect(err.message).toEqual(expected);
});
fnCount++;
complete = fnCount === fnTotal;
});
fn.apply(fs, args);
}
check(fs.link, 'foo\u0000bar', 'foobar');
check(fs.link, 'foobar', 'foo\u0000bar');
check(fs.lstat, 'foo\u0000bar');
check(fs.mkdir, 'foo\u0000bar', '0755');
check(fs.open, 'foo\u0000bar', 'r');
check(fs.readFile, 'foo\u0000bar');
check(fs.readdir, 'foo\u0000bar');
check(fs.readlink, 'foo\u0000bar');
check(fs.rename, 'foo\u0000bar', 'foobar');
check(fs.rename, 'foobar', 'foo\u0000bar');
check(fs.rmdir, 'foo\u0000bar');
check(fs.stat, 'foo\u0000bar');
check(fs.symlink, 'foo\u0000bar', 'foobar');
check(fs.symlink, 'foobar', 'foo\u0000bar');
check(fs.unlink, 'foo\u0000bar');
check(fs.writeFile, 'foo\u0000bar');
// TODO - need to be implemented still...
// check(fs.appendFile, 'foo\u0000bar');
// check(fs.realpath, 'foo\u0000bar');
// check(fs.chmod, 'foo\u0000bar', '0644');
// check(fs.chown, 'foo\u0000bar', 12, 34);
// check(fs.realpath, 'foo\u0000bar');
// check(fs.truncate, 'foo\u0000bar');
// check(fs.utimes, 'foo\u0000bar', 0, 0);
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
checks.forEach(function(fn){
fn();
});
});
});
});
});

View File

@ -0,0 +1,351 @@
define(["IDBFS"], function(IDBFS) {
describe('path resolution', function() {
beforeEach(function() {
this.db_name = mk_db_name();
this.fs = new IDBFS.FileSystem({
name: this.db_name,
flags: 'FORMAT'
});
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
delete this.fs;
});
it('should follow a symbolic link to the root directory', function() {
var complete = false;
var _error, _node, _result;
var that = this;
that.fs.symlink('/', '/mydirectorylink', function(error) {
if(error) throw error;
that.fs.stat('/', function(error, result) {
if(error) throw error;
_node = result['node'];
that.fs.stat('/mydirectorylink', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).toBeDefined();
expect(_node).toBeDefined();
expect(_error).toEqual(null);
expect(_result['node']).toEqual(_node);
});
});
it('should follow a symbolic link to a directory', function() {
var complete = false;
var _error, _node, _result;
var that = this;
that.fs.mkdir('/mydir', function(error) {
that.fs.symlink('/mydir', '/mydirectorylink', function(error) {
if(error) throw error;
that.fs.stat('/mydir', function(error, result) {
if(error) throw error;
_node = result['node'];
that.fs.stat('/mydirectorylink', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).toBeDefined();
expect(_node).toBeDefined();
expect(_error).toEqual(null);
expect(_result['node']).toEqual(_node);
});
});
it('should follow a symbolic link to a file', function() {
var complete = false;
var _error, _node, _result;
var that = this;
that.fs.open('/myfile', 'w', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.close(fd, function(error) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
if(error) throw error;
_node = result['node'];
that.fs.symlink('/myfile', '/myfilelink', function(error) {
if(error) throw error;
that.fs.stat('/myfilelink', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).toBeDefined();
expect(_node).toBeDefined();
expect(_error).toEqual(null);
expect(_result['node']).toEqual(_node);
});
});
it('should follow multiple symbolic links to a file', function() {
var complete = false;
var _error, _node, _result;
var that = this;
that.fs.open('/myfile', 'w', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.close(fd, function(error) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
if(error) throw error;
_node = result['node'];
that.fs.symlink('/myfile', '/myfilelink1', function(error) {
if(error) throw error;
that.fs.symlink('/myfilelink1', '/myfilelink2', function(error) {
if(error) throw error;
that.fs.stat('/myfilelink2', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).toBeDefined();
expect(_node).toBeDefined();
expect(_error).toEqual(null);
expect(_result['node']).toEqual(_node);
});
});
it('should error if symbolic link leads to itself', function() {
var complete = false;
var _error, _node, _result;
var that = this;
that.fs.symlink('/mylink1', '/mylink2', function(error) {
if(error) throw error;
that.fs.symlink('/mylink2', '/mylink1', function(error) {
if(error) throw error;
that.fs.stat('/myfilelink1', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).not.toBeDefined();
});
});
it('should error if it follows more than 10 symbolic links', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.open('/myfile', 'w', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.close(fd, function(error) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
if(error) throw error;
that.fs.symlink('/myfile', '/myfilelink1', function(error) {
if(error) throw error;
that.fs.symlink('/myfilelink1', '/myfilelink2', function(error) {
if(error) throw error;
that.fs.symlink('/myfilelink2', '/myfilelink3', function(error) {
if(error) throw error;
that.fs.symlink('/myfilelink3', '/myfilelink4', function(error) {
if(error) throw error;
that.fs.symlink('/myfilelink4', '/myfilelink5', function(error) {
if(error) throw error;
that.fs.symlink('/myfilelink5', '/myfilelink6', function(error) {
if(error) throw error;
that.fs.symlink('/myfilelink6', '/myfilelink7', function(error) {
if(error) throw error;
that.fs.symlink('/myfilelink7', '/myfilelink8', function(error) {
if(error) throw error;
that.fs.symlink('/myfilelink8', '/myfilelink9', function(error) {
if(error) throw error;
that.fs.symlink('/myfilelink9', '/myfilelink10', function(error) {
if(error) throw error;
that.fs.symlink('/myfilelink10', '/myfilelink11', function(error) {
if(error) throw error;
that.fs.stat('/myfilelink11', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
});
});
});
});
});
});
});
});
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).not.toBeDefined();
expect(_error).toBeDefined();
});
});
it('should follow a symbolic link in the path to a file', function() {
var complete = false;
var _error, _node, _result;
var that = this;
that.fs.open('/myfile', 'w', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.close(fd, function(error) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
if(error) throw error;
_node = result['node'];
that.fs.symlink('/', '/mydirlink', function(error) {
if(error) throw error;
that.fs.stat('/mydirlink/myfile', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_result).toBeDefined();
expect(_node).toBeDefined();
expect(_error).toEqual(null);
expect(_result['node']).toEqual(_node);
});
});
it('should error if a symbolic link in the path to a file is itself a file', function() {
var complete = false;
var _error, _result;
var that = this;
that.fs.open('/myfile', 'w', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.close(fd, function(error) {
if(error) throw error;
that.fs.stat('/myfile', function(error, result) {
if(error) throw error;
that.fs.open('/myfile2', 'w', function(error, result) {
if(error) throw error;
var fd = result;
that.fs.close(fd, function(error) {
if(error) throw error;
that.fs.symlink('/myfile2', '/mynotdirlink', function(error) {
if(error) throw error;
that.fs.stat('/mynotdirlink/myfile', function(error, result) {
_error = error;
_result = result;
complete = true;
});
});
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).not.toBeDefined();
});
});
});
});

View File

@ -1,188 +0,0 @@
describe("IDBFS.FileSystem.providers.IndexedDB", function() {
it("is supported -- if it isn't, none of these tests can run.", function() {
expect(IDBFS.FileSystem.providers.IndexedDB.isSupported()).toEqual(true);
});
it("has open, getReadOnlyContext, and getReadWriteContext instance methods", function() {
var indexedDBProvider = new IDBFS.FileSystem.providers.IndexedDB();
expect(typeof indexedDBProvider.open).toEqual('function');
expect(typeof indexedDBProvider.getReadOnlyContext).toEqual('function');
expect(typeof indexedDBProvider.getReadWriteContext).toEqual('function');
});
describe("open an IndexedDB provider", function() {
beforeEach(function() {
this.db_name = mk_db_name();
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
});
it("should open a new IndexedDB database", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
_result = firstAccess;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(true);
});
});
});
describe("Read/Write operations on an IndexedDB provider", function() {
beforeEach(function() {
this.db_name = mk_db_name();
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
});
it("should allow put() and get()", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadWriteContext();
context.put("key", "value", function(err, result) {
_error = _error || err;
context.get("key", function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual("value");
});
});
it("should allow delete()", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadWriteContext();
context.put("key", "value", function(err, result) {
_error = _error || err;
context.delete("key", function(err, result) {
_error = _error || err;
context.get("key", function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(null);
});
});
it("should allow clear()", function() {
var complete = false;
var _error, _result1, _result2;
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadWriteContext();
context.put("key1", "value1", function(err, result) {
_error = _error || err;
context.put("key2", "value2", function(err, result) {
_error = _error || err;
context.clear(function(err) {
_error = _error || err;
context.get("key1", function(err, result) {
_error = _error || err;
_result1 = result;
context.get("key2", function(err, result) {
_error = _error || err;
_result2 = result;
complete = true;
});
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result1).toEqual(null);
expect(_result2).toEqual(null);
});
});
it("should fail when trying to write on ReadOnlyContext", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadOnlyContext();
context.put("key1", "value1", function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).toEqual(null);
});
});
});
});

View File

@ -1,172 +0,0 @@
describe("IDBFS.FileSystem.providers.Memory", function() {
it("is supported -- if it isn't, none of these tests can run.", function() {
expect(IDBFS.FileSystem.providers.Memory.isSupported()).toEqual(true);
});
it("has open, getReadOnlyContext, and getReadWriteContext instance methods", function() {
var indexedDBProvider = new IDBFS.FileSystem.providers.Memory();
expect(typeof indexedDBProvider.open).toEqual('function');
expect(typeof indexedDBProvider.getReadOnlyContext).toEqual('function');
expect(typeof indexedDBProvider.getReadWriteContext).toEqual('function');
});
describe("open an Memory provider", function() {
it("should open a new Memory database", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
_result = firstAccess;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(true);
});
});
});
describe("Read/Write operations on an Memory provider", function() {
it("should allow put() and get()", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadWriteContext();
context.put("key", "value", function(err, result) {
_error = _error || err;
context.get("key", function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual("value");
});
});
it("should allow delete()", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadWriteContext();
context.put("key", "value", function(err, result) {
_error = _error || err;
context.delete("key", function(err, result) {
_error = _error || err;
context.get("key", function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(null);
});
});
it("should allow clear()", function() {
var complete = false;
var _error, _result1, _result2;
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadWriteContext();
context.put("key1", "value1", function(err, result) {
_error = _error || err;
context.put("key2", "value2", function(err, result) {
_error = _error || err;
context.clear(function(err) {
_error = _error || err;
context.get("key1", function(err, result) {
_error = _error || err;
_result1 = result;
context.get("key2", function(err, result) {
_error = _error || err;
_result2 = result;
complete = true;
});
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result1).toEqual(null);
expect(_result2).toEqual(null);
});
});
it("should fail when trying to write on ReadOnlyContext", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadOnlyContext();
context.put("key1", "value1", function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).toEqual(null);
});
});
});
});

View File

@ -1,17 +0,0 @@
describe("IDBFS.Providers", function() {
it("is defined", function() {
expect(typeof IDBFS.FileSystem.providers).not.toEqual(undefined);
});
it("has IndexedDB constructor", function() {
expect(typeof IDBFS.FileSystem.providers.IndexedDB).toEqual('function');
});
it("has Memory constructor", function() {
expect(typeof IDBFS.FileSystem.providers.Memory).toEqual('function');
});
it("has a Default constructor", function() {
expect(typeof IDBFS.FileSystem.providers.Default).toEqual('function');
});
});

View File

@ -0,0 +1,192 @@
define(["IDBFS"], function(IDBFS) {
describe("IDBFS.FileSystem.providers.IndexedDB", function() {
it("is supported -- if it isn't, none of these tests can run.", function() {
expect(IDBFS.FileSystem.providers.IndexedDB.isSupported()).toEqual(true);
});
it("has open, getReadOnlyContext, and getReadWriteContext instance methods", function() {
var indexedDBProvider = new IDBFS.FileSystem.providers.IndexedDB();
expect(typeof indexedDBProvider.open).toEqual('function');
expect(typeof indexedDBProvider.getReadOnlyContext).toEqual('function');
expect(typeof indexedDBProvider.getReadWriteContext).toEqual('function');
});
describe("open an IndexedDB provider", function() {
beforeEach(function() {
this.db_name = mk_db_name();
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
});
it("should open a new IndexedDB database", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
_result = firstAccess;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(true);
});
});
});
describe("Read/Write operations on an IndexedDB provider", function() {
beforeEach(function() {
this.db_name = mk_db_name();
});
afterEach(function() {
indexedDB.deleteDatabase(this.db_name);
});
it("should allow put() and get()", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadWriteContext();
context.put("key", "value", function(err, result) {
_error = _error || err;
context.get("key", function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual("value");
});
});
it("should allow delete()", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadWriteContext();
context.put("key", "value", function(err, result) {
_error = _error || err;
context.delete("key", function(err, result) {
_error = _error || err;
context.get("key", function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(null);
});
});
it("should allow clear()", function() {
var complete = false;
var _error, _result1, _result2;
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadWriteContext();
context.put("key1", "value1", function(err, result) {
_error = _error || err;
context.put("key2", "value2", function(err, result) {
_error = _error || err;
context.clear(function(err) {
_error = _error || err;
context.get("key1", function(err, result) {
_error = _error || err;
_result1 = result;
context.get("key2", function(err, result) {
_error = _error || err;
_result2 = result;
complete = true;
});
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result1).toEqual(null);
expect(_result2).toEqual(null);
});
});
it("should fail when trying to write on ReadOnlyContext", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.IndexedDB(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadOnlyContext();
context.put("key1", "value1", function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).toEqual(null);
});
});
});
});
});

View File

@ -0,0 +1,175 @@
define(["IDBFS"], function(IDBFS) {
describe("IDBFS.FileSystem.providers.Memory", function() {
it("is supported -- if it isn't, none of these tests can run.", function() {
expect(IDBFS.FileSystem.providers.Memory.isSupported()).toEqual(true);
});
it("has open, getReadOnlyContext, and getReadWriteContext instance methods", function() {
var indexedDBProvider = new IDBFS.FileSystem.providers.Memory();
expect(typeof indexedDBProvider.open).toEqual('function');
expect(typeof indexedDBProvider.getReadOnlyContext).toEqual('function');
expect(typeof indexedDBProvider.getReadWriteContext).toEqual('function');
});
describe("open an Memory provider", function() {
it("should open a new Memory database", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
_result = firstAccess;
complete = true;
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(true);
});
});
});
describe("Read/Write operations on an Memory provider", function() {
it("should allow put() and get()", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadWriteContext();
context.put("key", "value", function(err, result) {
_error = _error || err;
context.get("key", function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual("value");
});
});
it("should allow delete()", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadWriteContext();
context.put("key", "value", function(err, result) {
_error = _error || err;
context.delete("key", function(err, result) {
_error = _error || err;
context.get("key", function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result).toEqual(null);
});
});
it("should allow clear()", function() {
var complete = false;
var _error, _result1, _result2;
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadWriteContext();
context.put("key1", "value1", function(err, result) {
_error = _error || err;
context.put("key2", "value2", function(err, result) {
_error = _error || err;
context.clear(function(err) {
_error = _error || err;
context.get("key1", function(err, result) {
_error = _error || err;
_result1 = result;
context.get("key2", function(err, result) {
_error = _error || err;
_result2 = result;
complete = true;
});
});
});
});
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toEqual(null);
expect(_result1).toEqual(null);
expect(_result2).toEqual(null);
});
});
it("should fail when trying to write on ReadOnlyContext", function() {
var complete = false;
var _error, _result;
var provider = new IDBFS.FileSystem.providers.Memory(this.db_name);
provider.open(function(err, firstAccess) {
_error = err;
var context = provider.getReadOnlyContext();
context.put("key1", "value1", function(err, result) {
_error = _error || err;
_result = result;
complete = true;
});
});
waitsFor(function() {
return complete;
}, 'test to complete', DEFAULT_TIMEOUT);
runs(function() {
expect(_error).toBeDefined();
expect(_result).toEqual(null);
});
});
});
});
});

View File

@ -0,0 +1,19 @@
define(["IDBFS"], function(IDBFS) {
describe("IDBFS.Providers", function() {
it("is defined", function() {
expect(typeof IDBFS.FileSystem.providers).not.toEqual(undefined);
});
it("has IndexedDB constructor", function() {
expect(typeof IDBFS.FileSystem.providers.IndexedDB).toEqual('function');
});
it("has Memory constructor", function() {
expect(typeof IDBFS.FileSystem.providers.Memory).toEqual('function');
});
it("has a Default constructor", function() {
expect(typeof IDBFS.FileSystem.providers.Default).toEqual('function');
});
});
});

40
tests/test-manifest.js Normal file
View File

@ -0,0 +1,40 @@
define([
/**
* Add your test spec files to the list in order to
* get them running by default.
*/
// IDBFS
"spec/idbfs.spec",
// IDBFS.FileSystem.*
"spec/fs.spec",
"spec/fs.stat.spec",
"spec/fs.lstat.spec",
"spec/fs.mkdir.spec",
"spec/fs.readdir.spec",
"spec/fs.rmdir.spec",
"spec/fs.open.spec",
"spec/fs.write.spec",
"spec/fs.writeFile-readFile.spec",
"spec/fs.read.spec",
"spec/fs.close.spec",
"spec/fs.link.spec",
"spec/fs.unlink.spec",
"spec/fs.rename.spec",
"spec/fs.lseek.spec",
"spec/fs.symlink.spec",
"spec/fs.readlink.spec",
"spec/path-resolution.spec",
// IDBFS.FileSystem.providers.*
"spec/providers/providers.spec",
"spec/providers/providers.memory.spec",
"spec/providers/providers.indexeddb.spec",
// Ported node.js tests (filenames match names in https://github.com/joyent/node/tree/master/test)
"spec/node-js/simple/test-fs-mkdir",
"spec/node-js/simple/test-fs-null-bytes"
]);