diff --git a/javascripts/models/test-model.js b/javascripts/models/test-model.js index f177412..9234ee1 100644 --- a/javascripts/models/test-model.js +++ b/javascripts/models/test-model.js @@ -158,19 +158,28 @@ window.Test = Backbone.Model.extend({ var query = $rdf.SPARQLToQuery(sparqlText, true, kb); var queryResult = "error"; if (query) { + // rdflib.js does not always call the final onDone callback (bug?) + var timeoutFallback = setTimeout(function() { + window.console && window.console.log("timeout waiting for query to call done callback"); + that.set('result', queryResult); + }, 8000); + queryResult = expectedResults ? "FAIL" : "PASS"; kb.fetcher = null; // disables resource fetching - kb.query(query, function (result) { - // Result callback - // Indicate pass/fail and style - queryResult = result === expectedResults ? "PASS" : "FAIL"; + kb.query(query, function(result) { + // result is an empty array since ASK queries have no bindings + queryResult = Array.isArray(result) === expectedResults ? "PASS" : "FAIL"; + }, null, function () { + clearTimeout(timeoutFallback); + that.set('result', queryResult); }); + } else { + // Indicate fail and style + that.set('result', queryResult); } - // Indicate fail and style - that.set("result", queryResult); }).fail(function (result) { // Indicate fail and style - window.console && window.console.log("Error fetching " + sparqlUrl); + window.console && window.console.log("Error fetching " + sparqlUrl + ": " + result); that.set("result", "error"); }); }); @@ -267,7 +276,7 @@ window.TestCollection = Backbone.Collection.extend({ run_next: function(test) { var result = test.get('result'); - if (this.running && _.include(["PASS", "FAIL"], result)) { + if (this.running && _.include(["PASS", "FAIL", "error"], result)) { console.log("test " + test.get('num') + ' completed with ' + result); this.passed = _.reduce(this.models, function(memo, test) { return memo + (test.get('result') == "PASS" ? 1 : 0); @@ -275,8 +284,11 @@ window.TestCollection = Backbone.Collection.extend({ this.failed = _.reduce(this.models, function(memo, test) { return memo + (test.get('result') == "FAIL" ? 1 : 0); }, 0); + this.errored = _.reduce(this.models, function(memo, test) { + return memo + (test.get('result') == "error" ? 1 : 0); + }, 0); - var total = this.passed + this.failed; + var total = this.passed + this.failed + this.errored; var next = this.at(total); if (next) { console.log("next test: " + next.get('num'));