diff options
author | David Robillard <d@drobilla.net> | 2018-11-25 16:12:23 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-04-13 19:48:23 +0200 |
commit | 3b1252125ca66387f904ce107fb4c6130d5c582d (patch) | |
tree | 2407cdb6f3c372286895e767c58153f6f02bbe5b | |
parent | e320bb53e58314fb2f04d514fc68202efcb52f3e (diff) | |
download | serd-3b1252125ca66387f904ce107fb4c6130d5c582d.tar.gz serd-3b1252125ca66387f904ce107fb4c6130d5c582d.tar.bz2 serd-3b1252125ca66387f904ce107fb4c6130d5c582d.zip |
Add separate test suite for lax syntax tests
-rw-r--r-- | src/n3.c | 4 | ||||
-rw-r--r-- | tests/good/manifest.ttl | 7 | ||||
-rw-r--r-- | tests/lax/manifest.ttl | 17 | ||||
-rw-r--r-- | tests/lax/test-bad-utf8.nt (renamed from tests/good/test-bad-utf8.nt) | 0 | ||||
-rw-r--r-- | tests/lax/test-bad-utf8.ttl (renamed from tests/good/test-bad-utf8.ttl) | 0 | ||||
-rw-r--r-- | wscript | 17 |
6 files changed, 30 insertions, 15 deletions
@@ -303,7 +303,7 @@ static SerdStatus read_STRING_LITERAL_LONG(SerdReader* reader, SerdNode* dest, uint8_t q) { SerdStatus st = SERD_SUCCESS; - while (!reader->status) { + while (!reader->status && !(st && reader->strict)) { const uint8_t c = peek_byte(reader); if (c == '\\') { eat_byte_safe(reader, c); @@ -341,7 +341,7 @@ static SerdStatus read_STRING_LITERAL(SerdReader* reader, SerdNode* dest, uint8_t q) { SerdStatus st = SERD_SUCCESS; - while (!reader->status) { + while (!reader->status && !(st && reader->strict)) { const uint8_t c = peek_byte(reader); uint32_t code = 0; switch (c) { diff --git a/tests/good/manifest.ttl b/tests/good/manifest.ttl index dd83a7e5..9dccde7b 100644 --- a/tests/good/manifest.ttl +++ b/tests/good/manifest.ttl @@ -18,7 +18,6 @@ <#test-30> <#test-a-without-whitespace> <#test-backspace> - <#test-bad-utf8> <#test-base-query> <#test-blank-cont> <#test-blank-in-list> @@ -109,12 +108,6 @@ mf:action <test-backspace.ttl> ; mf:result <test-backspace.nt> . -<#test-bad-utf8> - rdf:type rdft:TestTurtleEval ; - mf:name "test-bad-utf8" ; - mf:action <test-bad-utf8.ttl> ; - mf:result <test-bad-utf8.nt> . - <#test-base-query> rdf:type rdft:TestTurtleEval ; mf:name "test-base-query" ; diff --git a/tests/lax/manifest.ttl b/tests/lax/manifest.ttl new file mode 100644 index 00000000..4de689ad --- /dev/null +++ b/tests/lax/manifest.ttl @@ -0,0 +1,17 @@ +@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#> . + +<> + rdf:type mf:Manifest ; + rdfs:comment "Serd lax syntax test cases" ; + mf:entries ( + <#test-bad-utf8> + ) . + +<#test-bad-utf8> + rdf:type rdft:TestTurtleNegativeSyntax ; + mf:name "test-bad-utf8" ; + mf:action <test-bad-utf8.ttl> ; + mf:result <test-bad-utf8.nt> . diff --git a/tests/good/test-bad-utf8.nt b/tests/lax/test-bad-utf8.nt index 6d73993d..6d73993d 100644 --- a/tests/good/test-bad-utf8.nt +++ b/tests/lax/test-bad-utf8.nt diff --git a/tests/good/test-bad-utf8.ttl b/tests/lax/test-bad-utf8.ttl index 2c105f5b..2c105f5b 100644 --- a/tests/good/test-bad-utf8.ttl +++ b/tests/lax/test-bad-utf8.ttl @@ -445,7 +445,8 @@ def test_suite(ctx, base_uri, testdir, report, isyntax, options=[]): expected=expected_return, name=action) - if result and ((mf + 'result') in model[test]): + if (result and expected_return == 0 and + ((mf + 'result') in model[test])): # Check output against test suite check_uri = model[test][mf + 'result'][0] check_path = ctx.src_path(file_uri_to_path(check_uri)) @@ -462,9 +463,10 @@ def test_suite(ctx, base_uri, testdir, report, isyntax, options=[]): report.write(earl_assertion(test, result, asserter)) if expected_return != 0: - # Run lax parsing test for negative test (may still fail) - check([command[0]] + ['-l'] + command[1:], - expected=None, name=action + ' lax') + if '-l' not in options: + # Run lax parsing test for negative test (may still fail) + check([command[0]] + ['-l'] + command[1:], + expected=None, name=action + ' lax') else: # Run model test for positive test (must succeed) model_out_path = action + '.model.out' @@ -478,7 +480,7 @@ def test_suite(ctx, base_uri, testdir, report, isyntax, options=[]): ns_rdftest = 'http://www.w3.org/ns/rdftest#' for test_class, instances in instances.items(): if test_class.startswith(ns_rdftest): - expected = 1 if 'Negative' in test_class else 0 + expected = 1 if '-l' not in options and 'Negative' in test_class else 0 run_tests(test_class, instances, expected) def validation_test_suite(tst, base_uri, testdir, isyntax, osyntax, options=''): @@ -506,7 +508,8 @@ def test(tst): import tempfile # Create test output directories - for i in ['bad', 'good', 'TurtleTests', 'NTriplesTests', 'NQuadsTests', 'TriGTests']: + for i in ['bad', 'good', 'lax', + 'TurtleTests', 'NTriplesTests', 'NQuadsTests', 'TriGTests']: try: test_dir = os.path.join('tests', i) os.makedirs(test_dir) @@ -588,6 +591,8 @@ def test(tst): serd_base = 'http://drobilla.net/sw/serd/tests/' test_suite(tst, serd_base + 'good/', 'good', None, 'Turtle') test_suite(tst, serd_base + 'bad/', 'bad', None, 'Turtle') + test_suite(tst, serd_base + 'lax/', 'lax', None, 'Turtle', ['-l']) + test_suite(tst, serd_base + 'lax/', 'lax', None, 'Turtle') # Serd validation test suite with open('validation_earl.ttl', 'w') as report: |