Skip to content

Commit a04e31b

Browse files
committed
catch exception in qunit log parsing
1 parent 018ed03 commit a04e31b

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/server.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,21 @@ exports.Server = function Server(bsClient, workers) {
100100

101101
function parseBody(body) {
102102
// TODO: Have better implementation
103-
return JSON.parse(qs.parse(body).data.replace(/\n/g, "\\n").replace(/\\s/g, "\s"));
103+
return JSON.parse(qs.parse(body).data.escapeSpecialChars());
104104
}
105105

106106
handlers = {
107107
"_progress": function progressHandler(uri, body, request, response) {
108-
query = parseBody(body);
109-
110108
var uuid = request.headers['x-worker-uuid'];
111109
var worker = workers[uuid];
112-
//console.log("Tests run:", query.tests_run);
110+
query = "";
111+
try {
112+
query = parseBody(body);
113+
} catch(e) {
114+
console.log("[%s] Exception in parsing QUnit log", worker.string)
115+
console.log("[%s] Log: " + qs.parse(body).data, worker.string)
116+
}
117+
113118
if (query.tracebacks) {
114119
query.tracebacks.forEach(function (traceback) {
115120
console.log("[%s] Error:", worker.string, traceback);

lib/utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ var http = require('http');
33
var url = require('url');
44
var querystring = require('querystring');
55

6+
String.prototype.escapeSpecialChars = function() {
7+
return this.replace(/\n/g, "\\n")
8+
.replace(/\\s/g, "\s")
9+
.replace(/\\\'/, "\'");
10+
};
11+
612
var titleCase = function toTitleCase(str) {
713
return str.replace(/\w\S*/g, function (txt) {
814
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();

0 commit comments

Comments
 (0)