semsol / arc2

ARC RDF Classes for PHP
Other
332 stars 89 forks source link

Added SPARQL 1.1 compliance tests (incomplete) #102

Closed k00ni closed 6 years ago

k00ni commented 6 years ago

What do you do, if you have a cold and must stay at home? You write tests for ARC2! :trollface:

W3C test suite

There is a test suite for SPARQL 1.1 compliance provided by the W3C here: https://www.w3.org/2009/sparql/docs/tests/. It contains many tests for different types of queries. They range from simple SELECT queries over function-usage to graph management.

Goal and motivation

I want to know the current state of SPARQL 1.0/1.1 support of ARC2. Instead of using custom queries, i decided to use the official test suite. Their tests showed that ARC2 lacks major parts of SPARQL 1.0/1.1. Please do not understand that as blaming, but as a first step to define a basement for further development. With these tests, further changes on the query engine can be made without worrying about adding bugs or change expected behavior.

Tested ARC2 component

These new tests check the result from ARC2_Store::query for a given query.

Coverage

I picked mostly cases, which cover major functionality. In the following related folders from the test suite:

Additionally, there a some cases which have exotic kinds of configuration (manifest.ttl). A few of those are also part of the list.

7 folders are covered, 22 folders are not covered yet.

Important: How to interpret the new tests

Don't get fooled, there are 2 different kinds of the tests:

Every skipped test provides meaningful information. For instance Tests\sparql11\AggregatesTest::test_agg_avg_01 outputs:

Test skipped, because of rounding bug in AVG function. 
See https://github.com/semsol/arc2/issues/99

This way one can see the limitations of ARC2, sometimes also the reason. If one decides to extend/fix ARC2 SPARQL support, they can take the related test and change it.

Current output in PHPUnit

New PHPUnit output below. To see a full overview, you can look here.

.SS.SSSSSSS.SSS..S..SS.S....S.....SSSSSSSSSSSSSSSSSSSSSSS.SSSSS  63 / 171 ( 36%)
..SS...SSSSSSS..SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS......... 126 / 171 ( 73%)
.S.S.........................................                   171 / 171 (100%)

Time: 32 seconds, Memory: 12.00MB

There were 94 skipped tests:

1) Tests\sparql11\AggregatesTest::test_agg_avg_01

Test skipped, because of rounding bug in AVG function. 
See https://github.com/semsol/arc2/issues/99
/home/travis/build/k00ni/arc2/tests/sparql11/AggregatesTest.php:29
/home/travis/build/k00ni/arc2/vendor/phpunit/phpunit/phpunit:52

2) Tests\sparql11\AggregatesTest::test_agg_avg_02

This kind of query is currently not supported. ARC2_Store::query returns 0 for query: 
PREFIX : <http://www.example.org/>
SELECT ?s (AVG(?o) AS ?avg)
FROM <http://arc/data/> WHERE { ?s ?p ?o
}
GROUP BY ?s
HAVING (AVG(?o) <= 2.0)

/home/travis/build/k00ni/arc2/tests/sparql11/AggregatesTest.php:41
/home/travis/build/k00ni/arc2/vendor/phpunit/phpunit/phpunit:52

[...]

Further changes

Besides these new files in tests/sparql11, i changed the following files:

Related issues

During this process, i opened the following issues:

k00ni commented 6 years ago

Ping @semsol :)

semsol commented 6 years ago

Cheers :-)