From f9520fa8111517d162b0c96be83bba567f0a5c59 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 20 Apr 2015 17:50:52 +0000 Subject: [PATCH 1/9] Fixes +6095. Only see kaefer output with debug=3 --- configs/client-default.js | 1 + node_modules/architect/architect.js | 2 +- plugins/c9.vfs.client/vfs_client.js | 7 +++++-- plugins/c9.vfs.standalone/standalone.js | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/configs/client-default.js b/configs/client-default.js index ad581a8a..3b0c06e8 100644 --- a/configs/client-default.js +++ b/configs/client-default.js @@ -21,6 +21,7 @@ module.exports = function(options) { var workspaceDir = options.workspaceDir; var debug = options.debug !== undefined ? options.debug : false; + var collab = options.collab; var packaging = options.packaging; var staticPrefix = options.staticPrefix; diff --git a/node_modules/architect/architect.js b/node_modules/architect/architect.js index 17c5fe43..9b2d602a 100644 --- a/node_modules/architect/architect.js +++ b/node_modules/architect/architect.js @@ -7,7 +7,7 @@ var EventEmitter = events.EventEmitter; var exports = {}; -var DEBUG = typeof location != "undefined" && location.href.match(/debug=[12]/) ? true : false; +var DEBUG = typeof location != "undefined" && location.href.match(/debug=[123]/) ? true : false; // Only define Node-style usage using sync I/O if in node. if (typeof module === "object") (function () { diff --git a/plugins/c9.vfs.client/vfs_client.js b/plugins/c9.vfs.client/vfs_client.js index 31ec4845..5339ee80 100644 --- a/plugins/c9.vfs.client/vfs_client.js +++ b/plugins/c9.vfs.client/vfs_client.js @@ -39,6 +39,9 @@ define(function(require, exports, module) { var protocolVersion = require("kaefer/version").protocol; var smith = require("smith"); var URL = require("url"); + var DEBUG = options.debug + && (typeof location == "undefined" + || location.href.indexOf("debug=3") > -1); // The connected vfs unique id var id; @@ -76,11 +79,11 @@ define(function(require, exports, module) { if (loaded) return false; loaded = true; - smith.debug = options.debug; + smith.debug = DEBUG; connection = connectClient(connectEngine, { preConnectCheck: preConnectCheck, - debug: options.debug + debug: DEBUG }); connection.on("away", emit.bind(null, "away")); diff --git a/plugins/c9.vfs.standalone/standalone.js b/plugins/c9.vfs.standalone/standalone.js index 83ddbf60..9aa56371 100644 --- a/plugins/c9.vfs.standalone/standalone.js +++ b/plugins/c9.vfs.standalone/standalone.js @@ -119,7 +119,7 @@ function plugin(options, imports, register) { token: req.params.token }); - opts.options.debug = req.params.debug == 1; + opts.options.debug = req.params.debug !== undefined; res.setHeader("Cache-Control", "no-cache, no-store"); res.render(__dirname + "/views/standalone.html.ejs", { architectConfig: getConfig(configType, opts), From c36c4210032d587006ea7c53b1852bc7ada1063e Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Mon, 20 Apr 2015 23:51:50 +0000 Subject: [PATCH 2/9] Using preview to display test results --- configs/client-default.js | 4 + package.json | 2 +- plugins/c9.ide.ace/themes.js | 4 +- plugins/c9.ide.plugins/debug.js | 23 +- .../templates/plugin.default/plugin_test.js | 2 +- plugins/c9.ide.plugins/test.html | 60 +++ plugins/c9.ide.plugins/test.js | 409 ++++++++---------- plugins/c9.ide.ui/menus.js | 26 +- .../views/standalone.html.ejs | 4 +- 9 files changed, 294 insertions(+), 240 deletions(-) create mode 100644 plugins/c9.ide.plugins/test.html diff --git a/configs/client-default.js b/configs/client-default.js index 3b0c06e8..39874673 100644 --- a/configs/client-default.js +++ b/configs/client-default.js @@ -100,6 +100,10 @@ module.exports = function(options) { { packagePath: "plugins/c9.ide.plugins/market" }, + { + packagePath: "plugins/c9.ide.plugins/test", + staticPrefix: staticPrefix + "/plugins/c9.ide.plugins" + }, // VFS "plugins/c9.vfs.client/vfs.ping", diff --git a/package.json b/package.json index 71822a2e..93d696eb 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", "c9.ide.openfiles": "#28a4f5af16", - "c9.ide.preview": "#dba2f4214d", + "c9.ide.preview": "#66fb343b5d", "c9.ide.preview.browser": "#ac18aaf31d", "c9.ide.preview.markdown": "#ab8d30ad9f", "c9.ide.pubsub": "#b83cf15ade", diff --git a/plugins/c9.ide.ace/themes.js b/plugins/c9.ide.ace/themes.js index 94fe9cce..a1cd5ea5 100644 --- a/plugins/c9.ide.ace/themes.js +++ b/plugins/c9.ide.ace/themes.js @@ -35,10 +35,10 @@ define(function(require, exports, module) { if (!drawn) return; var list = getThemes(); - plugin.form.update({ + plugin.form.update([{ id: "syntax", items: list - }); + }]); } ace.on("addTheme", update); diff --git a/plugins/c9.ide.plugins/debug.js b/plugins/c9.ide.plugins/debug.js index 1e7b358e..0b95e0b0 100644 --- a/plugins/c9.ide.plugins/debug.js +++ b/plugins/c9.ide.plugins/debug.js @@ -36,7 +36,9 @@ define(function(require, exports, module) { /***** Initialization *****/ var plugin = new Plugin("Ajax.org", main.consumes); - // var emit = plugin.getEmitter(); + var emit = plugin.getEmitter(); + + var plugins = []; var ENABLED = c9.location.indexOf("debug=2") > -1; var HASSDK = c9.location.indexOf("sdk=0") === -1; @@ -60,7 +62,7 @@ define(function(require, exports, module) { : "?debug=2"); window.open(url); } - }), 100100, plugin); + }), 900, plugin); if (!ENABLED) return; @@ -104,7 +106,7 @@ define(function(require, exports, module) { menus.addItemByPath("Tools/Developer/Restart Plugin", new ui.item({ command: "restartplugin" - }), 100100, plugin); + }), 1000, plugin); } /***** Methods *****/ @@ -174,6 +176,7 @@ define(function(require, exports, module) { cfg.apikey = "0000000000000000000000000000="; config.push(cfg); + plugins.push(name + "/" + path); }); // Set version for package manager @@ -231,6 +234,8 @@ define(function(require, exports, module) { load(); }, function(){ + emit.sticky("ready"); + if (!config.length) return; // Load config @@ -487,11 +492,23 @@ define(function(require, exports, module) { */ get architect(){ throw new Error(); }, set architect(v){ architect = v; }, + /** + * + */ + get plugins(){ return plugins; }, + + _events: [ + /** + * @event ready + */ + "ready" + ], /** * */ addStaticPlugin: addStaticPlugin, + /** * */ diff --git a/plugins/c9.ide.plugins/templates/plugin.default/plugin_test.js b/plugins/c9.ide.plugins/templates/plugin.default/plugin_test.js index 13007893..72b1a7fa 100644 --- a/plugins/c9.ide.plugins/templates/plugin.default/plugin_test.js +++ b/plugins/c9.ide.plugins/templates/plugin.default/plugin_test.js @@ -21,7 +21,7 @@ define(function(require, exports, module) { /***** Initialization *****/ - describe("The module", function(){ + describe(myplugin.name, function(){ this.timeout(2000); beforeEach(function() { diff --git a/plugins/c9.ide.plugins/test.html b/plugins/c9.ide.plugins/test.html new file mode 100644 index 00000000..309727c7 --- /dev/null +++ b/plugins/c9.ide.plugins/test.html @@ -0,0 +1,60 @@ + + + + + Test Runner + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/plugins/c9.ide.plugins/test.js b/plugins/c9.ide.plugins/test.js index c5fd81ad..fb082a19 100644 --- a/plugins/c9.ide.plugins/test.js +++ b/plugins/c9.ide.plugins/test.js @@ -1,85 +1,26 @@ -//@TODO look at jasmine instead - -require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], function() { - -mocha.setup('bdd'); - mocha.bail(false); - mocha.ignoreLeaks(true); -mocha.run(done) -/*global Mocha, mocha*/ - mocha.reporter(function(runner) { - Mocha.reporters.Base.call(this, runner); - Mocha.reporters.HTML.call(this, runner); - - var tests = []; - var stats = this.stats; - mocha.report = { stats: stats, tests: tests }; - - runner.on('test end', function(test) { - stats.percent = stats.tests / runner.total * 100 | 0; - tests.push(clean(test)); - }); - - runner.on('end', function() { - console.log(JSON.stringify(mocha.report, null, 4)); - }); - - function parseError(err) { - var str = err.stack || err.toString(); - - // FF / Opera do not add the message - if (!~str.indexOf(err.message)) { - str = err.message + '\n' + str; - } - - // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we - // check for the result of the stringifying. - if ('[object Error]' == str) str = err.message; - - // Safari doesn't give you a stack. Let's at least provide a source line. - if (!err.stack && err.sourceURL && err.line !== undefined) { - str += "\n(" + err.sourceURL + ":" + err.line + ")"; - } - return str; - } - function clean(test) { - return { - title: test.title, - duration: test.duration, - error: test.err && parseError(test.err), - speed: test.speed, - state: test.state - }; - } - }); - -/*global requirejs*/ +/* global requirejs */ define(function(require, exports, module) { main.consumes = [ - "Plugin", "vfs", "fs", "plugin.loader", "c9", "ext", "watcher", - "dialog.notification" + "Plugin", "plugin.debug", "c9", "menus", "ui", "ext", "preview" ]; - main.provides = ["plugin.editor"]; + main.provides = ["plugin.test"]; return main; function main(options, imports, register) { var Plugin = imports.Plugin; - var vfs = imports.vfs; - var watcher = imports.watcher; - var ext = imports.ext; - var fs = imports.fs; var c9 = imports.c9; - var loader = imports["plugin.loader"]; - var notify = imports["dialog.notification"].show; - - var dirname = require("path").dirname; - - var architect; + var menus = imports.menus; + var preview = imports.preview; + var ext = imports.ext; + var ui = imports.ui; + var debug = imports["plugin.debug"]; /***** Initialization *****/ var plugin = new Plugin("Ajax.org", main.consumes); - // var emit = plugin.getEmitter(); + var emit = plugin.getEmitter(); + + var chai, mocha, iframe, architect; var ENABLED = c9.location.indexOf("debug=2") > -1; @@ -90,187 +31,109 @@ define(function(require, exports, module) { if (!ENABLED) return; - notify("
You are in Debug Mode. " - + "Don't forget to open the browser's dev tools to see any errors.", - false); - - fs.readdir("~/.c9/plugins", function(err, list){ - if (err) return console.error(err); + debug.once("ready", function(){ + menus.addItemByPath("Tools/Developer/Tests", null, 200, plugin); - var names = loader.plugins; - var toLoad = []; - - list.forEach(function(stat){ - var name = stat.name; - // If the plugin doesn't exist - if (names.indexOf(name) == -1 && name.charAt(0) != ".") - toLoad.push(name); + debug.plugins.forEach(function(name, i){ + menus.addItemByPath("Tools/Developer/Tests/" + name.replace(/\//g, "\\/"), new ui.item({ + onclick: function(){ + run(name, function(err){ + if (err) console.error(err); + }); + } + }), i + 1, plugin); }); - - loadPlugins(toLoad); }); + + ext.on("register", function(){ + // TODO + }, plugin); + ext.on("unregister", function(){ + // TODO + }, plugin); } /***** Methods *****/ - function loadPlugins(list){ - if (!vfs.connected) { - vfs.once("connect", loadPlugins.bind(this, config)); - return; + function setReferences(c, m){ + chai = c; + mocha = m; + + emit("ready"); + } + + function loadIframe(callback){ + var url = options.staticPrefix + "/test.html"; + if (url.indexOf("http") !== 0) + url = location.origin + url; + + var tab = preview.openPreview(url, null, true); + iframe = tab.document.getSession().iframe; + iframe.addEventListener("load", handle); + iframe.addEventListener("error", onError); + + function handle(err){ + iframe.removeEventListener("load", handle); + iframe.removeEventListener("error", onError); + callback(err instanceof Error ? err : null); } - var config = []; - var count = list.length; + function onError(e){ + debugger; // e.?? + handle(new Error()); + } + } + + function loadTestSuite(name, callback){ + // Clear require cache + requirejs.undef("plugins/" + name + "_test"); // global - function next(name){ - if (!name) { - if (--count === 0) finish(); - return; - } + // Load plugin + architect.loadAdditionalPlugins([{ + packagePath: "plugins/" + name + "_test" + }], function(err){ + callback(err); + }); + } + + function run(pluginName, callback){ + // Load test runner + loadIframe(function(err){ + if (err) return callback(err); - // Fetch package.json - fs.readFile("~/.c9/plugins/" + name + "/package.json", function(err, data){ - if (err) { - console.error(err); - return next(); - } + // Wait until iframe is loaded + plugin.once("ready", function(){ - try{ - var options = JSON.parse(data); - if (!options.plugins) - throw new Error("Missing plugins property in package.json of " + name); - } - catch(e){ - console.error(err); - return next(); - } - - options.plugins.forEach(function(path){ - var pluginPath = "~/.c9/plugins/" + name + "/" + path + ".js"; - var url = vfs.url(pluginPath); + // Load the test for the plugin + loadTestSuite(pluginName, function(err){ + if (err) return callback(err); - // Watch project path - watch(pluginPath); - - config.push({ - packagePath: url, - staticPrefix: dirname(url), - apikey: "00000000-0000-4000-y000-" + String(config.length).pad(12, "0") + // Run the test + mocha.run(function(){ + + // Done + callback(); }); }); - next(); - }); - } - - function finish(){ - // Load config - architect.loadAdditionalPlugins(config, function(err){ - if (err) console.error(err); - }); - } - - list.forEach(next); - } - - // Check if require.s.contexts._ can help watching all dependencies - function watch(path){ - watcher.watch(path); - - watcher.on("change", function(e){ - if (e.path == path) - reloadPackage(path.replace(/^~\/\.c9\//, "")); - }); - watcher.on("delete", function(e){ - if (e.path == path) - reloadPackage(path.replace(/^~\/\.c9\//, "")); - }); - watcher.on("failed", function(e){ - if (e.path == path) { - setTimeout(function(){ - watcher.watch(path); // Retries once after 1s - }); - } - }); - } - - function reloadPackage(path){ - var unloaded = []; - - function recurUnload(name){ - var plugin = architect.services[name]; - unloaded.push(name); - - // Find all the dependencies - var deps = ext.getDependencies(plugin.name); - - // Unload all the dependencies (and their deps) - deps.forEach(function(name){ - recurUnload(name); }); - // Unload plugin - plugin.unload(); - } - - // Recursively unload plugin - var p = architect.lut[path]; - if (p.provides) { // Plugin might not been initialized all the way - p.provides.forEach(function(name){ - recurUnload(name); - }); - } - - // create reverse lookup table - var rlut = {}; - for (var packagePath in architect.lut) { - var provides = architect.lut[packagePath].provides; - if (provides) { // Plugin might not been initialized all the way - provides.forEach(function(name){ - rlut[name] = packagePath; - }); - } - } - - // Build config of unloaded plugins - var config = [], done = {}; - unloaded.forEach(function(name){ - var packagePath = rlut[name]; - - // Make sure we include each plugin only once - if (done[packagePath]) return; - done[packagePath] = true; - - var options = architect.lut[packagePath]; - delete options.provides; - delete options.consumes; - delete options.setup; - - config.push(options); - - // Clear require cache - requirejs.undef(options.packagePath); // global - }); - - // Load all plugins again - architect.loadAdditionalPlugins(config, function(err){ - if (err) console.error(err); - }); + // Load iframe with new test runner frame + iframe.contentWindow.start(plugin); + }) } /***** Lifecycle *****/ plugin.on("load", function() { load(); - }); - plugin.on("enable", function() { - - }); - plugin.on("disable", function() { - }); plugin.on("unload", function() { loaded = false; + chai = null; + mocha = null; + iframe = null; + architect = null; }); /***** Register and define API *****/ @@ -288,12 +151,104 @@ define(function(require, exports, module) { /** * */ - reloadPackage: reloadPackage + get describe(){ return mocha.describe; }, + /** + * + */ + get it(){ return mocha.it; }, + /** + * + */ + get before(){ return mocha.before; }, + /** + * + */ + get after(){ return mocha.after; }, + /** + * + */ + get beforeEach(){ return mocha.beforeEach; }, + /** + * + */ + get afterEach(){ return mocha.afterEach; }, + /** + * + */ + get assert(){ return chai.assert; }, + /** + * + */ + get expect(){ return chai.expect; }, + + /** + * + */ + setReferences: setReferences, + + /** + * + */ + run: run }); register(null, { - "plugin.editor": plugin + "plugin.test": plugin }); } }); -}); \ No newline at end of file + +//@TODO look at jasmine instead + +// require(["lib/architect/architect", "lib/chai/chai", "/vfs-root"], function() { + +// mocha.setup('bdd'); +// mocha.bail(false); +// mocha.ignoreLeaks(true); +// mocha.run(done) +// /*global Mocha, mocha*/ +// mocha.reporter(function(runner) { +// Mocha.reporters.Base.call(this, runner); +// Mocha.reporters.HTML.call(this, runner); + +// var tests = []; +// var stats = this.stats; +// mocha.report = { stats: stats, tests: tests }; + +// runner.on('test end', function(test) { +// stats.percent = stats.tests / runner.total * 100 | 0; +// tests.push(clean(test)); +// }); + +// runner.on('end', function() { +// console.log(JSON.stringify(mocha.report, null, 4)); +// }); + +// function parseError(err) { +// var str = err.stack || err.toString(); + +// // FF / Opera do not add the message +// if (!~str.indexOf(err.message)) { +// str = err.message + '\n' + str; +// } + +// // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we +// // check for the result of the stringifying. +// if ('[object Error]' == str) str = err.message; + +// // Safari doesn't give you a stack. Let's at least provide a source line. +// if (!err.stack && err.sourceURL && err.line !== undefined) { +// str += "\n(" + err.sourceURL + ":" + err.line + ")"; +// } +// return str; +// } +// function clean(test) { +// return { +// title: test.title, +// duration: test.duration, +// error: test.err && parseError(test.err), +// speed: test.speed, +// state: test.state +// }; +// } +// }); \ No newline at end of file diff --git a/plugins/c9.ide.ui/menus.js b/plugins/c9.ide.ui/menus.js index 94461231..57206a7b 100644 --- a/plugins/c9.ide.ui/menus.js +++ b/plugins/c9.ide.ui/menus.js @@ -181,6 +181,21 @@ define(function(require, exports, module) { /***** Methods *****/ + function splitSafe(path){ + var pieces = [], escaped; + path.split("/").forEach(function(n){ + if (escaped) n = escaped + "/" + n; + escaped = n.substr(-1) == "\\" ? n : false; //.substr(n, n.length - 1) + if (!escaped) pieces.push(n); + }); + if (escaped) pieces.push(escaped); + return pieces; + } + + function popSafe(path){ + return splitSafe(path).pop().replace(/\\\//g, "/"); + } + function init(){ inited = true; layout.initMenus(plugin); @@ -365,7 +380,8 @@ define(function(require, exports, module) { if (item) { item.setAttribute("submenu", menu); item.setAttribute("caption", - apf.escapeXML((debug ? "(" + index + ")" : "") + name.split("/").pop())); + apf.escapeXML((debug ? "(" + index + ")" : "") + + popSafe(name))); items[name] = item; } else { @@ -374,7 +390,7 @@ define(function(require, exports, module) { item = items[name] = new apf.item({ submenu: menu, caption: (debug ? "(" + index + ") " : "") + - name.split("/").pop() + popSafe(name) }); } else { @@ -402,7 +418,7 @@ define(function(require, exports, module) { function setMenuItem(parent, name, menuItem, index, item, plugin) { if (item && !item.nodeFunc) plugin = item, item = null; - var itemName = name.split("/").pop(); + var itemName = popSafe(name); if (itemName == "~") name += index; @@ -462,7 +478,7 @@ define(function(require, exports, module) { assert(plugin !== undefined, "addItemByPath requires a plugin argument"); - var steps = path.split("/"), name, p = [], isLast; + var steps = splitSafe(path), name, p = [], isLast; var curpath; if (!menuItem) @@ -568,7 +584,7 @@ define(function(require, exports, module) { if (!items[path]) throw new Error("Could not find menu item " + path); - var steps = path.split("/"), p = [], item; + var steps = splitSafe(path), p = [], item; var curpath; for (var name, i = 0, l = steps.length; i < l; i++) { diff --git a/plugins/c9.vfs.standalone/views/standalone.html.ejs b/plugins/c9.vfs.standalone/views/standalone.html.ejs index c1162d09..008507a3 100644 --- a/plugins/c9.vfs.standalone/views/standalone.html.ejs +++ b/plugins/c9.vfs.standalone/views/standalone.html.ejs @@ -101,7 +101,9 @@ }); app.on("service", function(name, plugin, options){ - if (name == "plugin.loader" || name == "plugin.installer" || name == "plugin.debug" || name == "plugin.manager") + if (name == "plugin.loader" || name == "plugin.installer" + || name == "plugin.debug" || name == "plugin.manager" + || name == "plugin.test") plugin.architect = app; if (!plugin.name) plugin.name = name; From 2a7d0887bbf72bafb31c310487f0440a1de872c0 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 21 Apr 2015 01:27:25 +0000 Subject: [PATCH 3/9] support reload of tests --- package.json | 2 +- plugins/c9.ide.plugins/test.js | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 93d696eb..9f948c04 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "c9.ide.navigate": "#64156c7f4a", "c9.ide.newresource": "#f1f0624768", "c9.ide.openfiles": "#28a4f5af16", - "c9.ide.preview": "#66fb343b5d", + "c9.ide.preview": "#0bd8dd6e8c", "c9.ide.preview.browser": "#ac18aaf31d", "c9.ide.preview.markdown": "#ab8d30ad9f", "c9.ide.pubsub": "#b83cf15ade", diff --git a/plugins/c9.ide.plugins/test.js b/plugins/c9.ide.plugins/test.js index fb082a19..4379ac36 100644 --- a/plugins/c9.ide.plugins/test.js +++ b/plugins/c9.ide.plugins/test.js @@ -1,7 +1,8 @@ /* global requirejs */ define(function(require, exports, module) { main.consumes = [ - "Plugin", "plugin.debug", "c9", "menus", "ui", "ext", "preview" + "Plugin", "plugin.debug", "c9", "menus", "ui", "ext", "preview", + "preview.browser" ]; main.provides = ["plugin.test"]; return main; @@ -14,6 +15,7 @@ define(function(require, exports, module) { var ext = imports.ext; var ui = imports.ui; var debug = imports["plugin.debug"]; + var browser = imports["preview.browser"]; /***** Initialization *****/ @@ -51,6 +53,29 @@ define(function(require, exports, module) { ext.on("unregister", function(){ // TODO }, plugin); + + var reloading; + function loadPreview(url, session){ + var idx = url.indexOf(options.staticPrefix); + if (!reloading && idx > -1) { + reloading = true; + + var name = session.doc.meta.pluginName; + run(name, function(err){ + if (err) console.error(err); + }); + + reloading = false; + } + } + + // browser.on("navigate", function(e){ + // if (!e.session.doc.meta.plugName) + // debugger; + // }); + browser.on("reload", function(e){ + loadPreview(e.session.path, e.session); + }); } /***** Methods *****/ @@ -62,7 +87,7 @@ define(function(require, exports, module) { emit("ready"); } - function loadIframe(callback){ + function loadIframe(pluginName, callback){ var url = options.staticPrefix + "/test.html"; if (url.indexOf("http") !== 0) url = location.origin + url; @@ -82,6 +107,8 @@ define(function(require, exports, module) { debugger; // e.?? handle(new Error()); } + + tab.document.meta.pluginName = pluginName; } function loadTestSuite(name, callback){ @@ -98,7 +125,7 @@ define(function(require, exports, module) { function run(pluginName, callback){ // Load test runner - loadIframe(function(err){ + loadIframe(pluginName, function(err){ if (err) return callback(err); // Wait until iframe is loaded From fab18bea2c8268c92c0e9ba90b3d20c14d9784d6 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 21 Apr 2015 01:30:27 +0000 Subject: [PATCH 4/9] Test preview tabs should not be restored --- plugins/c9.ide.plugins/test.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/c9.ide.plugins/test.js b/plugins/c9.ide.plugins/test.js index 4379ac36..df2584ed 100644 --- a/plugins/c9.ide.plugins/test.js +++ b/plugins/c9.ide.plugins/test.js @@ -69,10 +69,6 @@ define(function(require, exports, module) { } } - // browser.on("navigate", function(e){ - // if (!e.session.doc.meta.plugName) - // debugger; - // }); browser.on("reload", function(e){ loadPreview(e.session.path, e.session); }); @@ -108,6 +104,7 @@ define(function(require, exports, module) { handle(new Error()); } + tab.document.meta.ignoreState = true; tab.document.meta.pluginName = pluginName; } From 914cbd4e49a63282fe32e6c6755a0af4227e7a6b Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 21 Apr 2015 01:48:05 +0000 Subject: [PATCH 5/9] Enable error for tests --- plugins/c9.cli.publish/publish.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/c9.cli.publish/publish.js b/plugins/c9.cli.publish/publish.js index 75fdbef2..eec65672 100644 --- a/plugins/c9.cli.publish/publish.js +++ b/plugins/c9.cli.publish/publish.js @@ -372,11 +372,10 @@ define(function(require, exports, module) { console.warn("WARNING: Plugin '" + name + "' is not listed in package.json."); warned = true; } - // @TODO temporarily disabled the requirement for tests while tests cannot actually run yet - // else if (!fs.existsSync(join(cwd, name.replace(/\.js$/, "_test.js")))) { - // console.warn("ERROR: Plugin '" + name + "' has no test associated with it."); - // failed = true; - // } + else if (!fs.existsSync(join(cwd, name.replace(/\.js$/, "_test.js")))) { + console.warn("ERROR: Plugin '" + name + "' has no test associated with it. There must be a file called '" + name + "_test.js' containing tests."); + failed = true; + } }); if (failed) From f2a2d76025db515bd8f08f16f21b649b461732ae Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 21 Apr 2015 01:53:37 +0000 Subject: [PATCH 6/9] Add better location --- plugins/c9.ide.plugins/test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/c9.ide.plugins/test.js b/plugins/c9.ide.plugins/test.js index df2584ed..8afc1b74 100644 --- a/plugins/c9.ide.plugins/test.js +++ b/plugins/c9.ide.plugins/test.js @@ -96,7 +96,7 @@ define(function(require, exports, module) { function handle(err){ iframe.removeEventListener("load", handle); iframe.removeEventListener("error", onError); - callback(err instanceof Error ? err : null); + callback(err instanceof Error ? err : null, tab); } function onError(e){ @@ -122,9 +122,11 @@ define(function(require, exports, module) { function run(pluginName, callback){ // Load test runner - loadIframe(pluginName, function(err){ + loadIframe(pluginName, function(err, tab){ if (err) return callback(err); + tab.editor.setLocation("Test for `" + pluginName + "`") + // Wait until iframe is loaded plugin.once("ready", function(){ From de2578c2dce7656bbeb542cdd7839bb00bca9f12 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 21 Apr 2015 01:54:01 +0000 Subject: [PATCH 7/9] tweak --- plugins/c9.ide.plugins/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/c9.ide.plugins/test.js b/plugins/c9.ide.plugins/test.js index 8afc1b74..cf813862 100644 --- a/plugins/c9.ide.plugins/test.js +++ b/plugins/c9.ide.plugins/test.js @@ -125,7 +125,7 @@ define(function(require, exports, module) { loadIframe(pluginName, function(err, tab){ if (err) return callback(err); - tab.editor.setLocation("Test for `" + pluginName + "`") + tab.editor.setLocation("Test for '" + pluginName + "'") // Wait until iframe is loaded plugin.once("ready", function(){ From d495c11fea60e33bfd73e012557f0f101feb64f3 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 21 Apr 2015 02:01:11 +0000 Subject: [PATCH 8/9] Dont show start in debug mode when in debug mode --- plugins/c9.ide.plugins/debug.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/c9.ide.plugins/debug.js b/plugins/c9.ide.plugins/debug.js index 0b95e0b0..a97e00e2 100644 --- a/plugins/c9.ide.plugins/debug.js +++ b/plugins/c9.ide.plugins/debug.js @@ -55,14 +55,17 @@ define(function(require, exports, module) { menus.addItemByPath("Tools/~", new ui.divider(), 100000, plugin); menus.addItemByPath("Tools/Developer", null, 100100, plugin); - menus.addItemByPath("Tools/Developer/Start in Debug Mode", new ui.item({ - onclick: function(){ - var url = location.href + (location.href.indexOf("?") > -1 - ? "&debug=2" - : "?debug=2"); - window.open(url); - } - }), 900, plugin); + + if (!ENABLED) { + menus.addItemByPath("Tools/Developer/Start in Debug Mode", new ui.item({ + onclick: function(){ + var url = location.href + (location.href.indexOf("?") > -1 + ? "&debug=2" + : "?debug=2"); + window.open(url); + } + }), 900, plugin); + } if (!ENABLED) return; From e3c2fb0c713f4cfdd1dc219141730748148450e6 Mon Sep 17 00:00:00 2001 From: Ruben Daniels Date: Tue, 21 Apr 2015 17:24:46 +0000 Subject: [PATCH 9/9] Change to url instead of text --- plugins/c9.ide.plugins/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/c9.ide.plugins/test.js b/plugins/c9.ide.plugins/test.js index cf813862..c6af4465 100644 --- a/plugins/c9.ide.plugins/test.js +++ b/plugins/c9.ide.plugins/test.js @@ -125,7 +125,7 @@ define(function(require, exports, module) { loadIframe(pluginName, function(err, tab){ if (err) return callback(err); - tab.editor.setLocation("Test for '" + pluginName + "'") + tab.editor.setLocation("test://" + pluginName) // Wait until iframe is loaded plugin.once("ready", function(){