Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #260 from blackberry/next
Browse files Browse the repository at this point in the history
0.9.2 release
  • Loading branch information
dansilivestru committed Dec 21, 2011
2 parents 3c6a8a0 + ad10586 commit 706ff63
Show file tree
Hide file tree
Showing 25 changed files with 843 additions and 175 deletions.
5 changes: 2 additions & 3 deletions build/btest.js
Expand Up @@ -16,7 +16,6 @@
module.exports = function () {
var connect = require('connect'),
fs = require('fs'),
sys = require('sys'),
utils = require('./build/utils'),
libs = [],
tests = [],
Expand Down Expand Up @@ -57,6 +56,6 @@ module.exports = function () {

app.listen(3000);

sys.puts("Test Server running on:");
sys.puts("http://127.0.0.1:3000");
process.stdout.write("Test Server running on:");
process.stdout.write("http://127.0.0.1:3000");
};
9 changes: 4 additions & 5 deletions build/build.js
Expand Up @@ -13,8 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var sys = require('sys'),
fs = require('fs'),
var fs = require('fs'),
jWorkflow = require('jWorkflow'),
quotes = require('./build/quotes'),
pack = require('./build/pack'),
Expand All @@ -25,11 +24,11 @@ var sys = require('sys'),

function _done(error) {
if (error) {
sys.puts(fs.readFileSync(__dirname + "/../thirdparty/fail.txt", "utf-8"));
sys.puts(error);
process.stdout.write(fs.readFileSync(__dirname + "/../thirdparty/fail.txt", "utf-8"));
process.stdout.write(error);
process.exit(1);
} else {
sys.puts(fs.readFileSync(__dirname + "/../thirdparty/dredd.txt", "utf-8"));
process.stdout.write(fs.readFileSync(__dirname + "/../thirdparty/dredd.txt", "utf-8"));
quotes.random();
process.exit();
}
Expand Down
7 changes: 3 additions & 4 deletions build/build/compress.js
Expand Up @@ -17,7 +17,6 @@ var childProcess = require('child_process'),
_c = require('./conf'),
utils = require('./utils'),
childProcess = require('child_process'),
sys = require('sys'),
fs = require('fs'),
jWorkflow = require('jWorkflow');

Expand All @@ -30,8 +29,8 @@ module.exports = function (prev, baton) {
baton.take();
childProcess.exec('uglifyjs --overwrite ' + file, function (error, stdout, stdin) {
if (error) {
sys.puts("Something bad happened. Is uglify-js installed?");
sys.puts(error);
process.stdout.write("Something bad happened. Is uglify-js installed?");
process.stdout.write(error);
process.exit(1);
} else {
baton.pass();
Expand All @@ -40,7 +39,7 @@ module.exports = function (prev, baton) {
});
}

sys.puts("compressing...");
process.stdout.write("compressing...");
baton.take();

utils.collect(_c.DEPLOY, files);
Expand Down
3 changes: 1 addition & 2 deletions build/deploy.js
Expand Up @@ -16,13 +16,12 @@
var test = require('./test'),
lint = require('./lint'),
build = require('./build'),
sys = require('sys'),
fs = require('fs'),
fail = fs.readFileSync(__dirname + "/../thirdparty/fail.txt", "utf-8");

function ok(code) {
if (code || code === 1) {
sys.puts(fail);
process.stdout.write(fail);
process.exit(1);
}
}
Expand Down
11 changes: 8 additions & 3 deletions build/lint.js
Expand Up @@ -14,13 +14,18 @@
* limitations under the License.
*/
var childProcess = require('child_process'),
sys = require('sys'),
fs = require('fs');

function _spawn(proc, args, done) {
function log(data) {
process.stdout.write(new Buffer(data).toString("utf-8"));
}

var cmd = childProcess.spawn(proc, args);
cmd.stdout.on('data', sys.print);
cmd.stderr.on('data', sys.print);

cmd.stdout.on('data', log);
cmd.stderr.on('data', log);

if (done) {
cmd.on('exit', done);
}
Expand Down
5 changes: 2 additions & 3 deletions build/lint/reporter.js
Expand Up @@ -15,8 +15,7 @@
*/
module.exports = {
reporter: function (results) {
var sys = require('sys'),
len = results.length,
var len = results.length,
str = '',
file, error;

Expand All @@ -27,7 +26,7 @@ module.exports = {
error.character + ', ' + error.reason + '\n';
});

sys.puts(len > 0 ? (str + "\n" + len + ' error' + ((len === 1) ? '' : 's\n')) : "Lint Free!\n");
process.stdout.write(len > 0 ? (str + "\n" + len + ' error' + ((len === 1) ? '' : 's\n')) : "Lint Free!\n");

process.exit(len > 2 ? 1 : 0);
}
Expand Down
55 changes: 27 additions & 28 deletions build/stats.js
Expand Up @@ -14,8 +14,7 @@
* limitations under the License.
*/
module.exports = function () {
var sys = require('sys'),
libs = [],
var libs = [],
tests = [],
total_lines = 0,
total_loc = 0,
Expand Down Expand Up @@ -52,9 +51,9 @@ module.exports = function () {
.replace(/^.*lib\/ripple\/?/, '')
.replace(/^.*test\//, '');

sys.puts("| " + file + spaces(59 - file.length) + "| " +
process.stdout.write("| " + file + spaces(59 - file.length) + "| " +
lines + spaces(7 - String(lines).length) + "| " +
loc + spaces(7 - String(loc).length) + "|");
loc + spaces(7 - String(loc).length) + "|\n");

callback(lines, loc);
}
Expand All @@ -77,9 +76,9 @@ module.exports = function () {
libs.sort();
tests.sort();

sys.puts("+------------------------------------------------------------+--------+--------+");
sys.puts("| Lib | Lines | LOC |");
sys.puts("+------------------------------------------------------------+--------+--------+");
process.stdout.write("+------------------------------------------------------------+--------+--------+\n");
process.stdout.write("| Lib | Lines | LOC |\n");
process.stdout.write("+------------------------------------------------------------+--------+--------+\n");

libs.forEach(function (lib) {
parseFile(lib, function (lines, loc) {
Expand All @@ -88,15 +87,15 @@ module.exports = function () {
});
});

sys.puts("+------------------------------------------------------------+--------+--------+");
sys.print("| Total |");
sys.print(" " + lib_lines + spaces(7 - String(lib_lines).length) + "|");
sys.puts(" " + lib_loc + spaces(7 - String(lib_loc).length) + "|");
sys.puts("+------------------------------------------------------------+--------+--------+");
process.stdout.write("+------------------------------------------------------------+--------+--------+\n");
process.stdout.write("| Total |");
process.stdout.write(" " + lib_lines + spaces(7 - String(lib_lines).length) + "|");
process.stdout.write(" " + lib_loc + spaces(7 - String(lib_loc).length) + "|\n");
process.stdout.write("+------------------------------------------------------------+--------+--------+\n");

sys.puts("+------------------------------------------------------------+--------+--------+");
sys.puts("| Tests | Lines | LOC |");
sys.puts("+------------------------------------------------------------+--------+--------+");
process.stdout.write("+------------------------------------------------------------+--------+--------+\n");
process.stdout.write("| Tests | Lines | LOC |\n");
process.stdout.write("+------------------------------------------------------------+--------+--------+\n");

tests.forEach(function (test) {
parseFile(test, function (lines, loc) {
Expand All @@ -105,23 +104,23 @@ module.exports = function () {
});
});

sys.puts("+------------------------------------------------------------+--------+--------+");
sys.print("| Total |");
sys.print(" " + test_lines + spaces(7 - String(test_lines).length) + "|");
sys.puts(" " + test_loc + spaces(7 - String(test_loc).length) + "|");
sys.puts("+------------------------------------------------------------+--------+--------+");
process.stdout.write("+------------------------------------------------------------+--------+--------+\n");
process.stdout.write("| Total |");
process.stdout.write(" " + test_lines + spaces(7 - String(test_lines).length) + "|");
process.stdout.write(" " + test_loc + spaces(7 - String(test_loc).length) + "|\n");
process.stdout.write("+------------------------------------------------------------+--------+--------+\n");

total_lines = lib_lines + test_lines;
total_loc = lib_loc + test_loc;
testsOverLib = (lib_loc / test_loc).toFixed(2);
emptySpace = total_lines - total_loc;

sys.puts("+------------------------------------------------------------+--------+--------+");
sys.puts("| Stats |");
sys.puts("+------------------------------------------------------------+--------+--------+");
sys.puts("| lines: " + total_lines + spaces(70 - String(total_lines).length) + "|");
sys.puts("| loc: " + total_loc + spaces(72 - String(total_loc).length) + "|");
sys.puts("| lib/test (loc): " + testsOverLib + spaces(61 - String(testsOverLib).length) + "|");
sys.puts("| comments & empty space: " + emptySpace + spaces(53 - String(emptySpace).length) + "|");
sys.puts("+------------------------------------------------------------+--------+--------+");
process.stdout.write("+------------------------------------------------------------+--------+--------+\n");
process.stdout.write("| Stats |\n");
process.stdout.write("+------------------------------------------------------------+--------+--------+\n");
process.stdout.write("| lines: " + total_lines + spaces(70 - String(total_lines).length) + "|\n");
process.stdout.write("| loc: " + total_loc + spaces(72 - String(total_loc).length) + "|\n");
process.stdout.write("| lib/test (loc): " + testsOverLib + spaces(61 - String(testsOverLib).length) + "|\n");
process.stdout.write("| comments & empty space: " + emptySpace + spaces(53 - String(emptySpace).length) + "|\n");
process.stdout.write("+------------------------------------------------------------+--------+--------+\n");
};
47 changes: 19 additions & 28 deletions build/test.js
Expand Up @@ -13,37 +13,38 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var jsdom = require('jsdom'),
fs = require('fs'),
jWorkflow = require('jWorkflow'),
jasmine = require('./test/jasmine-node'),
childProcess = require('child_process'),
nodeXMLHttpRequest = require(__dirname + '/../thirdparty/node-XMLHttpRequest/XMLHttpRequest').XMLHttpRequest;

function _extraMocks() {
global.screen = {
height: 1600,
availHeight: 1600,
width: 1200,
availWidth: 1200
};
global.XMLHttpRequest = window.XMLHttpRequest = require(__dirname +
'/../thirdparty/node-XMLHttpRequest/XMLHttpRequest').XMLHttpRequest;

global.XMLHttpRequest = window.XMLHttpRequest = nodeXMLHttpRequest;
require(__dirname + "/../thirdparty/Math.uuid");

global.jWorkflow = require('jWorkflow');
global.jWorkflow = jWorkflow;

window.navigator.userAgent = "foo";
window.navigator.geolocation = {};
window.navigator.javaEnabled = function () {};

global.location = window.location = {
protocol: "http"
};
global.location = window.location = {protocol: "http"};
global.NamedNodeMap = function () {
return [];
};
window.removeEventListener = function () {};
}

function _setupEnv(ready) {
var jsdom = require('jsdom'),
fs = require('fs'),
layout = fs.readFileSync(__dirname + "/../ext/assets/index.html", "utf-8"),
var layout = fs.readFileSync(__dirname + "/../ext/assets/index.html", "utf-8"),
thirdparty = [
__dirname + "/../thirdparty/jquery.js",
__dirname + "/../thirdparty/jquery.ui.js"
Expand All @@ -64,20 +65,14 @@ function _setupEnv(ready) {

_extraMocks();

ready();
childProcess.exec('cp -rf lib/ripple node_modules/ripple && ' +
'cp -f lib/ripple.js node_modules/ripple.js', ready);
});
}

module.exports = function (done, custom) {
var jasmine = require('jasmine-node'),
verbose = false,
colored = false,
specs = __dirname + "/../" + (custom ? custom : "test");

require.paths.push(__dirname + "/../lib/");

//HACK: this should be taken out if our pull request in jasmine is accepted.
jasmine.Matchers.prototype.toThrow = function (expected) {
jasmine.core.Matchers.prototype.toThrow = function (expected) {
var result = false,
exception,
not = this.isNot ? "not " : "";
Expand All @@ -95,12 +90,12 @@ module.exports = function (done, custom) {
result = expected(exception);
}
else {
result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
result = (expected === jasmine.core.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
}
}

this.message = function () {
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
if (exception && (expected === jasmine.core.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
} else {
return "Expected function to throw an exception.";
Expand All @@ -111,17 +106,13 @@ module.exports = function (done, custom) {
};

_setupEnv(function () {
for (var key in jasmine) {
if (Object.prototype.hasOwnProperty.call(jasmine, key)) {
global[key] = jasmine[key];
}
}
var targets = __dirname + "/../" + (custom ? custom : "test");

jasmine.executeSpecsInFolder(specs, function (runner, log) {
jasmine.run(targets.split(' '), function (runner) {
var failed = runner.results().failedCount === 0 ? 0 : 1;
setTimeout(function () {
(typeof done !== "function" ? process.exit : done)(failed);
}, 10);
}, verbose, colored);
});
});
};

0 comments on commit 706ff63

Please sign in to comment.