1.25.0 • Published 11 months ago

rdf-test-suite v1.25.0

Weekly downloads
64
License
MIT
Repository
github
Last release
11 months ago

RDF-Test-Suite.js

Build status Coverage Status npm version

This tool executes the RDF and SPARQL test suites with any given system.

It can either output human-readable test results to the console, or it can output machine-readable reports in the EARL vocabulary.

Currently, the following test suites are supported:

Not all RDF test suites are supported at the moment. However, this package is fully modular, so that support for different test cases can be implemented easily.

Planned support:

Installation

Either install it globally:

$ yarn global add rdf-test-suite

Or locally (as a dev dependency):

$ yarn add --dev rdf-test-suite

Usage

After installing, the rdf-test-suite script will become available.

This script requires some kind of engine as first argument, and a test suite manifest URL as second argument.

The engine is a JavaScript file that can handle the test suite. The interface of this engine depends on the manifest. For example, the SPARQL 1.1 test suite requires an IQueryEngine, while the RDF/XML test suite requires a IParser.

Basic execution

The following command executes the SPARQL 1.1 test suite on the engine myengine.js:

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl

An example of what this myengine.js looks like is available for the Comunica SPARQL engine.

This command will output something like this:

...
✔ syn-bad-pname-04 (http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest#test_pn_bad_04) 0.293588ms
✔ syn-bad-pname-05 (http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest#test_pn_bad_05) 0.498646ms
✔ syn-bad-pname-06 (http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest#test_pn_bad_06) 0.513092ms
✔ syn-bad-pname-07 (http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest#test_pn_bad_07) 0.498646ms
✔ syn-bad-pname-08 (http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest#test_pn_bad_08) 0.293588ms
✔ syn-bad-pname-09 (http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest#test_pn_bad_09) 0.293588ms
✔ syn-bad-pname-10 (http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest#test_pn_bad_10) 0.516346ms
✔ syn-bad-pname-11 (http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest#test_pn_bad_11) 0.498646ms
✔ syn-bad-pname-12 (http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest#test_pn_bad_12) 0.516346ms
✔ syn-bad-pname-13 (http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest#test_pn_bad_13) 0.498646ms
✔ syn-pp-in-collection (http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest#test_pp_coll) 0.516346ms
✖ 105 / 268 tests succeeded!

Test filtering

With the -t option, you can filter tests that should be executed based on a regex that will be matched with the test URI.

For example:

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  -t test_pn_bad_0

Test skipping

With the --skip option you can filter tests that should be skipped based on a regex that will be matched with the test URI.

For example:

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  --skip test_pn_bad_0
$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  --skip (test_pn_bad_0|test_pn_bad_1)

Summarized output

By default, the printed test results are verbose, and print expanded views of failed tests.

You can change this to a more compact view using -o summary.

For example:

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  -o summary

EARL output

Test results are human readable by default. This can be changed to output machine-readable reports in the EARL vocabulary in the Turtle serialization. These reports can be published to report the compliance of engines to certain specifications, like on W3C’s RDF Test Curation Community Group.

As EARL reports require some metadata on your engine, you will need to provide a properties file via the -p argument.

This properties file can look something like this:

{
  "applicationBugsUrl": "https://github.com/comunica/comunica/issues",
  "applicationDescription": "A Comunica engine for SPARQL query evaluation over heterogeneous interfaces",
  "applicationHomepageUrl": "http://comunica.linkeddatafragments.org/",
  "applicationNameFull": "Comunica SPARQL",
  "applicationNameNpm": "@comunica/actor-init-sparql",
  "applicationUri": "https://www.npmjs.com/package/@comunica/actor-init-sparql",
  "authors": [
    {
      "homepage": "https://www.rubensworks.net/",
      "name": "Ruben Taelman",
      "uri": "https://www.rubensworks.net/#me"
    }
  ],
  "licenseUri": "http://opensource.org/licenses/MIT",
  "reportUri": null,
  "specificationUris": [
      "http://www.w3.org/TR/sparql11-query/"
  ],
  "version": "1.2.3"
}

The properties file can point to a non-existing file, in which case it will be auto-generated from the package.json file in the current working directory.

For example:

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  -o earl -p earl-meta.json

Restricting execution to certain specifications

Some test suites (like the one of SPARQL 1.1) contains tests for multiple specifications. If you only want to test your system for a single specification, then you can define this with the -s parameter.

For example, the following command executes the SPARQL 1.1 test cases that apply to the http://www.w3.org/TR/sparql11-query/ specification.

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  -s http://www.w3.org/TR/sparql11-query/

Enabling HTTP caching

By default, rdf-test-suite will look up all required manifest files. If this takes too much time, or if you don't have internet connection, then you can enable HTTP caching with the -c argument, so that all files only have to be looked up once.

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  -c path/to/cache/

If you don't provide a caching value after the -c, then the directory will default to .rdf-test-suite-cache/.

Ignore exit code

When there are failing tests, rdf-test-suite will exit with code 1 instead of 0. This can be useful in Continuous Integration tools.

If you want to disable this behaviour, you can add the -e flag to force an exit code 0.

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  -e

Pass custom options to the engine

With the optional -i option, a JSON string with arguments can be passed to the engine. These arguments will become available in both IQueryEngine, and IParser.

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  -i '{ "myProperty": "myValue" }'

Test timeouts

By default, all tests are allowed to run 3000 ms. Using the -d option, you can change this value.

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  -d 5000

Map URLs to local files

In cases where you are developing your own test manifests, it may be useful to intercept certain URL lookups and return local files instead.

In order to achieve this, the -m option can be used, with a mapping defined with the following pattern: URL~PATH.

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  -m http://w3c.github.io/rdf-tests/sparql11/data-sparql11/~/path/to/my/files/

Using rejected tests

In cases where you wish to execute a test suite that contains rdft:Rejected test entries rdf-test-suite will skip those tests by default. If you wish to execute those tests as well, you can use the -r option.

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  -r

Only using explicitly approved tests

In cases where you wish to execute a test suite that contains rdft:Approved test entries rdf-test-suite will, by default execute those tests as well as all other tests that are not explicitly rejected. If you wish to only execute those tests that are explicitly approved, you can use the -a option.

$ rdf-test-suite myengine.js http://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl \
  -a

Supported test suites

ManifestSpecificationInterfaceEntry manifest
SPARQL 1.0 testsSPARQL 1.0IQueryEnginehttps://w3c.github.io/rdf-tests/sparql11/data-r2/manifest.ttl
SPARQL 1.1 testsSPARQL 1.1 QueryIQueryEnginehttp://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl
SPARQL 1.1 testsSPARQL 1.1 UpdateIUpdateEnginehttp://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl
SPARQL 1.1 testsSPARQL 1.1 Results CSV/TSVhttp://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl
SPARQL 1.1 testsSPARQL 1.1 Results JSONhttp://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl
SPARQL 1.1 testsSPARQL 1.1 Federated Queryhttp://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl
SPARQL 1.1 testsSPARQL 1.1 Entailmenthttp://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl
SPARQL 1.1 testsSPARQL 1.1 Service Descriptionhttp://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl
SPARQL 1.1 testsSPARQL 1.1 Protocolhttp://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl
SPARQL 1.1 testsSPARQL 1.1 HTTP RDF Updatehttp://w3c.github.io/rdf-tests/sparql/sparql11/manifest-all.ttl
RDF/XML Syntax TestsRDF 1.1 XML SyntaxIParserhttp://w3c.github.io/rdf-tests/rdf-xml/manifest.ttl
N-Triples TestsRDF 1.1 N-TriplesIParserhttp://w3c.github.io/rdf-tests/ntriples/manifest.ttl
N-Quads TestsRDF 1.1 N-QuadsIParserhttp://w3c.github.io/rdf-tests/nquads/manifest.ttl
Turtle TestsRDF 1.1 TurtleIParserhttp://w3c.github.io/rdf-tests/turtle/manifest.ttl
TriG TestsRDF 1.1 TriGIParserhttp://w3c.github.io/rdf-tests/trig/manifest.ttl
JSON-LD Test SuiteJSON-LD (1.0 and 1.1)IParserhttps://w3c.github.io/json-ld-api/tests/toRdf-manifest.jsonld
JSON-LD Test SuiteJSON-LD (1.0 and 1.1)IParserhttps://w3c.github.io/json-ld-api/tests/html-manifest.jsonld
JSON-LD Test SuiteJSON-LD (1.0 and 1.1)ISerializerhttps://w3c.github.io/json-ld-api/tests/fromRdf-manifest.jsonld
JSON-LD-Star Test SuiteJSON-LD-StarIParserhttps://json-ld.github.io/json-ld-star/tests/toRdf-manifest.jsonld
JSON-LD-Star Test SuiteJSON-LD-StarISerializerhttps://json-ld.github.io/json-ld-star/tests/fromRdf-manifest.jsonld
RDFa Test SuiteRDFa 1.1IParserhttp://rdfa.info/test-suite/test-cases/rdfa1.1/html5/manifest.ttl
Microdata to RDF Test SuiteMicrodata to RDFIParserhttps://w3c.github.io/microdata-rdf/tests/manifest.ttl
Notation3 Test SuiteN3 GrammarIParserhttps://w3c.github.io/N3/tests/N3Tests/manifest-parser.ttl
Notation3 Test SuiteExtended N3 GrammarIParserhttps://w3c.github.io/N3/tests/N3Tests/manifest-extended.ttl
Turtle-star Evaluation TestsRDF-star and SPARQL-starhttps://w3c.github.io/rdf-star/tests/turtle/eval/manifest.jsonld
Turtle-star Syntax TestsRDF-star and SPARQL-starhttps://w3c.github.io/rdf-star/tests/turtle/syntax/manifest.jsonld
TriG-star Evaluation TestsRDF-star and SPARQL-starhttps://w3c.github.io/rdf-star/tests/trig/eval/manifest.jsonld
TriG-star Syntax TestsRDF-star and SPARQL-starhttps://w3c.github.io/rdf-star/tests/trig/syntax/manifest.jsonld
N-Triples-star Syntax TestsRDF-star and SPARQL-starhttps://w3c.github.io/rdf-star/tests/nt/syntax/manifest.jsonld
RDF-star Semantics testsRDF-star and SPARQL-starhttps://w3c.github.io/rdf-star/tests/semantics/manifest.jsonld
SPARQL-star Syntax TestsRDF-star and SPARQL-starhttps://w3c.github.io/rdf-star/tests/sparql/syntax/manifest.jsonld
SPARQL-star Evaluation TestsRDF-star and SPARQL-starhttps://w3c.github.io/rdf-star/tests/sparql/eval/manifest.jsonld

License

This software is written by Ruben Taelman.

This code is released under the MIT license.

1.25.0

11 months ago

1.23.1

1 year ago

1.24.0

1 year ago

1.21.0

1 year ago

1.23.0

1 year ago

1.22.0

1 year ago

1.19.3

1 year ago

1.20.0

1 year ago

1.19.0

2 years ago

1.19.2

2 years ago

1.19.1

2 years ago

1.18.0

3 years ago

1.17.0

3 years ago

1.16.0

4 years ago

1.15.0

4 years ago

1.14.0

4 years ago

1.13.4

4 years ago

1.13.3

4 years ago

1.13.2

4 years ago

1.13.1

4 years ago

1.13.0

4 years ago

1.12.1

4 years ago

1.12.0

4 years ago

1.11.0

5 years ago

1.10.6

5 years ago

1.10.5

5 years ago

1.10.4

5 years ago

1.10.3

5 years ago

1.10.2

5 years ago

1.10.1

5 years ago

1.10.0

5 years ago

1.9.3

5 years ago

1.9.2

5 years ago

1.9.1

5 years ago

1.9.0

5 years ago

1.8.2

5 years ago

1.8.1

5 years ago

1.8.0

5 years ago

1.7.0

5 years ago

1.6.0

5 years ago

1.5.3

5 years ago

1.5.2

5 years ago

1.5.1

5 years ago

1.5.0

5 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

6 years ago