Merge pull request +14145 from c9/fix-client-tests-2

Fix and unblacklist several clientside unit tests
pull/327/head
Harutyun Amirjanyan 2016-07-04 14:15:01 +04:00 zatwierdzone przez GitHub
commit bdc697cdc3
12 zmienionych plików z 60 dodań i 49 usunięć

25
node_modules/vfs-local/localfs.js wygenerowano vendored
Wyświetl plik

@ -429,8 +429,17 @@ module.exports = function setup(fsOptions) {
var meta = {}; var meta = {};
resolvePath(path, options, function (err, realpath) { resolvePath(path, options, function (err, realpath) {
if (err) return callback(err); if (err) return callback(err);
fn(realpath, function (err) { fn(realpath, function done(err) {
if (err) return callback(err); if (err) {
if (err.code == "ENOENT") {
return fs.exists(realpath, function(exists) {
if (exists) err.code = "EACCES";
callback(err);
});
} else {
return callback(err);
}
}
// Remove metadata // Remove metadata
resolvePath(WSMETAPATH + path, options, function (err, realpath) { resolvePath(WSMETAPATH + path, options, function (err, realpath) {
@ -1003,7 +1012,17 @@ module.exports = function setup(fsOptions) {
function rmdir(path, options, callback) { function rmdir(path, options, callback) {
if (options.recursive) { if (options.recursive) {
remove(path, function(path, callback) { remove(path, function(path, callback) {
execFile("rm", {args: ["-rf", path]}, callback); spawn("rm", {args: ["-rf", path], stdio: 'ignore'}, function(err, child) {
if (err) return callback(err);
child.process.on("close", function(code) {
if (code) {
var err = new Error("Permission denied.");
err.code = "EACCES";
return callback(err);
}
callback();
});
});
}, options, callback); }, options, callback);
} }
else { else {

Wyświetl plik

@ -58,7 +58,7 @@
"c9" "c9"
], ],
"c9plugins": { "c9plugins": {
"c9.ide.language": "#0e86345d39", "c9.ide.language": "#0426ee345b",
"c9.ide.language.core": "#bfb5dd2acc", "c9.ide.language.core": "#bfb5dd2acc",
"c9.ide.language.css": "#46ad561506", "c9.ide.language.css": "#46ad561506",
"c9.ide.language.generic": "#b47cbe58f9", "c9.ide.language.generic": "#b47cbe58f9",
@ -73,9 +73,9 @@
"c9.ide.language.codeintel": "#4e0a272229", "c9.ide.language.codeintel": "#4e0a272229",
"c9.ide.collab": "#e015881720", "c9.ide.collab": "#e015881720",
"c9.ide.local": "#9169fec157", "c9.ide.local": "#9169fec157",
"c9.ide.find": "#a2dfc3e306", "c9.ide.find": "#e632ecf4be",
"c9.ide.find.infiles": "#488db22ee1", "c9.ide.find.infiles": "#4484d6162d",
"c9.ide.find.replace": "#47a84af707", "c9.ide.find.replace": "#8468067976",
"c9.ide.run.debug": "#651451a7c2", "c9.ide.run.debug": "#651451a7c2",
"c9.automate": "#47e2c429c9", "c9.automate": "#47e2c429c9",
"c9.ide.ace.emmet": "#6dc4585e02", "c9.ide.ace.emmet": "#6dc4585e02",
@ -109,7 +109,7 @@
"c9.ide.recentfiles": "#7c099abf40", "c9.ide.recentfiles": "#7c099abf40",
"c9.ide.remote": "#301d2ab519", "c9.ide.remote": "#301d2ab519",
"c9.ide.processlist": "#2b12cd1bdd", "c9.ide.processlist": "#2b12cd1bdd",
"c9.ide.run": "#d661a7b847", "c9.ide.run": "#bf68394c6f",
"c9.ide.run.build": "#0598fff697", "c9.ide.run.build": "#0598fff697",
"c9.ide.run.debug.xdebug": "#054367574c", "c9.ide.run.debug.xdebug": "#054367574c",
"c9.ide.save": "#25a63f31e2", "c9.ide.save": "#25a63f31e2",

Wyświetl plik

@ -40,14 +40,6 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "/vfs-home"],
}, },
"plugins/c9.cli.bridge/bridge-client", "plugins/c9.cli.bridge/bridge-client",
// Mock plugins
{
consumes: [],
provides: [
"preferences", "ui"
],
setup: expect.html.mocked
},
{ {
consumes: ["bridge", "bridge.client"], consumes: ["bridge", "bridge.client"],
provides: [], provides: [],

Wyświetl plik

@ -122,9 +122,9 @@ define(function(require, module, exports) {
emit("quit"); emit("quit");
} }
function toExternalPath(path) { function toExternalPath(path, sep) {
if (plugin.platform == "win32") if (plugin.platform == "win32")
path = path.replace(/^[/]+/, "").replace(/[/]+/g, "\\"); path = path.replace(/^[/]+/, "").replace(/[/]+/g, sep || "\\");
return path; return path;
} }

Wyświetl plik

@ -208,20 +208,21 @@ define(function(require, exports, module) {
var reHome, reWorkspace, homeSub; var reHome, reWorkspace, homeSub;
plugin.$initPaths = function(home, workspaceDir) { plugin.$initPaths = function(home, workspaceDir) {
reHome = new RegExp("^" + plugin.escapeRegExp(home) + "(/|/?$)"); var pre = c9.platform == "win32" ? "/?" : "";
reHome = new RegExp("^" + pre + plugin.escapeRegExp(home) + "(/|/?$)");
var wd = workspaceDir.replace(/\/?$/, ""); var wd = workspaceDir.replace(/\/?$/, "");
reWorkspace = new RegExp("^" + plugin.escapeRegExp(wd) + "(/|/?$)"); reWorkspace = new RegExp("^" + pre + plugin.escapeRegExp(wd) + "(/|/?$)");
homeSub = "~/"; homeSub = "~/";
if (home == workspaceDir) { if (home == workspaceDir) {
reHome = new RegExp("^(" + plugin.escapeRegExp(home) + "|~)(/|/?$)"); reHome = new RegExp("^(" + pre + plugin.escapeRegExp(home) + "|~)(/|/?$)");
homeSub = "/"; homeSub = "/";
reWorkspace = null; reWorkspace = null;
} else if (reHome.test(workspaceDir)) { } else if (reHome.test(workspaceDir)) {
reWorkspace = new RegExp("^" + reWorkspace = new RegExp("^" + pre +
plugin.escapeRegExp(workspaceDir.replace(reHome, "~/")) + "(/|/?$)" plugin.escapeRegExp(workspaceDir.replace(reHome, "~/")) + "(/|/?$)"
); );
} else if (reWorkspace.test(home)) { } else if (reWorkspace.test(home)) {
reHome = new RegExp("^(" + plugin.escapeRegExp(home) + "|~)(/|/?$)"); reHome = new RegExp("^(" + pre + plugin.escapeRegExp(home) + "|~)(/|/?$)");
homeSub = home.replace(reWorkspace, "/").replace(/\/?$/, "/"); homeSub = home.replace(reWorkspace, "/").replace(/\/?$/, "/");
reWorkspace = null; reWorkspace = null;
} }

Wyświetl plik

@ -746,7 +746,7 @@ define(function(require, exports, module) {
} else if (node.status == "loading") { } else if (node.status == "loading") {
plugin.on("readdir", function listener(e) { plugin.on("readdir", function listener(e) {
if (e.path == subPath) { if (e.path == subPath) {
plugin.on("readdir", listener); plugin.off("readdir", listener);
recur(); recur();
} }
}); });

Wyświetl plik

@ -462,8 +462,9 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "events"],
fs.writeFile(before, text, function(err) { fs.writeFile(before, text, function(err) {
expect(fsCache.findNode(before), "start").to.exist; expect(fsCache.findNode(before), "start").to.exist;
expect(fsCache.findNode(after), "start").to.not.exist;
fs.rename(before, after, function() { fs.rename(before, after, function() {
expect(fsCache.findNode(after), "afer").to.exist; expect(fsCache.findNode(after), "after").to.exist;
expect(fsCache.findNode(before), "before").to.not.exist; expect(fsCache.findNode(before), "before").to.not.exist;
fs.rmfile(after, function(){ fs.rmfile(after, function(){
fsCache.off("update", c1); fsCache.off("update", c1);
@ -486,6 +487,7 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "events"],
fsCache.on("update", c1); fsCache.on("update", c1);
fs.writeFile(before, text, function(err) { fs.writeFile(before, text, function(err) {
expect(err).to.not.ok;
expect(fsCache.findNode(before), "start").to.exist; expect(fsCache.findNode(before), "start").to.exist;
fs.rename(before, after, function() { fs.rename(before, after, function() {
@ -500,11 +502,10 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "events"],
throw new Error("Wrong Event Count: " throw new Error("Wrong Event Count: "
+ count + " of 2"); + count + " of 2");
}); });
// Disabled: test fails only on CI server...
}); });
}); });
}); });
it.skip("should recursively update the nodes in cache when a dir is renamed", function(done) { it("should recursively update the nodes in cache when a dir is renamed", function(done) {
fs.rmdir("/rdir", {recursive:true}, function(){ fs.rmdir("/rdir", {recursive:true}, function(){
fs.copy("/dir", "/dir2", {recursive: true}, function(err) { fs.copy("/dir", "/dir2", {recursive: true}, function(err) {
if (err) throw err.message; if (err) throw err.message;
@ -535,7 +536,7 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root", "events"],
+ count + " of 3"); + count + " of 3");
}); });
}); });
}) });
}); });
}); });
}); });

Wyświetl plik

@ -18,12 +18,6 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"],
"plugins/c9.vfs.client/endpoint", "plugins/c9.vfs.client/endpoint",
"plugins/c9.ide.auth/auth", "plugins/c9.ide.auth/auth",
//Mock Plugins
{
consumes: ["Plugin"],
provides: ["auth.bootstrap", "info", "dialog.error"],
setup: expect.html.mocked
},
{ {
consumes: ["fs"], consumes: ["fs"],
provides: [], provides: [],
@ -285,6 +279,8 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"],
expect(exists).ok; expect(exists).ok;
fs.rmdir(vpath, {}, function(err, meta) { fs.rmdir(vpath, {}, function(err, meta) {
if (err.code == "EACCES") // node sends EACCES on windows
err.code = "ENOTDIR";
expect(err).property("code").equal("ENOTDIR"); expect(err).property("code").equal("ENOTDIR");
done(); done();
}); });

Wyświetl plik

@ -2,7 +2,7 @@
"use client"; "use client";
require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai) { require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], function (architect, chai, vfsRoot) {
var expect = chai.expect; var expect = chai.expect;
expect.setupArchitectTest([ expect.setupArchitectTest([
@ -11,7 +11,8 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
startdate: new Date(), startdate: new Date(),
debug: true, debug: true,
hosted: true, hosted: true,
local: false local: false,
platform: vfsRoot.indexOf(":") == -1 ? "linux" : "win32"
}, },
"plugins/c9.core/http-xhr", "plugins/c9.core/http-xhr",
"plugins/c9.core/ext", "plugins/c9.core/ext",
@ -19,14 +20,8 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
"plugins/c9.vfs.client/vfs_client", "plugins/c9.vfs.client/vfs_client",
"plugins/c9.vfs.client/endpoint", "plugins/c9.vfs.client/endpoint",
"plugins/c9.ide.auth/auth", "plugins/c9.ide.auth/auth",
// Mock plugins
{ {
consumes: [], consumes: ["proc", "c9"],
provides: ["auth.bootstrap", "info", "dialog.error"],
setup: expect.html.mocked
},
{
consumes: ["proc"],
provides: [], provides: [],
setup: main setup: main
} }
@ -34,6 +29,7 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
function main(options, imports, register) { function main(options, imports, register) {
var proc = imports.proc; var proc = imports.proc;
var c9 = imports.c9;
describe('proc', function() { describe('proc', function() {
describe('spawn()', function() { describe('spawn()', function() {
@ -117,10 +113,15 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
}); });
describe('pty()', function() { describe('pty()', function() {
this.timeout(30000); this.timeout(30000);
if (c9.platform == "win32")
return it.skip("Terminal Test", function(done) { done(); });
it("Terminal Test", function(done) { it("Terminal Test", function(done) {
var look = "--color=auto"; var look = "--color=auto";
if (c9.platform == "win32")
return done;
var args = ["-is"]; var args = ["-is"];
proc.pty("bash", { proc.pty("bash", {
args: args, args: args,

Wyświetl plik

@ -205,8 +205,7 @@ define(function(require, exports, module) {
} }
// Make sure home dir is marked correctly // Make sure home dir is marked correctly
path = path.replace(reHome, "~"); path = util.normalizePath(path);
if (path[0] != "/") path = "/" + path;
fs.stat(path, function(err, stat) { fs.stat(path, function(err, stat) {
if (err) { if (err) {

Wyświetl plik

@ -614,6 +614,8 @@ require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"],
}); });
}); });
it('should copy a node', function(done) { it('should copy a node', function(done) {
expect(fsCache.findNode("/dir/test.html")).to.ok;
expect(fsCache.findNode("/test.html")).to.not.ok;
tree.copy( tree.copy(
[fsCache.findNode("/dir/test.html")], [fsCache.findNode("/dir/test.html")],
fsCache.findNode("/"), fsCache.findNode("/"),

Wyświetl plik

@ -149,16 +149,16 @@ function plugin(options, imports, register) {
return next(); return next();
res.writeHead(200, {"Content-Type": "application/javascript"}); res.writeHead(200, {"Content-Type": "application/javascript"});
res.end("define(function(require, exports, module) { return '" res.end("define(function(require, exports, module) { return "
+ options.workspaceDir + "'; });"); + JSON.stringify(options.workspaceDir.replace(/\\/g, "/")) + "; });");
}); });
api.get("/vfs-home", function(req, res, next) { api.get("/vfs-home", function(req, res, next) {
if (!options.options.testing) if (!options.options.testing)
return next(); return next();
res.writeHead(200, {"Content-Type": "application/javascript"}); res.writeHead(200, {"Content-Type": "application/javascript"});
res.end("define(function(require, exports, module) { return '" res.end("define(function(require, exports, module) { return "
+ process.env.HOME + "'; });"); + JSON.stringify(process.env.HOME.replace(/\\/g, "/")) + "; });");
}); });
api.get("/update", function(req, res, next) { api.get("/update", function(req, res, next) {