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. 30
      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,
graph: &mut Graph,
format: RdfFormat,
base_iri: Option<&str>,
ignore_errors: bool,
) -> 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)?) {
match 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> {
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)
}

@ -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,16 +273,37 @@ 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 {
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
.subject_for_predicate_object(rdf::TYPE, mf::MANIFEST)
.context("no manifest found")?;
}
match self
.graph
.object_for_subject_predicate(manifest, mf::INCLUDE)
@ -313,7 +334,6 @@ impl TestManifest {
}
None => (),
}
}
Ok(Some(()))
}
}

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

Loading…
Cancel
Save