Runs SPARQL evaluation tests in parallel

pull/10/head
Tpt 5 years ago
parent 3beecdff76
commit 58aa9c2090
  1. 5
      lib/Cargo.toml
  2. 29
      lib/tests/sparql_test_cases.rs

@ -37,5 +37,8 @@ rio_turtle = "0.3"
rio_xml = "0.3" rio_xml = "0.3"
hex = "0.3" hex = "0.3"
[dev-dependencies]
rayon = "1"
[build-dependencies] [build-dependencies]
peg = "0.5" peg = "0.5"

@ -1,5 +1,6 @@
///! Integration tests based on [SPARQL 1.1 Test Cases](https://www.w3.org/2009/sparql/docs/tests/README.html) ///! Integration tests based on [SPARQL 1.1 Test Cases](https://www.w3.org/2009/sparql/docs/tests/README.html)
use failure::format_err; use failure::format_err;
use rayon::prelude::*;
use rudf::model::vocab::rdf; use rudf::model::vocab::rdf;
use rudf::model::vocab::rdfs; use rudf::model::vocab::rdfs;
use rudf::model::*; use rudf::model::*;
@ -123,17 +124,15 @@ fn sparql_w3c_query_evaluation_testsuite() -> Result<()> {
NamedNode::parse("http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#coalesce01").unwrap(), NamedNode::parse("http://www.w3.org/2009/sparql/docs/tests/data-sparql11/functions/manifest#coalesce01").unwrap(),
]; ];
let mut failed = Vec::default(); let tests: Result<Vec<_>> = manifest_10_urls
for test_result in manifest_10_urls
.into_iter() .into_iter()
.chain(manifest_11_urls.into_iter()) .chain(manifest_11_urls.into_iter())
.flat_map(|manifest| TestManifest::new(manifest)) .flat_map(|manifest| TestManifest::new(manifest))
{ .collect();
let test = test_result?; let failed: Vec<_> = tests?.into_par_iter().map(|test| {
if test_blacklist.contains(&test.id) { if test_blacklist.contains(&test.id) {
continue; Ok(())
} } else 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()?, None)?; load_graph_to_repository(&data, &repository.connection()?, None)?;
@ -149,12 +148,12 @@ fn sparql_w3c_query_evaluation_testsuite() -> Result<()> {
.connection()? .connection()?
.prepare_query(&read_file_to_string(&test.query)?, Some(&test.query)) .prepare_query(&read_file_to_string(&test.query)?, Some(&test.query))
{ {
Err(error) => failed.push(format!( Err(error) => Err(format_err!(
"Failure to parse query of {} with error: {}", "Failure to parse query of {} with error: {}",
test, error test, error
)), )),
Ok(query) => match query.exec() { Ok(query) => match query.exec() {
Err(error) => failed.push(format!( Err(error) => Err(format_err!(
"Failure to execute query of {} with error: {}", "Failure to execute query of {} with error: {}",
test, error test, error
)), )),
@ -166,8 +165,10 @@ fn sparql_w3c_query_evaluation_testsuite() -> Result<()> {
.next() .next()
.is_some(); .is_some();
let actual_graph = to_graph(result, with_order)?; let actual_graph = to_graph(result, with_order)?;
if !actual_graph.is_isomorphic(&expected_graph) { if actual_graph.is_isomorphic(&expected_graph) {
failed.push(format!("Failure on {}.\nExpected file:\n{}\nOutput file:\n{}\nParsed query:\n{}\nData:\n{}\n", Ok(())
} else {
Err(format_err!("Failure on {}.\nExpected file:\n{}\nOutput file:\n{}\nParsed query:\n{}\nData:\n{}\n",
test, test,
expected_graph, expected_graph,
actual_graph, actual_graph,
@ -179,9 +180,11 @@ fn sparql_w3c_query_evaluation_testsuite() -> Result<()> {
}, },
} }
} else if test.kind != "NegativeSyntaxTest11" { } else if test.kind != "NegativeSyntaxTest11" {
assert!(false, "Not supported test: {}", test); panic!("Not supported test: {}", test)
} else {
Ok(())
} }
} }).filter_map(|v| v.err()).map(|e| e.to_string()).collect();
assert!( assert!(
failed.is_empty(), failed.is_empty(),
"{} tests failed:\n{}", "{} tests failed:\n{}",

Loading…
Cancel
Save