|
|
|
@ -1,6 +1,6 @@ |
|
|
|
|
use crate::files::{guess_rdf_format, load_to_graph}; |
|
|
|
|
use crate::vocab::*; |
|
|
|
|
use anyhow::{bail, Result}; |
|
|
|
|
use anyhow::{bail, Context, Result}; |
|
|
|
|
use oxigraph::model::vocab::*; |
|
|
|
|
use oxigraph::model::*; |
|
|
|
|
use std::collections::VecDeque; |
|
|
|
@ -273,46 +273,66 @@ impl TestManifest { |
|
|
|
|
return Ok(None); |
|
|
|
|
}; |
|
|
|
|
self.graph.clear(); |
|
|
|
|
load_to_graph(&url, &mut self.graph, guess_rdf_format(&url)?, false)?; |
|
|
|
|
load_to_graph(&url, &mut self.graph, guess_rdf_format(&url)?, None, false)?; |
|
|
|
|
|
|
|
|
|
let manifests = self |
|
|
|
|
.graph |
|
|
|
|
.subjects_for_predicate_object(rdf::TYPE, mf::MANIFEST) |
|
|
|
|
.collect::<Vec<_>>(); |
|
|
|
|
if manifests.len() != 1 { |
|
|
|
|
bail!("The file {url} should contain a single manifest"); |
|
|
|
|
bail!("The file should contain a single manifest"); |
|
|
|
|
} |
|
|
|
|
for manifest in manifests { |
|
|
|
|
match self |
|
|
|
|
let mut manifest = manifests[0]; |
|
|
|
|
if let Some(base_iri) = self |
|
|
|
|
.graph |
|
|
|
|
.object_for_subject_predicate(manifest, mf::ASSUMED_TEST_BASE) |
|
|
|
|
{ |
|
|
|
|
let Term::NamedNode(base_iri) = base_iri.into_owned() else { |
|
|
|
|
bail!("Invalid base IRI: {base_iri}"); |
|
|
|
|
}; |
|
|
|
|
self.graph.clear(); |
|
|
|
|
load_to_graph( |
|
|
|
|
&url, |
|
|
|
|
&mut self.graph, |
|
|
|
|
guess_rdf_format(&url)?, |
|
|
|
|
Some(base_iri.as_str()), |
|
|
|
|
false, |
|
|
|
|
)?; |
|
|
|
|
manifest = self |
|
|
|
|
.graph |
|
|
|
|
.object_for_subject_predicate(manifest, mf::INCLUDE) |
|
|
|
|
{ |
|
|
|
|
Some(TermRef::BlankNode(list)) => { |
|
|
|
|
self.manifests_to_do.extend( |
|
|
|
|
RdfListIterator::iter(&self.graph, list.into()).filter_map(|m| match m { |
|
|
|
|
Term::NamedNode(nm) => Some(nm.into_string()), |
|
|
|
|
_ => None, |
|
|
|
|
}), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
Some(_) => bail!("invalid tests list"), |
|
|
|
|
None => (), |
|
|
|
|
.subject_for_predicate_object(rdf::TYPE, mf::MANIFEST) |
|
|
|
|
.context("no manifest found")?; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
match self |
|
|
|
|
.graph |
|
|
|
|
.object_for_subject_predicate(manifest, mf::INCLUDE) |
|
|
|
|
{ |
|
|
|
|
Some(TermRef::BlankNode(list)) => { |
|
|
|
|
self.manifests_to_do.extend( |
|
|
|
|
RdfListIterator::iter(&self.graph, list.into()).filter_map(|m| match m { |
|
|
|
|
Term::NamedNode(nm) => Some(nm.into_string()), |
|
|
|
|
_ => None, |
|
|
|
|
}), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
Some(_) => bail!("invalid tests list"), |
|
|
|
|
None => (), |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// New tests
|
|
|
|
|
match self |
|
|
|
|
.graph |
|
|
|
|
.object_for_subject_predicate(manifest, mf::ENTRIES) |
|
|
|
|
{ |
|
|
|
|
Some(TermRef::BlankNode(list)) => { |
|
|
|
|
self.tests_to_do |
|
|
|
|
.extend(RdfListIterator::iter(&self.graph, list.into())); |
|
|
|
|
} |
|
|
|
|
Some(term) => { |
|
|
|
|
bail!("Invalid tests list. Got term {term}"); |
|
|
|
|
} |
|
|
|
|
None => (), |
|
|
|
|
// New tests
|
|
|
|
|
match self |
|
|
|
|
.graph |
|
|
|
|
.object_for_subject_predicate(manifest, mf::ENTRIES) |
|
|
|
|
{ |
|
|
|
|
Some(TermRef::BlankNode(list)) => { |
|
|
|
|
self.tests_to_do |
|
|
|
|
.extend(RdfListIterator::iter(&self.graph, list.into())); |
|
|
|
|
} |
|
|
|
|
Some(term) => { |
|
|
|
|
bail!("Invalid tests list. Got term {term}"); |
|
|
|
|
} |
|
|
|
|
None => (), |
|
|
|
|
} |
|
|
|
|
Ok(Some(())) |
|
|
|
|
} |
|
|
|
|