aboutsummaryrefslogtreecommitdiffstats
path: root/wscript
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-10-14 22:18:17 +0200
committerDavid Robillard <d@drobilla.net>2020-10-27 13:13:58 +0100
commit2901a3669de67025f4daa47e5c452a4ffbec1476 (patch)
tree826da112a6338ff6f53edc78fb9e978f662ce7ee /wscript
parent9afb76e19e67951f6e6273acbbd35ceafb376e45 (diff)
downloadserd-2901a3669de67025f4daa47e5c452a4ffbec1476.tar.gz
serd-2901a3669de67025f4daa47e5c452a4ffbec1476.tar.bz2
serd-2901a3669de67025f4daa47e5c452a4ffbec1476.zip
Add validation to command line interface
Diffstat (limited to 'wscript')
-rw-r--r--wscript42
1 files changed, 42 insertions, 0 deletions
diff --git a/wscript b/wscript
index 31d3f36e..9a81651a 100644
--- a/wscript
+++ b/wscript
@@ -258,6 +258,7 @@ def build(bld):
bld(features = 'c cprogram',
source = prog[1],
use = 'libserd_profiled',
+ uselib = 'PCRE',
target = prog[0],
defines = defines,
**test_args)
@@ -621,6 +622,39 @@ def test_suite(ctx,
run_tests(test_class, instances, expected)
+def validation_test_suite(tst,
+ base_uri,
+ testdir,
+ isyntax,
+ osyntax,
+ options=''):
+ srcdir = tst.path.abspath()
+ schemas = glob.glob(os.path.join(srcdir, 'schemas', '*.ttl'))
+
+ ns_serd = 'http://drobilla.net/ns/serd#'
+ mf = 'http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#'
+ mf_path = os.path.join(srcdir, 'tests', testdir, 'manifest.ttl')
+
+ model, instances = _load_rdf(mf_path)
+ for test_class, instances in instances.items():
+ if not test_class.startswith(ns_serd):
+ continue
+
+ tests_name = 'validate.%s' % test_class[test_class.find('#') + 1:]
+ with tst.group(tests_name) as check:
+ expected = 1 if 'Negative' in test_class else 0
+ for test in sorted(instances):
+ action_node = model[test][mf + 'action'][0]
+ name = os.path.basename(action_node)
+ action = os.path.join('tests', 'validate', name)
+ rel_action = os.path.join(os.path.relpath(srcdir), action)
+ command = (['./serdi_static', '-V', '-o', 'empty'] +
+ schemas + [rel_action])
+
+ if tst.env.HAVE_PCRE or name != 'bad-literal-pattern.ttl':
+ check(command, expected=expected, name=action)
+
+
def test(tst):
import tempfile
@@ -752,6 +786,14 @@ def test(tst):
test_suite(tst, serd_base + 'terse/', 'terse', None, 'Turtle', ['-t'],
output_syntax='Turtle')
+ # Serd validation test suite
+ with open('validation_earl.ttl', 'w') as report:
+ serd_base = 'http://drobilla.net/sw/serd/tests/'
+ report.write('@prefix earl: <http://www.w3.org/ns/earl#> .\n'
+ '@prefix dc: <http://purl.org/dc/elements/1.1/> .\n')
+ validation_test_suite(tst, serd_base + 'validate/', 'validate',
+ None, 'Turtle', 'NTriples')
+
# Standard test suites
with open('earl.ttl', 'w') as report:
report.write('@prefix earl: <http://www.w3.org/ns/earl#> .\n'