Adds support to run QUnit tests in CI with JS TestNet

This commit is contained in:
Kumar McMillan 2010-11-22 09:51:10 -06:00
Родитель 5711830fbc
Коммит a527fa5ff1
3 изменённых файлов: 107 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,101 @@
//
// Adapter for JS TestNet
// https://github.com/kumar303/jstestnet
//
// Be sure this file is loaded *after* qunit/testrunner.js or whatever else
// you're using
(function() {
var canPost = false;
try {
canPost = !!window.top.postMessage;
} catch(e){}
if (!canPost) {
return;
}
function postMsg(data) {
var msg = '';
for (var k in data) {
if (msg.length > 0) {
msg += '&';
}
msg += k + '=' + encodeURI(data[k]);
}
window.top.postMessage(msg, '*');
}
// QUnit (jQuery)
// http://docs.jquery.com/QUnit
if ( typeof QUnit !== "undefined" ) {
QUnit.begin = function() {
postMsg({
action: 'hello',
user_agent: navigator.userAgent
});
};
QUnit.done = function(failures, total) {
// // Clean up the HTML (remove any un-needed test markup)
// $("nothiddendiv").remove();
// $("loadediframe").remove();
// $("dl").remove();
// $("main").remove();
//
// // Show any collapsed results
// $('ol').show();
postMsg({
action: 'done',
failures: failures,
total: total
});
};
QUnit.log = function(result, message) {
// Strip out html:
message = message.replace(/<(?:.|\s)*?>/g, '');
postMsg({
action: 'log',
result: result,
message: message
});
};
QUnit.moduleStart = function(name) {
postMsg({
action: 'set_module',
name: name
});
};
QUnit.testStart = function(name) {
postMsg({
action: 'set_test',
name: name
});
};
// window.TestSwarm.serialize = function(){
// // Clean up the HTML (remove any un-needed test markup)
// remove("nothiddendiv");
// remove("loadediframe");
// remove("dl");
// remove("main");
//
// // Show any collapsed results
// var ol = document.getElementsByTagName("ol");
// for ( var i = 0; i < ol.length; i++ ) {
// ol[i].style.display = "block";
// }
//
// return trimSerialize();
// };
} else {
throw new Error("Cannot adapt to jstestnet: Unknown test runner");
}
})();

Просмотреть файл

@ -1,6 +1,7 @@
{ {
"name": "Main Test Suite", "name": "Main Test Suite",
"extra_media_urls": [ "extra_media_urls": [
"js/zamboni/jstestnet.js",
"js/zamboni/tests.js", "js/zamboni/tests.js",
"js/zamboni/devhub.js" "js/zamboni/devhub.js"
] ]

Просмотреть файл

@ -141,7 +141,11 @@ if 'django_qunit' in settings.INSTALLED_APPS:
import django_qunit.views import django_qunit.views
import jingo import jingo
ctx = django_qunit.views.get_suite_context(request, path) ctx = django_qunit.views.get_suite_context(request, path)
return jingo.render(request, 'qunit.html', ctx) response = jingo.render(request, 'qunit.html', ctx)
# This allows another site to embed the QUnit suite
# in an iframe (for CI).
response['x-frame-options'] = ''
return response
urlpatterns += patterns('', urlpatterns += patterns('',
url(r'^qunit/(?P<path>.*)', zamboni_qunit), url(r'^qunit/(?P<path>.*)', zamboni_qunit),