Testsuite: fixes FROM and FROM NAMED tests

pull/76/head
Tpt 4 years ago
parent 30bc424432
commit 73191b2d5f
  1. 66
      testsuite/src/sparql_evaluator.rs
  2. 12
      testsuite/tests/sparql.rs

@ -89,39 +89,69 @@ fn evaluate_sparql_test(test: &Test) -> Result<()> {
test,
error
)),
Ok(query) => match store.query_opt(query, options) {
Err(error) => Err(anyhow!(
"Failure to execute query of {} with error: {}",
test,
error
)),
Ok(actual_results) => {
let expected_results = load_sparql_query_result(test.result.as_ref().unwrap())
Ok(query) => {
// FROM and FROM NAMED support. We make sure the data is in the store
if !query.dataset().is_default_dataset() {
for graph_name in query.dataset().default_graph_graphs().unwrap_or(&[]) {
if let GraphName::NamedNode(graph_name) = graph_name {
load_to_store(graph_name.as_str(), &store, graph_name.as_ref())?;
} else {
return Err(anyhow!(
"Invalid FROM in query {} for test {}",
query,
test
));
}
}
for graph_name in query.dataset().available_named_graphs().unwrap_or(&[]) {
if let NamedOrBlankNode::NamedNode(graph_name) = graph_name {
load_to_store(graph_name.as_str(), &store, graph_name.as_ref())?;
} else {
return Err(anyhow!(
"Invalid FROM NAMED in query {} for test {}",
query,
test
));
}
}
}
match store.query_opt(query, options) {
Err(error) => Err(anyhow!(
"Failure to execute query of {} with error: {}",
test,
error
)),
Ok(actual_results) => {
let expected_results = load_sparql_query_result(
test.result.as_ref().unwrap(),
)
.map_err(|e| {
anyhow!("Error constructing expected graph for {}: {}", test, e)
})?;
let with_order =
if let StaticQueryResults::Solutions { ordered, .. } = &expected_results {
let with_order = if let StaticQueryResults::Solutions { ordered, .. } =
&expected_results
{
*ordered
} else {
false
};
let actual_results =
StaticQueryResults::from_query_results(actual_results, with_order)?;
let actual_results =
StaticQueryResults::from_query_results(actual_results, with_order)?;
if are_query_results_isomorphic(&expected_results, &actual_results) {
Ok(())
} else {
Err(anyhow!("Failure on {}.\nExpected file:\n{}\nOutput file:\n{}\nParsed query:\n{}\nData:\n{}\n",
if are_query_results_isomorphic(&expected_results, &actual_results) {
Ok(())
} else {
Err(anyhow!("Failure on {}.\nExpected file:\n{}\nOutput file:\n{}\nParsed query:\n{}\nData:\n{}\n",
test,
expected_results,
actual_results,
Query::parse(&read_file_to_string(query_file)?, Some(query_file)).unwrap(),
store
))
))
}
}
}
},
}
}
} else if test.kind
== "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#PositiveUpdateSyntaxTest11"

@ -35,16 +35,6 @@ fn sparql10_w3c_query_syntax_testsuite() -> Result<()> {
#[test]
fn sparql10_w3c_query_evaluation_testsuite() -> Result<()> {
run_testsuite("http://www.w3.org/2001/sw/DataAccess/tests/data-r2/manifest-evaluation.ttl", vec![
// FROM and FROM name tests support is not implemented yet
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/dataset/manifest#dawg-dataset-01",
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/dataset/manifest#dawg-dataset-03",
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/dataset/manifest#dawg-dataset-05",
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/dataset/manifest#dawg-dataset-06",
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/dataset/manifest#dawg-dataset-07",
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/dataset/manifest#dawg-dataset-08",
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/dataset/manifest#dawg-dataset-11",
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/dataset/manifest#dawg-dataset-11",
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/dataset/manifest#dawg-dataset-12b",
//Multiple writing of the same xsd:integer. Our system does strong normalization.
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-1",
"http://www.w3.org/2001/sw/DataAccess/tests/data-r2/distinct/manifest#distinct-9",
@ -98,8 +88,6 @@ fn sparql11_query_w3c_evaluation_testsuite() -> Result<()> {
// SPARQL 1.1 JSON query results deserialization is not implemented yet
"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/aggregates/manifest#agg-empty-group-count-1",
"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/aggregates/manifest#agg-empty-group-count-2",
// FROM tests support
"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/construct/manifest#constructwhere04",
//BNODE() scope is currently wrong
"http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#bnode01",
//Property path with unbound graph name are not supported yet

Loading…
Cancel
Save