aboutsummaryrefslogtreecommitdiffstats
path: root/test/filter
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-10-21 15:38:10 -0400
committerDavid Robillard <d@drobilla.net>2022-01-28 21:57:07 -0500
commitb404312686874e539b617d1f27ccbaa5a82936af (patch)
treec2fdb2cc046e6da53071629cd1750dcc327e6cd9 /test/filter
parentd4aec28ba8ad24d5aef3ee12beeb1b805148eab1 (diff)
downloadserd-b404312686874e539b617d1f27ccbaa5a82936af.tar.gz
serd-b404312686874e539b617d1f27ccbaa5a82936af.tar.bz2
serd-b404312686874e539b617d1f27ccbaa5a82936af.zip
Replace serdi with more fine-grained tools
Especially with the new functionality, the complexity of the command-line interface alone was really becoming unmanageable. The serdi implementation also had the highest cyclomatic complexity of the entire codebase by a huge margin. So, take a page from the Unix philosophy and split serdi into several more finely-honed tools that can be freely composed. Though there is still unfortunately quite a bit of option overlap between them due to the common details of reading RDF, I think the resulting tools are a lot easier to understand, both from a user and a developer perspective.
Diffstat (limited to 'test/filter')
-rw-r--r--test/filter/input.ttl9
-rw-r--r--test/filter/manifest.ttl48
-rw-r--r--test/filter/meson.build15
-rw-r--r--test/filter/o1.pattern.nt1
-rw-r--r--test/filter/o1.result.nt2
-rw-r--r--test/filter/p1.pattern.nt1
-rw-r--r--test/filter/p1.result.nt2
-rw-r--r--test/filter/s1.pattern.nt1
-rw-r--r--test/filter/s1.result.nt2
9 files changed, 81 insertions, 0 deletions
diff --git a/test/filter/input.ttl b/test/filter/input.ttl
new file mode 100644
index 00000000..59aa67f7
--- /dev/null
+++ b/test/filter/input.ttl
@@ -0,0 +1,9 @@
+@prefix eg: <http://example.org/> .
+
+eg:s1
+ eg:p1 eg:o1 ;
+ eg:p2 eg:o2 .
+
+eg:s2
+ eg:p1 eg:o1 ;
+ eg:p2 eg:o2 .
diff --git a/test/filter/manifest.ttl b/test/filter/manifest.ttl
new file mode 100644
index 00000000..59ce3f55
--- /dev/null
+++ b/test/filter/manifest.ttl
@@ -0,0 +1,48 @@
+@prefix checks: <http://drobilla.net/ns/serd/checks#> .
+@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix rdft: <http://www.w3.org/ns/rdftest#> .
+@prefix serd: <http://drobilla.net/ns/serd#> .
+
+rdft:Test
+ rdfs:subClassOf mf:ManifestEntry .
+
+serd:patternFile
+ a rdf:Property ;
+ rdfs:label "pattern file" .
+
+serd:TestFilterPositive
+ a rdfs:Class ;
+ rdfs:label "Positive Filtering" ;
+ rdfs:subClassOf rdft:Test .
+
+<>
+ a mf:Manifest ;
+ rdfs:comment "Serd filter test cases" ;
+ mf:entries (
+ <#s1>
+ <#p1>
+ <#o1>
+ ) .
+
+<#s1>
+ a serd:TestFilterPositive ;
+ serd:patternFile <s1.pattern.nt> ;
+ mf:name "s1" ;
+ mf:action <input.ttl> ;
+ mf:result <s1.result.nt> .
+
+<#p1>
+ a serd:TestFilterPositive ;
+ serd:patternFile <p1.pattern.nt> ;
+ mf:name "p1" ;
+ mf:action <input.ttl> ;
+ mf:result <p1.result.nt> .
+
+<#o1>
+ a serd:TestFilterPositive ;
+ serd:patternFile <o1.pattern.nt> ;
+ mf:name "o1" ;
+ mf:action <input.ttl> ;
+ mf:result <o1.result.nt> .
diff --git a/test/filter/meson.build b/test/filter/meson.build
new file mode 100644
index 00000000..fd2b1bca
--- /dev/null
+++ b/test/filter/meson.build
@@ -0,0 +1,15 @@
+base_uri = 'http://drobilla.net/sw/serd/test/filter/'
+
+test('filter',
+ run_filter_suite,
+ args: common_script_options + [
+ '--pipe',
+ serd_pipe,
+ '--filter',
+ serd_filter,
+ files('manifest.ttl'),
+ base_uri
+ ],
+ env: test_env,
+ suite: ['suite', 'extra'],
+ timeout: 240)
diff --git a/test/filter/o1.pattern.nt b/test/filter/o1.pattern.nt
new file mode 100644
index 00000000..41932fd7
--- /dev/null
+++ b/test/filter/o1.pattern.nt
@@ -0,0 +1 @@
+?s ?p <http://example.org/o1> .
diff --git a/test/filter/o1.result.nt b/test/filter/o1.result.nt
new file mode 100644
index 00000000..e7b1e759
--- /dev/null
+++ b/test/filter/o1.result.nt
@@ -0,0 +1,2 @@
+<http://example.org/s1> <http://example.org/p1> <http://example.org/o1> .
+<http://example.org/s2> <http://example.org/p1> <http://example.org/o1> .
diff --git a/test/filter/p1.pattern.nt b/test/filter/p1.pattern.nt
new file mode 100644
index 00000000..fca20e94
--- /dev/null
+++ b/test/filter/p1.pattern.nt
@@ -0,0 +1 @@
+?s <http://example.org/p1> ?o .
diff --git a/test/filter/p1.result.nt b/test/filter/p1.result.nt
new file mode 100644
index 00000000..e7b1e759
--- /dev/null
+++ b/test/filter/p1.result.nt
@@ -0,0 +1,2 @@
+<http://example.org/s1> <http://example.org/p1> <http://example.org/o1> .
+<http://example.org/s2> <http://example.org/p1> <http://example.org/o1> .
diff --git a/test/filter/s1.pattern.nt b/test/filter/s1.pattern.nt
new file mode 100644
index 00000000..f5b87db1
--- /dev/null
+++ b/test/filter/s1.pattern.nt
@@ -0,0 +1 @@
+<http://example.org/s1> ?p ?o .
diff --git a/test/filter/s1.result.nt b/test/filter/s1.result.nt
new file mode 100644
index 00000000..023faf42
--- /dev/null
+++ b/test/filter/s1.result.nt
@@ -0,0 +1,2 @@
+<http://example.org/s1> <http://example.org/p1> <http://example.org/o1> .
+<http://example.org/s1> <http://example.org/p2> <http://example.org/o2> .