kopia lustrzana https://github.com/c9/core
Using preview to display test results
rodzic
f9520fa811
commit
c36c421003
|
@ -100,6 +100,10 @@ module.exports = function(options) {
|
||||||
{
|
{
|
||||||
packagePath: "plugins/c9.ide.plugins/market"
|
packagePath: "plugins/c9.ide.plugins/market"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
packagePath: "plugins/c9.ide.plugins/test",
|
||||||
|
staticPrefix: staticPrefix + "/plugins/c9.ide.plugins"
|
||||||
|
},
|
||||||
|
|
||||||
// VFS
|
// VFS
|
||||||
"plugins/c9.vfs.client/vfs.ping",
|
"plugins/c9.vfs.client/vfs.ping",
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
"c9.ide.navigate": "#64156c7f4a",
|
"c9.ide.navigate": "#64156c7f4a",
|
||||||
"c9.ide.newresource": "#f1f0624768",
|
"c9.ide.newresource": "#f1f0624768",
|
||||||
"c9.ide.openfiles": "#28a4f5af16",
|
"c9.ide.openfiles": "#28a4f5af16",
|
||||||
"c9.ide.preview": "#dba2f4214d",
|
"c9.ide.preview": "#66fb343b5d",
|
||||||
"c9.ide.preview.browser": "#ac18aaf31d",
|
"c9.ide.preview.browser": "#ac18aaf31d",
|
||||||
"c9.ide.preview.markdown": "#ab8d30ad9f",
|
"c9.ide.preview.markdown": "#ab8d30ad9f",
|
||||||
"c9.ide.pubsub": "#b83cf15ade",
|
"c9.ide.pubsub": "#b83cf15ade",
|
||||||
|
|
|
@ -35,10 +35,10 @@ define(function(require, exports, module) {
|
||||||
if (!drawn) return;
|
if (!drawn) return;
|
||||||
|
|
||||||
var list = getThemes();
|
var list = getThemes();
|
||||||
plugin.form.update({
|
plugin.form.update([{
|
||||||
id: "syntax",
|
id: "syntax",
|
||||||
items: list
|
items: list
|
||||||
});
|
}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ace.on("addTheme", update);
|
ace.on("addTheme", update);
|
||||||
|
|
|
@ -36,7 +36,9 @@ define(function(require, exports, module) {
|
||||||
/***** Initialization *****/
|
/***** Initialization *****/
|
||||||
|
|
||||||
var plugin = new Plugin("Ajax.org", main.consumes);
|
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 ENABLED = c9.location.indexOf("debug=2") > -1;
|
||||||
var HASSDK = c9.location.indexOf("sdk=0") === -1;
|
var HASSDK = c9.location.indexOf("sdk=0") === -1;
|
||||||
|
@ -60,7 +62,7 @@ define(function(require, exports, module) {
|
||||||
: "?debug=2");
|
: "?debug=2");
|
||||||
window.open(url);
|
window.open(url);
|
||||||
}
|
}
|
||||||
}), 100100, plugin);
|
}), 900, plugin);
|
||||||
|
|
||||||
if (!ENABLED) return;
|
if (!ENABLED) return;
|
||||||
|
|
||||||
|
@ -104,7 +106,7 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
menus.addItemByPath("Tools/Developer/Restart Plugin", new ui.item({
|
menus.addItemByPath("Tools/Developer/Restart Plugin", new ui.item({
|
||||||
command: "restartplugin"
|
command: "restartplugin"
|
||||||
}), 100100, plugin);
|
}), 1000, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Methods *****/
|
/***** Methods *****/
|
||||||
|
@ -174,6 +176,7 @@ define(function(require, exports, module) {
|
||||||
cfg.apikey = "0000000000000000000000000000=";
|
cfg.apikey = "0000000000000000000000000000=";
|
||||||
|
|
||||||
config.push(cfg);
|
config.push(cfg);
|
||||||
|
plugins.push(name + "/" + path);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set version for package manager
|
// Set version for package manager
|
||||||
|
@ -231,6 +234,8 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
load();
|
load();
|
||||||
}, function(){
|
}, function(){
|
||||||
|
emit.sticky("ready");
|
||||||
|
|
||||||
if (!config.length) return;
|
if (!config.length) return;
|
||||||
|
|
||||||
// Load config
|
// Load config
|
||||||
|
@ -487,11 +492,23 @@ define(function(require, exports, module) {
|
||||||
*/
|
*/
|
||||||
get architect(){ throw new Error(); },
|
get architect(){ throw new Error(); },
|
||||||
set architect(v){ architect = v; },
|
set architect(v){ architect = v; },
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
get plugins(){ return plugins; },
|
||||||
|
|
||||||
|
_events: [
|
||||||
|
/**
|
||||||
|
* @event ready
|
||||||
|
*/
|
||||||
|
"ready"
|
||||||
|
],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
addStaticPlugin: addStaticPlugin,
|
addStaticPlugin: addStaticPlugin,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -21,7 +21,7 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
/***** Initialization *****/
|
/***** Initialization *****/
|
||||||
|
|
||||||
describe("The module", function(){
|
describe(myplugin.name, function(){
|
||||||
this.timeout(2000);
|
this.timeout(2000);
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Test Runner</title>
|
||||||
|
<link rel="stylesheet" href="/static/lib/mocha/mocha.css" />
|
||||||
|
<style>
|
||||||
|
HTML { overflow: auto !important }
|
||||||
|
body {
|
||||||
|
font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||||
|
padding: 60px 50px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
/*global mocha*/
|
||||||
|
var plugin, chai;
|
||||||
|
function start(p){
|
||||||
|
if (p) plugin = p;
|
||||||
|
|
||||||
|
if (plugin && chai) {
|
||||||
|
// Pass chai and mocha to the plugin
|
||||||
|
plugin.setReferences(chai, {
|
||||||
|
describe: describe,
|
||||||
|
it: it,
|
||||||
|
before: before,
|
||||||
|
after: after,
|
||||||
|
beforeEach: beforeEach,
|
||||||
|
afterEach: afterEach,
|
||||||
|
run: function(cb){
|
||||||
|
mocha.run(cb);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="mocha"></div>
|
||||||
|
<div id='jserror' width='100%' height='20px' style='font: 10px \"courier new\"; color: red; display: none;'></div>
|
||||||
|
|
||||||
|
<script src="/static/require.js"></script>
|
||||||
|
<script src="/static/lib/mocha/mocha.js"></script>
|
||||||
|
<script>
|
||||||
|
/*global mocha*/
|
||||||
|
mocha.setup('bdd');
|
||||||
|
mocha.bail(false);
|
||||||
|
mocha.ignoreLeaks(true);
|
||||||
|
|
||||||
|
window.onerror = function(msg){
|
||||||
|
var el = document.getElementById('jserror');
|
||||||
|
el.innerHTML+="<div class='jserr'>"+msg+"</div>";
|
||||||
|
};
|
||||||
|
|
||||||
|
require(["/static/lib/chai/chai.js"], function(c){
|
||||||
|
chai = c;
|
||||||
|
start();
|
||||||
|
});
|
||||||
|
//--></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,85 +1,26 @@
|
||||||
//@TODO look at jasmine instead
|
/* global requirejs */
|
||||||
|
|
||||||
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*/
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
main.consumes = [
|
main.consumes = [
|
||||||
"Plugin", "vfs", "fs", "plugin.loader", "c9", "ext", "watcher",
|
"Plugin", "plugin.debug", "c9", "menus", "ui", "ext", "preview"
|
||||||
"dialog.notification"
|
|
||||||
];
|
];
|
||||||
main.provides = ["plugin.editor"];
|
main.provides = ["plugin.test"];
|
||||||
return main;
|
return main;
|
||||||
|
|
||||||
function main(options, imports, register) {
|
function main(options, imports, register) {
|
||||||
var Plugin = imports.Plugin;
|
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 c9 = imports.c9;
|
||||||
var loader = imports["plugin.loader"];
|
var menus = imports.menus;
|
||||||
var notify = imports["dialog.notification"].show;
|
var preview = imports.preview;
|
||||||
|
var ext = imports.ext;
|
||||||
var dirname = require("path").dirname;
|
var ui = imports.ui;
|
||||||
|
var debug = imports["plugin.debug"];
|
||||||
var architect;
|
|
||||||
|
|
||||||
/***** Initialization *****/
|
/***** Initialization *****/
|
||||||
|
|
||||||
var plugin = new Plugin("Ajax.org", main.consumes);
|
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;
|
var ENABLED = c9.location.indexOf("debug=2") > -1;
|
||||||
|
|
||||||
|
@ -90,187 +31,109 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
if (!ENABLED) return;
|
if (!ENABLED) return;
|
||||||
|
|
||||||
notify("<div class='c9-readonly'>You are in <span style='color:rgb(245, 234, 15)'>Debug</span> Mode. "
|
debug.once("ready", function(){
|
||||||
+ "Don't forget to open the browser's dev tools to see any errors.",
|
menus.addItemByPath("Tools/Developer/Tests", null, 200, plugin);
|
||||||
false);
|
|
||||||
|
|
||||||
fs.readdir("~/.c9/plugins", function(err, list){
|
|
||||||
if (err) return console.error(err);
|
|
||||||
|
|
||||||
var names = loader.plugins;
|
debug.plugins.forEach(function(name, i){
|
||||||
var toLoad = [];
|
menus.addItemByPath("Tools/Developer/Tests/" + name.replace(/\//g, "\\/"), new ui.item({
|
||||||
|
onclick: function(){
|
||||||
list.forEach(function(stat){
|
run(name, function(err){
|
||||||
var name = stat.name;
|
if (err) console.error(err);
|
||||||
// If the plugin doesn't exist
|
});
|
||||||
if (names.indexOf(name) == -1 && name.charAt(0) != ".")
|
}
|
||||||
toLoad.push(name);
|
}), i + 1, plugin);
|
||||||
});
|
});
|
||||||
|
|
||||||
loadPlugins(toLoad);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ext.on("register", function(){
|
||||||
|
// TODO
|
||||||
|
}, plugin);
|
||||||
|
ext.on("unregister", function(){
|
||||||
|
// TODO
|
||||||
|
}, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Methods *****/
|
/***** Methods *****/
|
||||||
|
|
||||||
function loadPlugins(list){
|
function setReferences(c, m){
|
||||||
if (!vfs.connected) {
|
chai = c;
|
||||||
vfs.once("connect", loadPlugins.bind(this, config));
|
mocha = m;
|
||||||
return;
|
|
||||||
|
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 = [];
|
function onError(e){
|
||||||
var count = list.length;
|
debugger; // e.??
|
||||||
|
handle(new Error());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadTestSuite(name, callback){
|
||||||
|
// Clear require cache
|
||||||
|
requirejs.undef("plugins/" + name + "_test"); // global
|
||||||
|
|
||||||
function next(name){
|
// Load plugin
|
||||||
if (!name) {
|
architect.loadAdditionalPlugins([{
|
||||||
if (--count === 0) finish();
|
packagePath: "plugins/" + name + "_test"
|
||||||
return;
|
}], function(err){
|
||||||
}
|
callback(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function run(pluginName, callback){
|
||||||
|
// Load test runner
|
||||||
|
loadIframe(function(err){
|
||||||
|
if (err) return callback(err);
|
||||||
|
|
||||||
// Fetch package.json
|
// Wait until iframe is loaded
|
||||||
fs.readFile("~/.c9/plugins/" + name + "/package.json", function(err, data){
|
plugin.once("ready", function(){
|
||||||
if (err) {
|
|
||||||
console.error(err);
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
|
|
||||||
try{
|
// Load the test for the plugin
|
||||||
var options = JSON.parse(data);
|
loadTestSuite(pluginName, function(err){
|
||||||
if (!options.plugins)
|
if (err) return callback(err);
|
||||||
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);
|
|
||||||
|
|
||||||
// Watch project path
|
// Run the test
|
||||||
watch(pluginPath);
|
mocha.run(function(){
|
||||||
|
|
||||||
config.push({
|
// Done
|
||||||
packagePath: url,
|
callback();
|
||||||
staticPrefix: dirname(url),
|
|
||||||
apikey: "00000000-0000-4000-y000-" + String(config.length).pad(12, "0")
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
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
|
// Load iframe with new test runner frame
|
||||||
plugin.unload();
|
iframe.contentWindow.start(plugin);
|
||||||
}
|
})
|
||||||
|
|
||||||
// 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);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Lifecycle *****/
|
/***** Lifecycle *****/
|
||||||
|
|
||||||
plugin.on("load", function() {
|
plugin.on("load", function() {
|
||||||
load();
|
load();
|
||||||
});
|
|
||||||
plugin.on("enable", function() {
|
|
||||||
|
|
||||||
});
|
|
||||||
plugin.on("disable", function() {
|
|
||||||
|
|
||||||
});
|
});
|
||||||
plugin.on("unload", function() {
|
plugin.on("unload", function() {
|
||||||
loaded = false;
|
loaded = false;
|
||||||
|
chai = null;
|
||||||
|
mocha = null;
|
||||||
|
iframe = null;
|
||||||
|
architect = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
/***** Register and define API *****/
|
/***** 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, {
|
register(null, {
|
||||||
"plugin.editor": plugin
|
"plugin.test": plugin
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
//@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
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
// });
|
|
@ -181,6 +181,21 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
/***** Methods *****/
|
/***** 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(){
|
function init(){
|
||||||
inited = true;
|
inited = true;
|
||||||
layout.initMenus(plugin);
|
layout.initMenus(plugin);
|
||||||
|
@ -365,7 +380,8 @@ define(function(require, exports, module) {
|
||||||
if (item) {
|
if (item) {
|
||||||
item.setAttribute("submenu", menu);
|
item.setAttribute("submenu", menu);
|
||||||
item.setAttribute("caption",
|
item.setAttribute("caption",
|
||||||
apf.escapeXML((debug ? "(" + index + ")" : "") + name.split("/").pop()));
|
apf.escapeXML((debug ? "(" + index + ")" : "")
|
||||||
|
+ popSafe(name)));
|
||||||
items[name] = item;
|
items[name] = item;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -374,7 +390,7 @@ define(function(require, exports, module) {
|
||||||
item = items[name] = new apf.item({
|
item = items[name] = new apf.item({
|
||||||
submenu: menu,
|
submenu: menu,
|
||||||
caption: (debug ? "(" + index + ") " : "") +
|
caption: (debug ? "(" + index + ") " : "") +
|
||||||
name.split("/").pop()
|
popSafe(name)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -402,7 +418,7 @@ define(function(require, exports, module) {
|
||||||
function setMenuItem(parent, name, menuItem, index, item, plugin) {
|
function setMenuItem(parent, name, menuItem, index, item, plugin) {
|
||||||
if (item && !item.nodeFunc) plugin = item, item = null;
|
if (item && !item.nodeFunc) plugin = item, item = null;
|
||||||
|
|
||||||
var itemName = name.split("/").pop();
|
var itemName = popSafe(name);
|
||||||
if (itemName == "~")
|
if (itemName == "~")
|
||||||
name += index;
|
name += index;
|
||||||
|
|
||||||
|
@ -462,7 +478,7 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
assert(plugin !== undefined, "addItemByPath requires a plugin argument");
|
assert(plugin !== undefined, "addItemByPath requires a plugin argument");
|
||||||
|
|
||||||
var steps = path.split("/"), name, p = [], isLast;
|
var steps = splitSafe(path), name, p = [], isLast;
|
||||||
var curpath;
|
var curpath;
|
||||||
|
|
||||||
if (!menuItem)
|
if (!menuItem)
|
||||||
|
@ -568,7 +584,7 @@ define(function(require, exports, module) {
|
||||||
if (!items[path])
|
if (!items[path])
|
||||||
throw new Error("Could not find menu item " + path);
|
throw new Error("Could not find menu item " + path);
|
||||||
|
|
||||||
var steps = path.split("/"), p = [], item;
|
var steps = splitSafe(path), p = [], item;
|
||||||
var curpath;
|
var curpath;
|
||||||
|
|
||||||
for (var name, i = 0, l = steps.length; i < l; i++) {
|
for (var name, i = 0, l = steps.length; i < l; i++) {
|
||||||
|
|
|
@ -101,7 +101,9 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on("service", function(name, plugin, options){
|
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;
|
plugin.architect = app;
|
||||||
if (!plugin.name)
|
if (!plugin.name)
|
||||||
plugin.name = name;
|
plugin.name = name;
|
||||||
|
|
Ładowanie…
Reference in New Issue