From a3fa7ea027b30a2f437d3282a3726ed2bc988770 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 3 Mar 2013 03:51:25 +0000 Subject: Abstract out thru test running. git-svn-id: http://svn.drobilla.net/serd/trunk@426 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- wscript | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'wscript') diff --git a/wscript b/wscript index b4d908ed..a53c62a6 100644 --- a/wscript +++ b/wscript @@ -282,6 +282,31 @@ def earl_assertion(test, passed, asserter): "earl:passed" if passed else "earl:failed", datetime.datetime.now().replace(microsecond=0).isoformat()) +def test_thru(ctx, base, path, flags): + in_filename = os.path.join(ctx.path.abspath(), path) + out_filename = path + '.thru' + check_filename = in_filename.replace('.ttl', '.nt') + + command = ('%s %s -i ntriples -o turtle -p foo "%s" "%s"' + '| %s -i turtle -o ntriples -c foo - "%s" > %s') % ( + 'serdi_static', flags.ljust(5), + in_filename, base, + 'serdi_static', base, out_filename) + + passed = autowaf.run_test(ctx, APPNAME, command, 0, name=out_filename) + if not passed: + return False + + if not os.access(out_filename, os.F_OK): + Logs.pprint('RED', 'FAIL: %s is missing' % out_filename) + elif not file_equals(check_filename, out_filename, '_:docid', '_:genid'): + Logs.pprint('RED', 'FAIL: %s != %s' % (out_filename, check_filename)) + else: + Logs.pprint('GREEN', '** Pass %s == %s' % (out_filename, check_filename)) + return True + + return False + def test_manifest(ctx, srcdir, testdir, report, test_base, parse_base): import rdflib import urlparse @@ -473,27 +498,9 @@ def test(ctx): flags += ' -r http://www.w3.org/' if (num % 7 == 0): flags += ' -e' - out_filename = os.path.join('tests', tdir, test + '.thru') - commands += [ - ('%s %s -i ntriples -o turtle -p foo "%s" "%s"' - '| %s -i turtle -o ntriples -c foo - "%s" > %s') % ( - 'serdi_static', flags.ljust(5), - os.path.join(srcdir, 'tests', tdir, test), test_base(test), - 'serdi_static', test_base(test), out_filename) ] - - autowaf.run_tests(ctx, APPNAME, commands, 0, name='turtle-round-trip') - Logs.pprint('BOLD', '\nVerifying ntriples => turtle => ntriples') - for test in thru_tests: - path = os.path.join('tests', tdir, test) - out_filename = path + '.thru' - if not os.access(out_filename, os.F_OK): - Logs.pprint('RED', 'FAIL: %s output is missing' % test) - elif not file_equals(os.path.join(srcdir, path).replace('.ttl', '.nt'), - path + '.thru', - '_:docid', '_:genid'): - Logs.pprint('RED', 'FAIL: %s is incorrect' % out_filename) - else: - Logs.pprint('GREEN', 'Pass: %s' % test) + + path = os.path.join('tests', tdir, test) + test_thru(ctx, test_base(test), path, flags) try: report = open('earl.ttl', 'w') -- cgit v1.2.1