diff --git a/lib/src/model/graph.rs b/lib/src/model/graph.rs index 557238d1..c7c2241b 100644 --- a/lib/src/model/graph.rs +++ b/lib/src/model/graph.rs @@ -174,6 +174,11 @@ impl Graph { self.graph_mut().remove(triple) } + /// Clears the graph + pub fn clear(&mut self) { + self.dataset.clear() + } + /// Loads a file into the graph. /// /// Usage example: diff --git a/testsuite/src/manifest.rs b/testsuite/src/manifest.rs index 7fcf3c02..beac945b 100644 --- a/testsuite/src/manifest.rs +++ b/testsuite/src/manifest.rs @@ -246,43 +246,50 @@ impl Iterator for TestManifest { None => { match self.manifests_to_do.pop() { Some(url) => { - let manifest = SubjectRef::from(NamedNodeRef::new(url.as_str()).unwrap()); + self.graph.clear(); if let Err(error) = load_to_graph(&url, &mut self.graph) { return Some(Err(error)); } - // New manifests - match self + for manifest in self .graph - .object_for_subject_predicate(manifest, mf::INCLUDE) + .subjects_for_predicate_object(rdf::TYPE, mf::MANIFEST) { - 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, - }, - ), - ); + 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(_) => return Some(Err(anyhow!("invalid tests list"))), + None => (), } - Some(_) => return Some(Err(anyhow!("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) => { - return Some(Err(anyhow!("Invalid tests list. Got term {}", term))); + // 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) => { + return Some(Err(anyhow!( + "Invalid tests list. Got term {}", + term + ))); + } + None => (), } - None => (), } } None => return None, diff --git a/testsuite/src/vocab.rs b/testsuite/src/vocab.rs index b9e9b46c..33ed5283 100644 --- a/testsuite/src/vocab.rs +++ b/testsuite/src/vocab.rs @@ -34,6 +34,9 @@ pub mod mf { pub const ENTRIES: NamedNodeRef<'_> = NamedNodeRef::new_unchecked( "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#entries", ); + pub const MANIFEST: NamedNodeRef<'_> = NamedNodeRef::new_unchecked( + "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#Manifest", + ); pub const NAME: NamedNodeRef<'_> = NamedNodeRef::new_unchecked( "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#name", );