Testsuite: Makes use of mf:assumedTestBase

pull/649/head
Tpt 1 year ago committed by Thomas Tanon
parent 832a4ba27d
commit 517df6d59e
  1. 2
      testsuite/N3
  2. 2
      testsuite/rdf-canon
  3. 2
      testsuite/rdf-tests
  4. 5
      testsuite/src/files.rs
  5. 80
      testsuite/src/manifest.rs
  6. 3
      testsuite/src/vocab.rs

@ -1 +1 @@
Subproject commit 5fa35bf602669a467cfd0ab24cc732fe49f2b927 Subproject commit 73f4e00c15828f030749567f61cea2f5d7d9c59b

@ -1 +1 @@
Subproject commit 9b3efebebe0e5338debfc4d3ddd02f6adf0a852c Subproject commit 0503facfaa0825686afc1f533f487816de54d9b7

@ -1 +1 @@
Subproject commit aaa24e4729a89bdee004bc3042814159eb689a19 Subproject commit a0b910e0f2cff4d3a7e32f15ce0bfbc7db2768fb

@ -34,9 +34,10 @@ pub fn load_to_graph(
url: &str, url: &str,
graph: &mut Graph, graph: &mut Graph,
format: RdfFormat, format: RdfFormat,
base_iri: Option<&str>,
ignore_errors: bool, ignore_errors: bool,
) -> Result<()> { ) -> Result<()> {
let parser = RdfParser::from_format(format).with_base_iri(url)?; let parser = RdfParser::from_format(format).with_base_iri(base_iri.unwrap_or(url))?;
for t in parser.parse_read(read_file(url)?) { for t in parser.parse_read(read_file(url)?) {
match t { match t {
Ok(t) => { Ok(t) => {
@ -54,7 +55,7 @@ pub fn load_to_graph(
pub fn load_graph(url: &str, format: RdfFormat, ignore_errors: bool) -> Result<Graph> { pub fn load_graph(url: &str, format: RdfFormat, ignore_errors: bool) -> Result<Graph> {
let mut graph = Graph::new(); let mut graph = Graph::new();
load_to_graph(url, &mut graph, format, ignore_errors)?; load_to_graph(url, &mut graph, format, None, ignore_errors)?;
Ok(graph) Ok(graph)
} }

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

@ -43,6 +43,9 @@ pub mod mf {
pub const ACTION: NamedNodeRef<'_> = NamedNodeRef::new_unchecked( pub const ACTION: NamedNodeRef<'_> = NamedNodeRef::new_unchecked(
"http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#action", "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#action",
); );
pub const ASSUMED_TEST_BASE: NamedNodeRef<'_> = NamedNodeRef::new_unchecked(
"http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#assumedTestBase",
);
pub const RESULT: NamedNodeRef<'_> = NamedNodeRef::new_unchecked( pub const RESULT: NamedNodeRef<'_> = NamedNodeRef::new_unchecked(
"http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#result", "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#result",
); );

Loading…
Cancel
Save