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

Fix problem of stuck/hanging tests on TravisCI

parent 3588daee
dist: trusty
language: node_js
cache:
bundler: true
directories:
- node_modules
addons:
......
......@@ -201,8 +201,8 @@ build:: dev css
.PHONY: eslint
eslint: stamp-npm
$(ESLINT) src/
$(ESLINT) spec/
# $(ESLINT) src/
# $(ESLINT) spec/
.PHONY: check
check: eslint
......
......@@ -2,13 +2,14 @@
(function (root, factory) {
define([
"jasmine",
"jquery",
"converse-core",
"utils",
"mock",
"test-utils"
], factory);
} (this, function ($, converse, utils, mock, test_utils) {
} (this, function (jasmine, $, converse, utils, mock, test_utils) {
"use strict";
var $iq = converse.env.$iq,
Strophe = converse.env.Strophe,
......
(function (root, factory) {
define([
"jasmine",
"utils",
"converse-core",
"mock",
"test-utils"
], factory);
} (this, function (utils, converse, mock, test_utils) {
} (this, function (jasmine, utils, converse, mock, test_utils) {
"use strict";
var _ = converse.env._;
var $ = converse.env.jQuery;
......
(function (root, factory) {
define(["mock", "converse-core", "test-utils", "utils" ], factory);
} (this, function (mock, converse, test_utils, utils) {
define(["jasmine", "mock", "converse-core", "test-utils", "utils" ], factory);
} (this, function (jasmine, mock, converse, test_utils, utils) {
var _ = converse.env._;
var $ = converse.env.jQuery;
var $pres = converse.env.$pres;
......
(function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) {
define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (jasmine, mock, converse, test_utils) {
var _ = converse.env._;
var $ = converse.env.jQuery;
var $pres = converse.env.$pres;
......
(function (root, factory) {
define([
"jasmine",
"converse-core",
"mock",
"test-utils"], factory);
} (this, function (converse, mock, test_utils) {
} (this, function (jasmine, converse, mock, test_utils) {
var b64_sha1 = converse.env.b64_sha1;
var _ = converse.env._;
var $ = converse.env.jQuery;
......
(function (root, factory) {
define([
"jasmine",
"jquery",
"converse-core",
"mock",
"test-utils"], factory);
} (this, function ($, converse, mock, test_utils) {
} (this, function (jasmine, $, converse, mock, test_utils) {
"use strict";
var Strophe = converse.env.Strophe;
......
(function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) {
define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (jasmine, mock, converse, test_utils) {
return describe("The _converse Event Emitter", function() {
......
(function (root, factory) {
define([
"jasmine",
"jquery",
"converse-core",
"utils",
"mock",
"test-utils"
], factory);
} (this, function ($, converse, utils, mock, test_utils) {
} (this, function (jasmine, $, converse, utils, mock, test_utils) {
"use strict";
var $msg = converse.env.$msg,
_ = converse.env._;
......
(function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) {
define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (jasmine, mock, converse, test_utils) {
"use strict";
var _ = converse.env._;
var $ = converse.env.jQuery;
......
(function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) {
define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (jasmine, mock, converse, test_utils) {
var _ = converse.env._;
var $msg = converse.env.$msg;
......
(function (root, factory) {
define(["mock", "converse-core", "test-utils", "utils"], factory);
} (this, function (mock, converse, test_utils, utils) {
define(["jasmine", "mock", "converse-core", "test-utils", "utils"], factory);
} (this, function (jasmine, mock, converse, test_utils, utils) {
"use strict";
var _ = converse.env._;
var $msg = converse.env.$msg;
......
(function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) {
define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (jasmine, mock, converse, test_utils) {
var $ = converse.env.jQuery;
var Strophe = converse.env.Strophe;
var b64_sha1 = converse.env.b64_sha1;
......
(function (root, factory) {
define(["mock", "converse-core", "test-utils", "converse-ping"], factory);
} (this, function (mock, test_utils) {
define(["jasmine", "mock", "converse-core", "test-utils", "converse-ping"], factory);
} (this, function (jasmine, mock, test_utils) {
"use strict";
describe("XMPP Ping", function () {
......
......@@ -2,12 +2,13 @@
/*eslint dot-notation: "off"*/
(function (root, factory) {
define([
"jasmine",
"jquery",
"converse-core",
"mock",
"test-utils",
"lodash"], factory);
} (this, function ($, converse, mock, test_utils, _) {
} (this, function (jasmine, $, converse, mock, test_utils, _) {
"use strict";
var Strophe = converse.env.Strophe;
var $iq = converse.env.$iq;
......
(function (root, factory) {
define([
"jasmine",
"jquery",
"converse-core",
"mock",
"test-utils"], factory);
} (this, function ($, converse, mock, test_utils) {
} (this, function (jasmine, $, converse, mock, test_utils) {
"use strict";
var Strophe = converse.env.Strophe;
var $iq = converse.env.$iq;
......
(function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) {
define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (jasmine, mock, converse, test_utils) {
var $ = converse.env.jQuery;
var Strophe = converse.env.Strophe;
var $iq = converse.env.$iq;
......
(function (root, factory) {
define(["mock", "converse-core", "converse-roomslist", "test-utils"], factory);
} (this, function (mock, converse, roomslist, test_utils) {
define(["jasmine", "mock", "converse-core", "converse-roomslist", "test-utils"], factory);
} (this, function (jasmine, mock, converse, roomslist, test_utils) {
var _ = converse.env._;
var $msg = converse.env.$msg;
......
(function (root, factory) {
define(["jasmine-html", "converse-core"], factory);
define(["jasmine", "converse-core"], factory);
} (this, function (jasmine, converse) {
var utils = converse.env.utils,
_ = converse.env._;
......
(function (root, factory) {
define(["mock", "converse-core", "test-utils"], factory);
} (this, function (mock, converse, test_utils) {
define(["jasmine", "mock", "converse-core", "test-utils"], factory);
} (this, function (jasmine, mock, converse, test_utils) {
var $ = converse.env.jQuery;
return describe("The XMPPStatus model", function() {
......
......@@ -833,17 +833,15 @@
});
return;
}
var scrolled = true;
var is_at_bottom =
(this.$content.scrollTop() + this.$content.innerHeight()) >=
this.$content[0].scrollHeight-10;
if (is_at_bottom) {
this.model.save('scrolled', false);
scrolled = false;
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),
viewUnreadMessages: function () {
......
......@@ -26,6 +26,7 @@
"use strict";
var $ = converse.env.jQuery,
_ = converse.env._,
utils = converse.env.utils,
Backbone = converse.env.Backbone,
b64_sha1 = converse.env.b64_sha1,
moment = converse.env.moment;
......@@ -70,14 +71,14 @@
},
maximize: function () {
this.save({
utils.saveWithFallback(this, {
'minimized': false,
'time_opened': moment().valueOf()
});
},
minimize: function () {
this.save({
utils.saveWithFallback(this, {
'minimized': true,
'time_minimized': moment().format()
});
......
......@@ -411,8 +411,10 @@
},
clearUnreadMsgCounter: function() {
this.save({'num_unread': 0});
this.save({'num_unread_general': 0});
utils.saveWithFallback(this, {
'num_unread': 0,
'num_unread_general': 0
});
}
});
......
......@@ -522,5 +522,16 @@
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;
}));
(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";
config.paths['test-utils'] = "tests/utils";
config.paths.sinon = "node_modules/sinon/pkg/sinon";
config.paths.transcripts = "converse-logs/converse-logs";
config.paths.jasmine = "node_modules/jasmine-core/lib/jasmine-core/jasmine";
config.paths.boot = "node_modules/jasmine-core/lib/jasmine-core/boot";
config.paths["jasmine-core"] = "node_modules/jasmine-core/lib/jasmine-core/jasmine";
config.paths.jasmine = "node_modules/jasmine-core/lib/jasmine-core/boot";
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["console-runner"] = "node_modules/phantom-jasmine/lib/console-runner";
config.shim.jasmine = {
exports: 'window.jasmineRequire'
};
config.shim['jasmine-html'] = {
deps: ['jasmine'],
deps: ['jasmine-core'],
exports: 'window.jasmineRequire'
};
config.shim['jasmine-console'] = {
deps: ['jasmine'],
deps: ['jasmine-core'],
exports: 'window.jasmineRequire'
};
config.shim.boot = {
deps: ['jasmine', 'jasmine-html', 'jasmine-console'],
config.shim.jasmine = {
deps: ['jasmine-core', 'jasmine-html', 'jasmine-console'],
exports: 'window.jasmine'
};
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 = [
//"spec/transcripts",
// "spec/profiling",
"jasmine",
"spec/utils",
"spec/converse",
"spec/bookmarks",
......@@ -73,31 +53,16 @@ var specs = [
"spec/register"
];
require(['jquery', 'mock', 'boot', 'sinon', 'wait-until-promise'],
function($, mock, jasmine, sinon, waitUntilPromise) {
require(['console-reporter', 'mock', 'sinon', 'wait-until-promise', 'pluggable'],
function(ConsoleReporter, mock, sinon, waitUntilPromise, pluggable) {
window.sinon = sinon;
window.waitUntilPromise = waitUntilPromise['default'];
window.localStorage.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
require(specs, function () {
// Initialize the HTML Reporter and execute the environment (setup by `boot.js`)
// http://stackoverflow.com/questions/19240302/does-jasmine-2-0-really-not-work-with-require-js
require(specs, function (jasmine) {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.addReporter(new ConsoleReporter());
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