diff options
Diffstat (limited to 'wscript')
-rw-r--r-- | wscript | 88 |
1 files changed, 60 insertions, 28 deletions
@@ -34,6 +34,9 @@ def options(ctx): opt.add_option('--' + name, action='store_true', dest=name.replace('-', '_'), help=desc) + opt.add_option('--dump', type='string', default='', dest='dump', + help='dump debugging output (iter, search, write, all)') + def configure(conf): autowaf.display_header('Serd Configuration') conf.load('compiler_c', cache=True) @@ -64,6 +67,14 @@ def configure(conf): defines = ['_POSIX_C_SOURCE=200809L'], mandatory = False) + dump = Options.options.dump.split(',') + if 'all' in dump or 'iter' in dump: + conf.define('SERD_DEBUG_ITER', 1) + if 'all' in dump or 'search' in dump: + conf.define('SERD_DEBUG_SEARCH', 1) + if 'all' in dump or 'write' in dump: + conf.define('SERD_DEBUG_WRITE', 1) + autowaf.define(conf, 'SERD_VERSION', SERD_VERSION) autowaf.set_lib_env(conf, 'serd', SERD_VERSION) conf.write_config_header('serd_config.h', remove=False) @@ -78,14 +89,22 @@ def configure(conf): lib_source = ['src/base64.c', 'src/byte_source.c', 'src/env.c', + 'src/inserter.c', + 'src/iter.c', + 'src/model.c', 'src/n3.c', 'src/node.c', + 'src/nodes.c', 'src/reader.c', + 'src/statement.c', 'src/string.c', 'src/system.c', 'src/uri.c', 'src/world.c', - 'src/writer.c'] + 'src/writer.c', + 'src/zix/btree.c', + 'src/zix/digest.c', + 'src/zix/hash.c'] def build(bld): # C Headers @@ -144,7 +163,8 @@ def build(bld): # Test programs for prog in [('serdi_static', 'src/serdi.c'), ('serd_test', 'tests/serd_test.c'), - ('read_chunk_test', 'tests/read_chunk_test.c')]: + ('read_chunk_test', 'tests/read_chunk_test.c'), + ('model_test', 'tests/model_test.c')]: bld(features = 'c cprogram', source = prog[1], use = 'libserd_profiled', @@ -275,9 +295,17 @@ def show_diff(from_lines, to_lines, from_filename, to_filename): from_lines, to_lines, fromfile=from_filename, tofile=to_filename): sys.stderr.write(line) -def check_output(out_filename, check_filename, subst_from='', subst_to=''): +def check_output(out_filename, check_filename, subst_from='', subst_to='', sort=False): if not os.access(out_filename, os.F_OK): Logs.pprint('RED', 'FAIL: output %s is missing' % out_filename) + elif sort: + out_lines = sorted(set(io.open(out_filename, encoding='utf-8').readlines())) + check_lines = sorted(set(io.open(check_filename, encoding='utf-8').readlines())) + if out_lines != check_lines: + show_diff(check_lines, out_lines, check_filename, out_filename) + return False + else: + return True elif not file_equals(check_filename, out_filename, subst_from, subst_to): Logs.pprint('RED', 'FAIL: %s != %s' % (os.path.abspath(out_filename), check_filename)) @@ -389,14 +417,17 @@ def test_suite(ctx, base_uri, testdir, report, isyntax, osyntax, options=''): # Check output against test suite check_uri = model[test][mf + 'result'][0] check_path = file_uri_to_path(check_uri) + sort = '-m' in options result = autowaf.run_test( ctx, APPNAME, - lambda: check_output(action + '.out', check_path), + lambda: check_output(action + '.out', check_path, sort=sort), True, name=str(action) + ' check', quiet=True) # Run round-trip tests - test_thru(ctx, uri, action, check_path, - ' '.join(next(thru_options_iter)), isyntax, osyntax, options, quiet=True) + if not sort: + test_thru(ctx, uri, action, check_path, + ' '.join(next(thru_options_iter)), + isyntax, osyntax, options, quiet=True) # Write test report entry if report is not None: @@ -434,7 +465,7 @@ def test(ctx): os.environ['PATH'] = '.' + os.pathsep + os.getenv('PATH') autowaf.pre_test(ctx, APPNAME) - for test in ['serd_test', 'read_chunk_test']: + for test in ['serd_test', 'read_chunk_test', 'model_test']: autowaf.run_test(ctx, APPNAME, test, dirs=['.']) def test_ttl(in_name, expected_name): @@ -493,27 +524,28 @@ def test(ctx): 'serdi_static "file://%s/tests/good/manifest.ttl" > /dev/full' % srcdir, 1, name='write_error') - # Serd-specific test cases - serd_base = 'http://drobilla.net/sw/serd/tests/' - test_suite(ctx, serd_base + 'good/', 'good', None, 'Turtle', 'NTriples') - test_suite(ctx, serd_base + 'bad/', 'bad', None, 'Turtle', 'NTriples') - - # Standard test suites - with open('earl.ttl', 'w') as report: - report.write('@prefix earl: <http://www.w3.org/ns/earl#> .\n' - '@prefix dc: <http://purl.org/dc/elements/1.1/> .\n') - - with open(os.path.join(srcdir, 'serd.ttl')) as serd_ttl: - for line in serd_ttl: - report.write(line) - - w3c_base = 'http://www.w3.org/2013/' - test_suite(ctx, w3c_base + 'NTriplesTests/', - 'NTriplesTests', report, 'NTriples', 'NTriples') - test_suite(ctx, w3c_base + 'NQuadsTests/', - 'NQuadsTests', report, 'NQuads', 'NQuads') - test_suite(ctx, w3c_base + 'TriGTests/', - 'TriGTests', report, 'TriG', 'NQuads', '-a') + for opts in ['', '-m']: + # Serd-specific test cases + serd_base = 'http://drobilla.net/sw/serd/tests/' + test_suite(ctx, serd_base + 'good/', 'good', None, 'Turtle', 'NTriples', opts) + test_suite(ctx, serd_base + 'bad/', 'bad', None, 'Turtle', 'NTriples', opts) + + # Standard test suites + with open('earl.ttl', 'w') as report: + report.write('@prefix earl: <http://www.w3.org/ns/earl#> .\n' + '@prefix dc: <http://purl.org/dc/elements/1.1/> .\n') + + with open(os.path.join(srcdir, 'serd.ttl')) as serd_ttl: + for line in serd_ttl: + report.write(line) + + w3c_base = 'http://www.w3.org/2013/' + test_suite(ctx, w3c_base + 'NTriplesTests/', + 'NTriplesTests', report, 'NTriples', 'NTriples', opts) + test_suite(ctx, w3c_base + 'NQuadsTests/', + 'NQuadsTests', report, 'NQuads', 'NQuads', opts) + test_suite(ctx, w3c_base + 'TriGTests/', + 'TriGTests', report, 'TriG', 'NQuads', '-a' + opts) autowaf.post_test(ctx, APPNAME) if ctx.autowaf_tests[APPNAME]['failed'] > 0: |