test-suite: fix eval of ASK results and continue running after errors #46
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm not sure if this repository is still maintained or worth changing at this point, but I ran into #16 and took a detour to see if there was a quick fix. This is a partial fix with the remaining issues presumably related to the upstream rdflib.js package which I did not research further. Personally, I have moved to integrating the test files directly into my automated tests (thank you for the curated test cases), so the browser-based testing page is no longer directly relevant to me. Regardless, I thought it might be helpful to document the findings and this potential fix for others.
These were the errors I ran into, however, I'm not sure how this would have been working previously, so there's a possibility I have misunderstood something else entirely. The patch tries to work around them with a minimal set of changes.
kb.querycallback function receives an array of bindings for a match, nottrueorfalse. As anASKquery, there are no bindings, so the callback is called with an empty[]array which never equates to theexpectedResultsboolean.kb.queryfunction is asynchronous, so a case is always marked as anerror. Then the callback may or may not be invoked, but is effectively a no-op since it only reassigns the scopedqueryResult.$rdf.SPARQLToQueryparser throws an error on several cases for a variety of reasons which always interrupts the "Run All Tests" feature.Since the SPARQL parsing fails, I changed the "Run All Tests" behavior to continue after an error. That might not be a desirable default, but seemed more confusing to classify it as
FAILor introduce error-specific handling. The related console messages for the parse errors are:The
kb.queryfunction includes a fourth argument,onDone, which, by name, is called after the query has been fully evaluated. This is mostly true, but occasionally and predictably it is not. As a workaround, I used a timeout fallback for updating the test result and allow the running to tests to continue. The related console messages for the timeout errors are:I did try updating to the latest rdflib.js (v2.3.5) and switching to the
querySyncfunction. The same SPARQL query parse errors still exist, and instead of relying on theonDonecallback (which is apparently now documented with "do not use"), it errors with a caught message ofSync query should have called done function.Since it did not seem to fix anything (nor break anything), I did not include it in this change.