Skip to content

Commit

Permalink
Issue #1 WIP - All W3C SPARQL 1.0 Query tests that use data passing e…
Browse files Browse the repository at this point in the history
…xcluding 'dataset', use of named graphs, and tests already excluded by Oxigraph.
  • Loading branch information
donpellegrino authored and GregHanson committed Apr 16, 2024
1 parent d77b92c commit b91ecef
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 4 deletions.
54 changes: 50 additions & 4 deletions oxhdt-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,21 @@ mod tests {
}
}

macro_rules! rdf_sparql10_customized_test {
($(($group:literal, $name:ident, $query:literal, $data:literal, $result:literal)),*) => {
$(
#[test]
fn $name() {
assert!(super::rdf_test_runner(
concat!("../testsuite/rdf-tests/sparql/sparql10/", $group, "/", $query),
concat!("tests/resources/rdf-tests/sparql/sparql10/", $group, "/", $data),
concat!("https://github.com/oxigraph/oxhdt-sys/tests/resources/rdf-tests/sparql/sparql10/", $group, "/", $result)
));
}
)*
}
}

// Create test functions for the combinations of input, data, and
// output from the W3C SPARQL 1.0 Basic test suite. Note that this
// implementation fails to stay automatically up-to-date with
Expand Down Expand Up @@ -602,11 +617,42 @@ mod tests {
}

mod reduced {
// TODO These both fail. Oxigraph ignores reduced_2 but it is
// not clear why.
rdf_sparql10_test! {
("reduced", reduced_1, "reduced-1.rq", "reduced-star.hdt", "reduced-1.srx"),
rdf_sparql10_ignore_test! {
// This test relies on naive iteration on the input file
("reduced", reduced_2, "reduced-2.rq", "reduced-str.hdt", "reduced-2.srx")
}

// Original Data
// <http://example/x1> <http://example/p> "abc" .
// <http://example/x1> <http://example/q> "abc" .
// <http://example/x2> <http://example/p> "abc" .
//
// HDT
// <http://example/x1> <http://example/p> "abc" .
// <http://example/x1> <http://example/q> "abc" .
// <http://example/x2> <http://example/p> "abc" .
//
// Query
// SELECT REDUCED *
// WHERE {
// { ?s :p ?o } UNION { ?s :q ?o }
// }
//
// Expected
// s o
// <http://example/x1> "abc"
// <http://example/x1> "abc"
// <http://example/x2> "abc"
//
// Actual
// s o
// <http://example/x1> "abc"
// <http://example/x2> "abc"
//
// The actual is passable per
// https://www.w3.org/TR/sparql11-query/#modDuplicates
rdf_sparql10_customized_test! {
("reduced", reduced_1, "reduced-1.rq", "reduced-star.hdt", "reduced-1.srx")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<sparql
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xs="http://www.w3.org/2001/XMLSchema#"
xmlns="http://www.w3.org/2005/sparql-results#" >
<head>
<variable name="s"/>
<variable name="o"/>
</head>
<results>
<result>
<binding name="s"><uri>http://example/x1</uri></binding>
<binding name="o"><literal>abc</literal></binding>
</result>
<!-- This row is optional per -->
<!-- https://www.w3.org/TR/sparql11-query/#modDuplicates -->
<!-- <result> -->
<!-- <binding name="s"><uri>http://example/x1</uri></binding> -->
<!-- <binding name="o"><literal>abc</literal></binding> -->
<!-- </result> -->
<result>
<binding name="s"><uri>http://example/x2</uri></binding>
<binding name="o"><literal>abc</literal></binding>
</result>
</results>
</sparql>
5 changes: 5 additions & 0 deletions testsuite/src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ pub fn read_file(url: &str) -> Result<impl Read> {
)
} else if url.starts_with("http://drobilla.net/sw/serd/test/") {
url.replace("http://drobilla.net/sw/serd/test/", "serd-tests/")
} else if url.starts_with("https://github.com/oxigraph/oxhdt-sys/tests/") {
url.replace(
"https://github.com/oxigraph/oxhdt-sys/tests/",
"../oxhdt-sys/tests/",
)
} else {
bail!("Not supported url for file: {url}")
});
Expand Down

0 comments on commit b91ecef

Please sign in to comment.