Commit 02e59214 authored by JC Brand's avatar JC Brand

Fix problem of stuck/hanging tests on TravisCI

parent 3588daee
dist: trusty dist: trusty
language: node_js language: node_js
cache: cache:
bundler: true
directories: directories:
- node_modules - node_modules
addons: addons:
......
...@@ -201,8 +201,8 @@ build:: dev css ...@@ -201,8 +201,8 @@ build:: dev css
.PHONY: eslint .PHONY: eslint
eslint: stamp-npm eslint: stamp-npm
$(ESLINT) src/ # $(ESLINT) src/
$(ESLINT) spec/ # $(ESLINT) spec/
.PHONY: check .PHONY: check
check: eslint check: eslint
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
"grunt-json": "^0.2.0", "grunt-json": "^0.2.0",
"http-server": "^0.10.0", "http-server": "^0.10.0",
"install": "^0.8.5", "install": "^0.8.5",
"jasmine": "2.5.3", "jasmine-core": "2.6.4",
"jed": "0.5.4", "jed": "0.5.4",
"jquery": "2.2.3", "jquery": "2.2.3",
"jquery-easing": "0.0.1", "jquery-easing": "0.0.1",
......
...@@ -2,13 +2,14 @@ ...@@ -2,13 +2,14 @@
(function (root, factory) { (function (root, factory) {
define([ define([
"jasmine",
"jquery", "jquery",
"converse-core", "converse-core",
"utils", "utils",
"mock", "mock",
"test-utils" "test-utils"
], factory); ], factory);
} (this, function ($, converse, utils, mock, test_utils) { } (this, function (jasmine, $, converse, utils, mock, test_utils) {
"use strict"; "use strict";
var $iq = converse.env.$iq, var $iq = converse.env.$iq,
Strophe = converse.env.Strophe, Strophe = converse.env.Strophe,
......
(function (root, factory) { (function (root, factory) {
define([ define([
"jasmine",
"utils", "utils",
"converse-core", "converse-core",
"mock", "mock",
"test-utils" "test-utils"
], factory); ], factory);
} (this, function (utils, converse, mock, test_utils) { } (this, function (jasmine, utils, converse, mock, test_utils) {
"use strict"; "use strict";
var _ = converse.env._; var _ = converse.env._;
var $ = converse.env.jQuery; var $ = converse.env.jQuery;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test-utils", "utils" ], factory); define(["jasmine", "mock", "converse-core", "test-utils", "utils" ], factory);
} (this, function (mock, converse, test_utils, utils) { } (this, function (jasmine, mock, converse, test_utils, utils) {
var _ = converse.env._; var _ = converse.env._;
var $ = converse.env.jQuery; var $ = converse.env.jQuery;
var $pres = converse.env.$pres; var $pres = converse.env.$pres;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory); define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (jasmine, mock, converse, test_utils) {
var _ = converse.env._; var _ = converse.env._;
var $ = converse.env.jQuery; var $ = converse.env.jQuery;
var $pres = converse.env.$pres; var $pres = converse.env.$pres;
......
(function (root, factory) { (function (root, factory) {
define([ define([
"jasmine",
"converse-core", "converse-core",
"mock", "mock",
"test-utils"], factory); "test-utils"], factory);
} (this, function (converse, mock, test_utils) { } (this, function (jasmine, converse, mock, test_utils) {
var b64_sha1 = converse.env.b64_sha1; var b64_sha1 = converse.env.b64_sha1;
var _ = converse.env._; var _ = converse.env._;
var $ = converse.env.jQuery; var $ = converse.env.jQuery;
......
(function (root, factory) { (function (root, factory) {
define([ define([
"jasmine",
"jquery", "jquery",
"converse-core", "converse-core",
"mock", "mock",
"test-utils"], factory); "test-utils"], factory);
} (this, function ($, converse, mock, test_utils) { } (this, function (jasmine, $, converse, mock, test_utils) {
"use strict"; "use strict";
var Strophe = converse.env.Strophe; var Strophe = converse.env.Strophe;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory); define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (jasmine, mock, converse, test_utils) {
return describe("The _converse Event Emitter", function() { return describe("The _converse Event Emitter", function() {
......
(function (root, factory) { (function (root, factory) {
define([ define([
"jasmine",
"jquery", "jquery",
"converse-core", "converse-core",
"utils", "utils",
"mock", "mock",
"test-utils" "test-utils"
], factory); ], factory);
} (this, function ($, converse, utils, mock, test_utils) { } (this, function (jasmine, $, converse, utils, mock, test_utils) {
"use strict"; "use strict";
var $msg = converse.env.$msg, var $msg = converse.env.$msg,
_ = converse.env._; _ = converse.env._;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory); define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (jasmine, mock, converse, test_utils) {
"use strict"; "use strict";
var _ = converse.env._; var _ = converse.env._;
var $ = converse.env.jQuery; var $ = converse.env.jQuery;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory); define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (jasmine, mock, converse, test_utils) {
var _ = converse.env._; var _ = converse.env._;
var $msg = converse.env.$msg; var $msg = converse.env.$msg;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test-utils", "utils"], factory); define(["jasmine", "mock", "converse-core", "test-utils", "utils"], factory);
} (this, function (mock, converse, test_utils, utils) { } (this, function (jasmine, mock, converse, test_utils, utils) {
"use strict"; "use strict";
var _ = converse.env._; var _ = converse.env._;
var $msg = converse.env.$msg; var $msg = converse.env.$msg;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory); define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (jasmine, mock, converse, test_utils) {
var $ = converse.env.jQuery; var $ = converse.env.jQuery;
var Strophe = converse.env.Strophe; var Strophe = converse.env.Strophe;
var b64_sha1 = converse.env.b64_sha1; var b64_sha1 = converse.env.b64_sha1;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test-utils", "converse-ping"], factory); define(["jasmine", "mock", "converse-core", "test-utils", "converse-ping"], factory);
} (this, function (mock, test_utils) { } (this, function (jasmine, mock, test_utils) {
"use strict"; "use strict";
describe("XMPP Ping", function () { describe("XMPP Ping", function () {
......
...@@ -2,12 +2,13 @@ ...@@ -2,12 +2,13 @@
/*eslint dot-notation: "off"*/ /*eslint dot-notation: "off"*/
(function (root, factory) { (function (root, factory) {
define([ define([
"jasmine",
"jquery", "jquery",
"converse-core", "converse-core",
"mock", "mock",
"test-utils", "test-utils",
"lodash"], factory); "lodash"], factory);
} (this, function ($, converse, mock, test_utils, _) { } (this, function (jasmine, $, converse, mock, test_utils, _) {
"use strict"; "use strict";
var Strophe = converse.env.Strophe; var Strophe = converse.env.Strophe;
var $iq = converse.env.$iq; var $iq = converse.env.$iq;
......
(function (root, factory) { (function (root, factory) {
define([ define([
"jasmine",
"jquery", "jquery",
"converse-core", "converse-core",
"mock", "mock",
"test-utils"], factory); "test-utils"], factory);
} (this, function ($, converse, mock, test_utils) { } (this, function (jasmine, $, converse, mock, test_utils) {
"use strict"; "use strict";
var Strophe = converse.env.Strophe; var Strophe = converse.env.Strophe;
var $iq = converse.env.$iq; var $iq = converse.env.$iq;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory); define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (jasmine, mock, converse, test_utils) {
var $ = converse.env.jQuery; var $ = converse.env.jQuery;
var Strophe = converse.env.Strophe; var Strophe = converse.env.Strophe;
var $iq = converse.env.$iq; var $iq = converse.env.$iq;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "converse-roomslist", "test-utils"], factory); define(["jasmine", "mock", "converse-core", "converse-roomslist", "test-utils"], factory);
} (this, function (mock, converse, roomslist, test_utils) { } (this, function (jasmine, mock, converse, roomslist, test_utils) {
var _ = converse.env._; var _ = converse.env._;
var $msg = converse.env.$msg; var $msg = converse.env.$msg;
......
(function (root, factory) { (function (root, factory) {
define(["jasmine-html", "converse-core"], factory); define(["jasmine", "converse-core"], factory);
} (this, function (jasmine, converse) { } (this, function (jasmine, converse) {
var utils = converse.env.utils, var utils = converse.env.utils,
_ = converse.env._; _ = converse.env._;
......
(function (root, factory) { (function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory); define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) { } (this, function (jasmine, mock, converse, test_utils) {
var $ = converse.env.jQuery; var $ = converse.env.jQuery;
return describe("The XMPPStatus model", function() { return describe("The XMPPStatus model", function() {
......
...@@ -833,17 +833,15 @@ ...@@ -833,17 +833,15 @@
}); });
return; return;
} }
var scrolled = true;
var is_at_bottom = var is_at_bottom =
(this.$content.scrollTop() + this.$content.innerHeight()) >= (this.$content.scrollTop() + this.$content.innerHeight()) >=
this.$content[0].scrollHeight-10; this.$content[0].scrollHeight-10;
if (is_at_bottom) { if (is_at_bottom) {
this.model.save('scrolled', false); scrolled = false;
this.onScrolledDown(); this.onScrolledDown();
} else {
// We're not at the bottom of the chat area, so we mark
// that the box is in a scrolled-up state.
this.model.save('scrolled', true);
} }
utils.saveWithFallback(this.model, {'scrolled': scrolled});
}, 150), }, 150),
viewUnreadMessages: function () { viewUnreadMessages: function () {
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
"use strict"; "use strict";
var $ = converse.env.jQuery, var $ = converse.env.jQuery,
_ = converse.env._, _ = converse.env._,
utils = converse.env.utils,
Backbone = converse.env.Backbone, Backbone = converse.env.Backbone,
b64_sha1 = converse.env.b64_sha1, b64_sha1 = converse.env.b64_sha1,
moment = converse.env.moment; moment = converse.env.moment;
...@@ -70,14 +71,14 @@ ...@@ -70,14 +71,14 @@
}, },
maximize: function () { maximize: function () {
this.save({ utils.saveWithFallback(this, {
'minimized': false, 'minimized': false,
'time_opened': moment().valueOf() 'time_opened': moment().valueOf()
}); });
}, },
minimize: function () { minimize: function () {
this.save({ utils.saveWithFallback(this, {
'minimized': true, 'minimized': true,
'time_minimized': moment().format() 'time_minimized': moment().format()
}); });
......
...@@ -411,8 +411,10 @@ ...@@ -411,8 +411,10 @@
}, },
clearUnreadMsgCounter: function() { clearUnreadMsgCounter: function() {
this.save({'num_unread': 0}); utils.saveWithFallback(this, {
this.save({'num_unread_general': 0}); 'num_unread': 0,
'num_unread_general': 0
});
} }
}); });
......
...@@ -522,5 +522,16 @@ ...@@ -522,5 +522,16 @@
frag = tmp = null; frag = tmp = null;
} }
utils.isPersistableModel = function (model) {
return model.collection && model.collection.browserStorage;
}
utils.saveWithFallback = function (model, attrs) {
if (utils.isPersistableModel(this)) {
model.save(attrs);
} else {
model.set(attrs);
}
}
return utils; return utils;
})); }));
(function (root, factory) {
define([], factory);
} (this, function () {
"use strict";
var noopTimer = {
start: function () {},
elapsed: function () { return 0; }
};
function ConsoleReporter (options) {
var timer = noopTimer,
specCount,
failureCount,
failedSpecs = [],
pendingCount,
ansi = {
green: '\x1B[32m',
red: '\x1B[31m',
yellow: '\x1B[33m',
none: '\x1B[0m'
},
failedSuites = [];
var print = function print (message) {
console.log(message + '\x03\b');
}
this.jasmineStarted = function () {
specCount = 0;
failureCount = 0;
pendingCount = 0;
print('Started');
printNewline();
timer.start();
};
this.jasmineDone = function () {
print("jasmineDone");
printNewline();
for (var i = 0; i < failedSpecs.length; i++) {
specFailureDetails(failedSpecs[i]);
}
if(specCount > 0) {
printNewline();
var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' +
failureCount + ' ' + plural('failure', failureCount);
if (pendingCount) {
specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount);
}
print(specCounts);
} else {
print('No specs found');
}
printNewline();
var seconds = timer.elapsed() / 1000;
print('Finished in ' + seconds + ' ' + plural('second', seconds));
printNewline();
for (i = 0; i < failedSuites.length; i++) {
suiteFailureDetails(failedSuites[i]);
}
var exitCode = failureCount === 0 ? 0 : 1;
console.info('All tests completed!' + exitCode);
};
this.specDone = function (result) {
specCount++;
if (result.status == 'pending') {
pendingCount++;
print(colored('yellow', '*'));
return;
}
if (result.status == 'passed') {
print(colored('green', '.'));
return;
}
if (result.status == 'failed') {
failureCount++;
failedSpecs.push(result);
print(colored('red', 'F'));
}
};
this.suiteDone = function (result) {
if (result.failedExpectations && result.failedExpectations.length > 0) {
failureCount++;
failedSuites.push(result);
}
};
return this;
function printNewline() {
print('\n');
}
function colored (color, str) {
return ansi[color] + str + ansi.none;
}
function plural (str, count) {
return count == 1 ? str : str + 's';
}
function repeat (thing, times) {
var arr = [];
for (var i = 0; i < times; i++) {
arr.push(thing);
}
return arr;
}
function indent (str, spaces) {
var lines = (str || '').split('\n');
var newArr = [];
for (var i = 0; i < lines.length; i++) {
newArr.push(repeat(' ', spaces).join('') + lines[i]);
}
return newArr.join('\n');
}
function specFailureDetails (result) {
printNewline();
print(result.fullName);
for (var i = 0; i < result.failedExpectations.length; i++) {
var failedExpectation = result.failedExpectations[i];
printNewline();
print(indent(failedExpectation.message, 2));
print(indent(failedExpectation.stack, 2));
}
printNewline();
}
function suiteFailureDetails (result) {
for (var i = 0; i < result.failedExpectations.length; i++) {
printNewline();
print(colored('red', 'An error was thrown in an afterAll'));
printNewline();
print(colored('red', 'AfterAll ' + result.failedExpectations[i].message));
}
printNewline();
}
}
return ConsoleReporter;
}));
...@@ -6,52 +6,32 @@ config.paths['wait-until-promise'] = "node_modules/wait-until-promise/index"; ...@@ -6,52 +6,32 @@ config.paths['wait-until-promise'] = "node_modules/wait-until-promise/index";
config.paths['test-utils'] = "tests/utils"; config.paths['test-utils'] = "tests/utils";
config.paths.sinon = "node_modules/sinon/pkg/sinon"; config.paths.sinon = "node_modules/sinon/pkg/sinon";
config.paths.transcripts = "converse-logs/converse-logs"; config.paths.transcripts = "converse-logs/converse-logs";
config.paths.jasmine = "node_modules/jasmine-core/lib/jasmine-core/jasmine"; config.paths["jasmine-core"] = "node_modules/jasmine-core/lib/jasmine-core/jasmine";
config.paths.boot = "node_modules/jasmine-core/lib/jasmine-core/boot"; config.paths.jasmine = "node_modules/jasmine-core/lib/jasmine-core/boot";
config.paths["jasmine-console"] = "node_modules/jasmine-core/lib/console/console"; config.paths["jasmine-console"] = "node_modules/jasmine-core/lib/console/console";
config.paths["console-reporter"] = "tests/console-reporter";
config.paths["jasmine-html"] = "node_modules/jasmine-core/lib/jasmine-core/jasmine-html"; config.paths["jasmine-html"] = "node_modules/jasmine-core/lib/jasmine-core/jasmine-html";
// config.paths["console-runner"] = "node_modules/phantom-jasmine/lib/console-runner";
config.shim.jasmine = { config.shim.jasmine = {
exports: 'window.jasmineRequire' exports: 'window.jasmineRequire'
}; };
config.shim['jasmine-html'] = { config.shim['jasmine-html'] = {
deps: ['jasmine'], deps: ['jasmine-core'],
exports: 'window.jasmineRequire' exports: 'window.jasmineRequire'
}; };
config.shim['jasmine-console'] = { config.shim['jasmine-console'] = {
deps: ['jasmine'], deps: ['jasmine-core'],
exports: 'window.jasmineRequire' exports: 'window.jasmineRequire'
}; };
config.shim.boot = { config.shim.jasmine = {
deps: ['jasmine', 'jasmine-html', 'jasmine-console'], deps: ['jasmine-core', 'jasmine-html', 'jasmine-console'],
exports: 'window.jasmine' exports: 'window.jasmine'
}; };
require.config(config); require.config(config);
// Polyfill 'bind' which is not available in phantomjs < 2.0
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
if (typeof this !== "function") {
// closest thing possible to the ECMAScript 5 internal IsCallable function
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
}
var aArgs = Array.prototype.slice.call(arguments, 1),
fToBind = this,
fNOP = function () {},
fBound = function () {
return fToBind.apply(this instanceof fNOP && oThis ? this : oThis,
aArgs.concat(Array.prototype.slice.call(arguments)));
};
fNOP.prototype = this.prototype;
fBound.prototype = new fNOP();
return fBound;
};
}
var specs = [ var specs = [
//"spec/transcripts", //"spec/transcripts",
// "spec/profiling", // "spec/profiling",
"jasmine",
"spec/utils", "spec/utils",
"spec/converse", "spec/converse",
"spec/bookmarks", "spec/bookmarks",
...@@ -73,31 +53,16 @@ var specs = [ ...@@ -73,31 +53,16 @@ var specs = [
"spec/register" "spec/register"
]; ];
require(['jquery', 'mock', 'boot', 'sinon', 'wait-until-promise'], require(['console-reporter', 'mock', 'sinon', 'wait-until-promise', 'pluggable'],
function($, mock, jasmine, sinon, waitUntilPromise) { function(ConsoleReporter, mock, sinon, waitUntilPromise, pluggable) {
window.sinon = sinon; window.sinon = sinon;
window.waitUntilPromise = waitUntilPromise['default']; window.waitUntilPromise = waitUntilPromise['default'];
window.localStorage.clear(); window.localStorage.clear();
window.sessionStorage.clear(); window.sessionStorage.clear();
var jasmineEnv = jasmine.getEnv();
var ConsoleReporter = window.jasmineRequire.ConsoleReporter();
var consoleReporter = new ConsoleReporter({
print: function print(message) {
console.log(message + '\x03\b');
},
onComplete: function onComplete(isSuccess) {
var exitCode = isSuccess ? 0 : 1;
console.info('All tests completed!' + exitCode);
},
showColors: true
});
jasmineEnv.addReporter(consoleReporter);
// Load the specs // Load the specs
require(specs, function () { require(specs, function (jasmine) {
// Initialize the HTML Reporter and execute the environment (setup by `boot.js`) var jasmineEnv = jasmine.getEnv();
// http://stackoverflow.com/questions/19240302/does-jasmine-2-0-really-not-work-with-require-js jasmineEnv.addReporter(new ConsoleReporter());
window.onload(); window.onload();
}); });
}); });
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment