|
|
@ -13,7 +13,7 @@ use std::io::{BufRead, BufReader}; |
|
|
|
use std::path::PathBuf; |
|
|
|
use std::path::PathBuf; |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn sparql_w3c_syntax_testsuite() { |
|
|
|
fn sparql_w3c_syntax_testsuite() -> Result<()> { |
|
|
|
let manifest_10_url = "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/manifest-syntax.ttl"; |
|
|
|
let manifest_10_url = "http://www.w3.org/2001/sw/DataAccess/tests/data-r2/manifest-syntax.ttl"; |
|
|
|
let manifest_11_url = |
|
|
|
let manifest_11_url = |
|
|
|
"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest.ttl"; |
|
|
|
"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/syntax-query/manifest.ttl"; |
|
|
@ -54,10 +54,11 @@ fn sparql_w3c_syntax_testsuite() { |
|
|
|
assert!(false, "Not supported test: {}", test); |
|
|
|
assert!(false, "Not supported test: {}", test); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
#[test] |
|
|
|
fn sparql_w3c_query_evaluation_testsuite() { |
|
|
|
fn sparql_w3c_query_evaluation_testsuite() -> Result<()> { |
|
|
|
//TODO: dataset open-world
|
|
|
|
//TODO: dataset open-world
|
|
|
|
let manifest_10_urls = vec![ |
|
|
|
let manifest_10_urls = vec![ |
|
|
|
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest.ttl", |
|
|
|
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/algebra/manifest.ttl", |
|
|
@ -113,27 +114,25 @@ fn sparql_w3c_query_evaluation_testsuite() { |
|
|
|
.into_iter() |
|
|
|
.into_iter() |
|
|
|
.flat_map(|manifest| TestManifest::new(manifest)) |
|
|
|
.flat_map(|manifest| TestManifest::new(manifest)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
let test = test_result.unwrap(); |
|
|
|
let test = test_result?; |
|
|
|
if test_blacklist.contains(&test.id) { |
|
|
|
if test_blacklist.contains(&test.id) { |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if test.kind == "QueryEvaluationTest" { |
|
|
|
if test.kind == "QueryEvaluationTest" { |
|
|
|
let repository = MemoryRepository::default(); |
|
|
|
let repository = MemoryRepository::default(); |
|
|
|
if let Some(data) = &test.data { |
|
|
|
if let Some(data) = &test.data { |
|
|
|
load_graph_to_repository(&data, &repository.connection().unwrap(), None).unwrap(); |
|
|
|
load_graph_to_repository(&data, &repository.connection()?, None)?; |
|
|
|
} |
|
|
|
} |
|
|
|
for graph_data in &test.graph_data { |
|
|
|
for graph_data in &test.graph_data { |
|
|
|
load_graph_to_repository( |
|
|
|
load_graph_to_repository( |
|
|
|
&graph_data, |
|
|
|
&graph_data, |
|
|
|
&repository.connection().unwrap(), |
|
|
|
&repository.connection()?, |
|
|
|
Some(&NamedNode::new(graph_data).into()), |
|
|
|
Some(&NamedNode::new(graph_data).into()), |
|
|
|
) |
|
|
|
)?; |
|
|
|
.unwrap(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
match repository |
|
|
|
match repository |
|
|
|
.connection() |
|
|
|
.connection()? |
|
|
|
.unwrap() |
|
|
|
.prepare_query(read_file(&test.query)?) |
|
|
|
.prepare_query(read_file(&test.query).unwrap()) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
Err(error) => assert!( |
|
|
|
Err(error) => assert!( |
|
|
|
false, |
|
|
|
false, |
|
|
@ -148,19 +147,19 @@ fn sparql_w3c_query_evaluation_testsuite() { |
|
|
|
), |
|
|
|
), |
|
|
|
Ok(result) => { |
|
|
|
Ok(result) => { |
|
|
|
let expected_graph = |
|
|
|
let expected_graph = |
|
|
|
load_sparql_query_result_graph(test.result.as_ref().unwrap()).unwrap(); |
|
|
|
load_sparql_query_result_graph(test.result.as_ref().unwrap())?; |
|
|
|
let with_order = expected_graph |
|
|
|
let with_order = expected_graph |
|
|
|
.triples_for_predicate(&rs::INDEX) |
|
|
|
.triples_for_predicate(&rs::INDEX) |
|
|
|
.next() |
|
|
|
.next() |
|
|
|
.is_some(); |
|
|
|
.is_some(); |
|
|
|
let actual_graph = to_graph(result, with_order).unwrap(); |
|
|
|
let actual_graph = to_graph(result, with_order)?; |
|
|
|
assert!( |
|
|
|
assert!( |
|
|
|
actual_graph.is_isomorphic(&expected_graph), |
|
|
|
actual_graph.is_isomorphic(&expected_graph), |
|
|
|
"Failure on {}.\nExpected file:\n{}\nOutput file:\n{}\nParsed query:\n{}\nData:\n{}\n", |
|
|
|
"Failure on {}.\nExpected file:\n{}\nOutput file:\n{}\nParsed query:\n{}\nData:\n{}\n", |
|
|
|
test, |
|
|
|
test, |
|
|
|
expected_graph, |
|
|
|
expected_graph, |
|
|
|
actual_graph, |
|
|
|
actual_graph, |
|
|
|
read_file_to_string(&test.query).unwrap(), |
|
|
|
read_file_to_string(&test.query)?, |
|
|
|
repository_to_string(&repository) |
|
|
|
repository_to_string(&repository) |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
@ -170,6 +169,7 @@ fn sparql_w3c_query_evaluation_testsuite() { |
|
|
|
assert!(false, "Not supported test: {}", test); |
|
|
|
assert!(false, "Not supported test: {}", test); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn repository_to_string(repository: impl Repository) -> String { |
|
|
|
fn repository_to_string(repository: impl Repository) -> String { |
|
|
|