Always check SPARQL roundtrip

pull/271/head
Tpt 2 years ago committed by Thomas Tanon
parent 825b330132
commit b84df8a3d9
  1. 68
      testsuite/src/sparql_evaluator.rs

@ -177,6 +177,16 @@ fn evaluate_evaluation_test(test: &Test) -> Result<()> {
error error
)), )),
Ok(query) => { Ok(query) => {
// We check parsing roundtrip
if let Err(error) = Query::parse(&query.to_string(), None) {
return Err(anyhow!(
"Failure to deserialize \"{}\" of {} with error: {}",
query.to_string(),
test,
error
));
}
// FROM and FROM NAMED support. We make sure the data is in the store // FROM and FROM NAMED support. We make sure the data is in the store
if !query.dataset().is_default_dataset() { if !query.dataset().is_default_dataset() {
for graph_name in query.dataset().default_graph_graphs().unwrap_or(&[]) { for graph_name in query.dataset().default_graph_graphs().unwrap_or(&[]) {
@ -296,31 +306,43 @@ fn evaluate_update_evaluation_test(test: &Test) -> Result<()> {
test, test,
error error
)), )),
Ok(update) => match store.update(update) { Ok(update) => {
Err(error) => Err(anyhow!( // We check parsing roundtrip
"Failure to execute update of {} with error: {}", if let Err(error) = Update::parse(&update.to_string(), None) {
test, return Err(anyhow!(
error "Failure to deserialize \"{}\" of {} with error: {}",
)), update.to_string(),
Ok(()) => { test,
let mut store_dataset: Dataset = store.iter().collect::<Result<_, _>>()?; error
store_dataset.canonicalize(); ));
let mut result_store_dataset: Dataset = }
result_store.iter().collect::<Result<_, _>>()?;
result_store_dataset.canonicalize(); match store.update(update) {
if store_dataset == result_store_dataset { Err(error) => Err(anyhow!(
Ok(()) "Failure to execute update of {} with error: {}",
} else { test,
Err(anyhow!( error
"Failure on {}.\nDiff:\n{}\nParsed update:\n{}\n", )),
test, Ok(()) => {
dataset_diff(&result_store_dataset, &store_dataset), let mut store_dataset: Dataset = store.iter().collect::<Result<_, _>>()?;
Update::parse(&read_file_to_string(update_file)?, Some(update_file)) store_dataset.canonicalize();
.unwrap(), let mut result_store_dataset: Dataset =
)) result_store.iter().collect::<Result<_, _>>()?;
result_store_dataset.canonicalize();
if store_dataset == result_store_dataset {
Ok(())
} else {
Err(anyhow!(
"Failure on {}.\nDiff:\n{}\nParsed update:\n{}\n",
test,
dataset_diff(&result_store_dataset, &store_dataset),
Update::parse(&read_file_to_string(update_file)?, Some(update_file))
.unwrap(),
))
}
} }
} }
}, }
} }
} }

Loading…
Cancel
Save