Testsuite: do not run rejected tests

pull/370/head
Tpt 2 years ago committed by Thomas Tanon
parent 6cabf6da15
commit 323ad73831
  1. 344
      testsuite/src/manifest.rs
  2. 9
      testsuite/src/vocab.rs

@ -85,185 +85,193 @@ impl Iterator for TestManifest {
impl TestManifest { impl TestManifest {
fn next_test(&mut self) -> Result<Option<Test>> { fn next_test(&mut self) -> Result<Option<Test>> {
let test_node = if let Some(test_node) = self.tests_to_do.pop_front() { loop {
test_node let test_node = if let Some(test_node) = self.tests_to_do.pop_front() {
} else { test_node
return Ok(None); } else {
}; return Ok(None);
let test_node = if let Term::NamedNode(test_node) = test_node { };
test_node let test_node = if let Term::NamedNode(test_node) = test_node {
} else { test_node
bail!("Invalid test identifier. Got {test_node}"); } else {
}; bail!("Invalid test identifier. Got {test_node}");
};
let name = if let Some(TermRef::Literal(c)) = self if self
.graph .graph
.object_for_subject_predicate(&test_node, mf::NAME) .contains(TripleRef::new(&test_node, rdft::APPROVAL, rdft::REJECTED))
{ {
Some(c.value().to_string()) continue; // We do not run rejected tests
} else { }
None let name = if let Some(TermRef::Literal(c)) = self
}; .graph
let kind = if let Some(TermRef::NamedNode(c)) = self .object_for_subject_predicate(&test_node, mf::NAME)
.graph {
.object_for_subject_predicate(&test_node, rdf::TYPE) Some(c.value().to_string())
{ } else {
c.into_owned() None
} else { };
bail!( let kind = if let Some(TermRef::NamedNode(c)) = self
"The test {test_node} named {} has no rdf:type", .graph
name.as_deref().unwrap_or("") .object_for_subject_predicate(&test_node, rdf::TYPE)
); {
}; c.into_owned()
let comment = if let Some(TermRef::Literal(c)) = self } else {
.graph bail!(
.object_for_subject_predicate(&test_node, rdfs::COMMENT) "The test {test_node} named {} has no rdf:type",
{ name.as_deref().unwrap_or("")
Some(c.value().to_string()) );
} else { };
None let comment = if let Some(TermRef::Literal(c)) = self
}; .graph
let (action, query, update, data, graph_data, service_data) = match self .object_for_subject_predicate(&test_node, rdfs::COMMENT)
.graph {
.object_for_subject_predicate(&test_node, mf::ACTION) Some(c.value().to_string())
{ } else {
Some(TermRef::NamedNode(n)) => ( None
Some(n.as_str().to_owned()), };
None, let (action, query, update, data, graph_data, service_data) = match self
None, .graph
None, .object_for_subject_predicate(&test_node, mf::ACTION)
vec![], {
vec![], Some(TermRef::NamedNode(n)) => (
), Some(n.as_str().to_owned()),
Some(TermRef::BlankNode(n)) => { None,
let query = match self.graph.object_for_subject_predicate(n, qt::QUERY) { None,
Some(TermRef::NamedNode(q)) => Some(q.as_str().to_owned()), None,
_ => None, vec![],
}; vec![],
let update = match self.graph.object_for_subject_predicate(n, ut::REQUEST) { ),
Some(TermRef::NamedNode(q)) => Some(q.as_str().to_owned()), Some(TermRef::BlankNode(n)) => {
_ => None, let query = match self.graph.object_for_subject_predicate(n, qt::QUERY) {
}; Some(TermRef::NamedNode(q)) => Some(q.as_str().to_owned()),
let data = match self _ => None,
.graph };
.object_for_subject_predicate(n, qt::DATA) let update = match self.graph.object_for_subject_predicate(n, ut::REQUEST) {
.or_else(|| self.graph.object_for_subject_predicate(n, ut::DATA)) Some(TermRef::NamedNode(q)) => Some(q.as_str().to_owned()),
{ _ => None,
Some(TermRef::NamedNode(q)) => Some(q.as_str().to_owned()), };
_ => None, let data = match self
}; .graph
let graph_data = self .object_for_subject_predicate(n, qt::DATA)
.graph .or_else(|| self.graph.object_for_subject_predicate(n, ut::DATA))
.objects_for_subject_predicate(n, qt::GRAPH_DATA) {
.chain(self.graph.objects_for_subject_predicate(n, ut::GRAPH_DATA)) Some(TermRef::NamedNode(q)) => Some(q.as_str().to_owned()),
.filter_map(|g| match g { _ => None,
TermRef::NamedNode(q) => Some((q.into_owned(), q.as_str().to_owned())), };
TermRef::BlankNode(node) => { let graph_data = self
if let Some(TermRef::NamedNode(graph)) = .graph
self.graph.object_for_subject_predicate(node, ut::GRAPH) .objects_for_subject_predicate(n, qt::GRAPH_DATA)
{ .chain(self.graph.objects_for_subject_predicate(n, ut::GRAPH_DATA))
if let Some(TermRef::Literal(name)) = .filter_map(|g| match g {
self.graph.object_for_subject_predicate(node, rdfs::LABEL) TermRef::NamedNode(q) => Some((q.into_owned(), q.as_str().to_owned())),
TermRef::BlankNode(node) => {
if let Some(TermRef::NamedNode(graph)) =
self.graph.object_for_subject_predicate(node, ut::GRAPH)
{ {
Some(( if let Some(TermRef::Literal(name)) =
NamedNode::new(name.value()).unwrap(), self.graph.object_for_subject_predicate(node, rdfs::LABEL)
graph.as_str().to_owned(), {
)) Some((
NamedNode::new(name.value()).unwrap(),
graph.as_str().to_owned(),
))
} else {
Some((graph.into_owned(), graph.as_str().to_owned()))
}
} else { } else {
Some((graph.into_owned(), graph.as_str().to_owned())) None
} }
}
_ => None,
})
.collect();
let service_data = self
.graph
.objects_for_subject_predicate(n, qt::SERVICE_DATA)
.filter_map(|g| match g {
TermRef::NamedNode(g) => Some(g.into()),
TermRef::BlankNode(g) => Some(g.into()),
_ => None,
})
.filter_map(|g: SubjectRef<'_>| {
if let (
Some(TermRef::NamedNode(endpoint)),
Some(TermRef::NamedNode(data)),
) = (
self.graph.object_for_subject_predicate(g, qt::ENDPOINT),
self.graph.object_for_subject_predicate(g, qt::DATA),
) {
Some((endpoint.as_str().to_owned(), data.as_str().to_owned()))
} else { } else {
None None
} }
} })
_ => None, .collect();
}) (None, query, update, data, graph_data, service_data)
.collect(); }
let service_data = self Some(_) => bail!("invalid action"),
.graph None => {
.objects_for_subject_predicate(n, qt::SERVICE_DATA) bail!("action not found for test {test_node}");
.filter_map(|g| match g { }
TermRef::NamedNode(g) => Some(g.into()), };
TermRef::BlankNode(g) => Some(g.into()), let (result, result_graph_data) = match self
_ => None, .graph
}) .object_for_subject_predicate(&test_node, mf::RESULT)
.filter_map(|g: SubjectRef<'_>| { {
if let ( Some(TermRef::NamedNode(n)) => (Some(n.as_str().to_owned()), Vec::new()),
Some(TermRef::NamedNode(endpoint)), Some(TermRef::BlankNode(n)) => (
Some(TermRef::NamedNode(data)), if let Some(TermRef::NamedNode(result)) =
) = ( self.graph.object_for_subject_predicate(n, ut::DATA)
self.graph.object_for_subject_predicate(g, qt::ENDPOINT), {
self.graph.object_for_subject_predicate(g, qt::DATA), Some(result.as_str().to_owned())
) { } else {
Some((endpoint.as_str().to_owned(), data.as_str().to_owned())) None
} else { },
None self.graph
} .objects_for_subject_predicate(n, ut::GRAPH_DATA)
}) .filter_map(|g| match g {
.collect(); TermRef::NamedNode(q) => Some((q.into_owned(), q.as_str().to_owned())),
(None, query, update, data, graph_data, service_data) TermRef::BlankNode(node) => {
} if let Some(TermRef::NamedNode(graph)) =
Some(_) => bail!("invalid action"), self.graph.object_for_subject_predicate(node, ut::GRAPH)
None => {
bail!("action not found for test {test_node}");
}
};
let (result, result_graph_data) = match self
.graph
.object_for_subject_predicate(&test_node, mf::RESULT)
{
Some(TermRef::NamedNode(n)) => (Some(n.as_str().to_owned()), Vec::new()),
Some(TermRef::BlankNode(n)) => (
if let Some(TermRef::NamedNode(result)) =
self.graph.object_for_subject_predicate(n, ut::DATA)
{
Some(result.as_str().to_owned())
} else {
None
},
self.graph
.objects_for_subject_predicate(n, ut::GRAPH_DATA)
.filter_map(|g| match g {
TermRef::NamedNode(q) => Some((q.into_owned(), q.as_str().to_owned())),
TermRef::BlankNode(node) => {
if let Some(TermRef::NamedNode(graph)) =
self.graph.object_for_subject_predicate(node, ut::GRAPH)
{
if let Some(TermRef::Literal(name)) =
self.graph.object_for_subject_predicate(node, rdfs::LABEL)
{ {
Some(( if let Some(TermRef::Literal(name)) =
NamedNode::new(name.value()).unwrap(), self.graph.object_for_subject_predicate(node, rdfs::LABEL)
graph.as_str().to_owned(), {
)) Some((
NamedNode::new(name.value()).unwrap(),
graph.as_str().to_owned(),
))
} else {
Some((graph.into_owned(), graph.as_str().to_owned()))
}
} else { } else {
Some((graph.into_owned(), graph.as_str().to_owned())) None
} }
} else {
None
} }
} _ => None,
_ => None, })
}) .collect(),
.collect(), ),
), Some(_) => bail!("invalid result"),
Some(_) => bail!("invalid result"), None => (None, Vec::new()),
None => (None, Vec::new()), };
}; return Ok(Some(Test {
Ok(Some(Test { id: test_node,
id: test_node, kind,
kind, name,
name, comment,
comment, action,
action, query,
query, update,
update, data,
data, graph_data,
graph_data, service_data,
service_data, result,
result, result_graph_data,
result_graph_data, }));
})) }
} }
fn load_next_manifest(&mut self) -> Result<Option<()>> { fn load_next_manifest(&mut self) -> Result<Option<()>> {

@ -48,6 +48,15 @@ pub mod mf {
); );
} }
pub mod rdft {
use oxigraph::model::NamedNodeRef;
pub const APPROVAL: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/ns/rdftest#approval");
pub const REJECTED: NamedNodeRef<'_> =
NamedNodeRef::new_unchecked("http://www.w3.org/ns/rdftest#Rejected");
}
pub mod qt { pub mod qt {
use oxigraph::model::NamedNodeRef; use oxigraph::model::NamedNodeRef;

Loading…
Cancel
Save