diff --git a/node_modules/c9/blocked.js b/node_modules/c9/blocked.js new file mode 100644 index 00000000..fcb1e2f7 --- /dev/null +++ b/node_modules/c9/blocked.js @@ -0,0 +1,9 @@ +module.exports = function (callback) { + var start = Date.now(); + // setInterval is handled after setImmediate and setTimeout handlers + var interval = setTimeout(function () { + clearInterval(interval); + var took = Date.now() - start; + return callback(took); + }, 0); +}; \ No newline at end of file diff --git a/node_modules/c9/blocked_test.js b/node_modules/c9/blocked_test.js new file mode 100644 index 00000000..108325d1 --- /dev/null +++ b/node_modules/c9/blocked_test.js @@ -0,0 +1,60 @@ +"use strict"; +"use server"; + +var assert = require("assert"); +var blocked = require("./blocked"); + +module.exports = { + + "test normal run should return low blocked time": function(next) { + blocked(function(time) { + assert(time < 10); + next(); + }); + }, + "test busy loop should report high blocked time": function(next) { + blocked(function(time) { + assert(time >= 100); + next(); + }); + + var start = Date.now(); + while (Date.now() - start < 100) {} + }, + "test busy loop in setTimeout should report high blocked time": function(next) { + setTimeout(function() { + var start = Date.now(); + while (Date.now() - start < 100) {} + }, 0); + + blocked(function(time) { + assert(time >= 100); + next(); + }); + }, + "test busy loop in setInterval should report high blocked time": function(next) { + var interval = setInterval(function() { + clearInterval(interval); + var start = Date.now(); + while (Date.now() - start < 100) {} + }); + + blocked(function(time) { + assert(time >= 100); + next(); + }); + }, + "test busy loop in setImmediate should report high blocked time": function(next) { + setImmediate(function() { + var start = Date.now(); + while (Date.now() - start < 100) {} + }); + + blocked(function(time) { + assert(time >= 100); + next(); + }); + } +}; + +!module.parent && require("asyncjs").test.testcase(module.exports).exec(); \ No newline at end of file diff --git a/node_modules/c9/git_test.js b/node_modules/c9/git_test.js index 690eb76e..fae73a2b 100644 --- a/node_modules/c9/git_test.js +++ b/node_modules/c9/git_test.js @@ -58,7 +58,7 @@ module.exports = { }, "test get head revision sync": function(next) { - var rev = git.getHeadRevisionSync(__dirname + "/../"); + var rev = git.getHeadRevisionSync(__dirname + "/../../"); assert.equal(rev.length, 40); next(); @@ -70,6 +70,6 @@ module.exports = { next(); }); } -} +}; !module.parent && require("asyncjs").test.testcase(module.exports).exec(); diff --git a/node_modules/c9/passcrypt_test.js b/node_modules/c9/passcrypt_test.js index 9314c156..d373e9d8 100644 --- a/node_modules/c9/passcrypt_test.js +++ b/node_modules/c9/passcrypt_test.js @@ -3,27 +3,12 @@ "use server"; "use mocha"; -// Test flags -// -// "use root"; the unit test will be executed as root (using sudo); use with care! (ex. back-up / restore tests) -// "use non-osx"; test will be skipped if the operating system is Mac OS -// "use server"; tests are supposed to run on server-side (either with node or mocha) -// "use client"; tests are run by means of Selenium on client side -// "use mocha"; tests can be run by mocha or by node; this label indicates needs be run using mocha. +require("c9/inline-mocha")(module); -if (typeof define === "undefined") { - require("c9/inline-mocha")(module); - require("amd-loader"); - require("../../test/setup_paths"); -} - -define(function(require, exports, module) { - -var assert = require("ace/test/assertions"); +var assert = require("assert"); var passcrypt = require('./passcrypt'); var bcrypt = require('bcrypt'); - describe("c9/passcrypt", function(){ this.timeout(2000); @@ -77,6 +62,4 @@ describe("c9/passcrypt", function(){ }); }); -if (typeof onload !== "undefined") - onload(); -}); +if (typeof onload !== "undefined") onload(); diff --git a/scripts/makestatic.js b/scripts/makestatic.js index c3d5344d..ea4370c1 100755 --- a/scripts/makestatic.js +++ b/scripts/makestatic.js @@ -67,18 +67,24 @@ function main(config, settings, options, callback) { compress: options.compress, virtual: options.virtual }) - .concat({ - consumes: [], - provides: ["cdn.build", "db"], - setup: function(options, imports, register) { - register(null, { "cdn.build": {}, "db": {} }); - } - }) .filter(function(p) { var path = p.packagePath; return !path || path.indexOf("c9.db.redis/redis") == -1 && path.indexOf("c9.static/build") == -1 && path.indexOf("c9.api/health") == -1; + }) + .concat({ + consumes: [], + provides: ["cdn.build", "db", "health"], + setup: function(options, imports, register) { + register(null, { + "cdn.build": {}, + "db": {}, + "health": { + addCheck: function() {} + } + }); + } });