Received: from eggs.gnu.org ([2001:4830:134:3::10]:44286) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYqZW-000247-D4 for qemu-devel@nongnu.org; Mon, 07 Sep 2015 03:10:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYqZS-0008UN-AO for qemu-devel@nongnu.org; Mon, 07 Sep 2015 03:10:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45365) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYqZS-0008UI-5I for qemu-devel@nongnu.org; Mon, 07 Sep 2015 03:10:30 -0400 From: Markus Armbruster References: <1441290623-13631-1-git-send-email-armbru@redhat.com> <1441290623-13631-6-git-send-email-armbru@redhat.com> <55EAECBD.6070807@redhat.com> Date: Mon, 07 Sep 2015 09:10:27 +0200 In-Reply-To: <55EAECBD.6070807@redhat.com> (Eric Blake's message of "Sat, 5 Sep 2015 07:23:09 -0600") Message-ID: <87egiavh5o.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH RFC v4 05/32] tests/qapi-schema: Convert test harness to QAPISchemaVisitor List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org, mdroth@linux.vnet.ibm.com Eric Blake writes: > On 09/03/2015 08:29 AM, Markus Armbruster wrote: >> The old code prints the result of parsing (list of expression >> dictionaries), and partial results of semantic analysis (list of enum >> dictionaries, list of struct dictionaries). >>=20 >> The new code prints a trace of a schema visit, i.e. what the back-ends >> are going to use. Built-in and array types are omitted, because >> they're boring. >>=20 >> Signed-off-by: Markus Armbruster >> Reviewed-by: Eric Blake >> --- > >> +++ b/tests/qapi-schema/test-qapi.py >> @@ -15,11 +15,35 @@ from pprint import pprint >> import os >> import sys >>=20=20 >> -try: >> - exprs =3D QAPISchema(sys.argv[1]).get_exprs() >> -except SystemExit: >> - raise > > Don't we still need a try wrapped around... > >> +schema =3D QAPISchema(sys.argv[1]) >> +schema.visit(QAPISchemaTestVisitor()) > > ...this, to guarantee non-zero exit status if an exception caused by > refactoring breaks the pretty-printing? (It happened to me when I tried > to rename to _tag_name, and my only indication that something was wrong > was that qapi-tests/qapi-schema-test.out was truncated due to this > script aborting early after trying to access the old spelling tag_name). The new version doesn't catch exceptions, and uncaught exceptions terminate the program unsucsessfully. Anything wrong with that? The old version hides exceptions other than SystemExit. Why? I believe it's mostly historical accident. Accidents mostly cause by me. I created the file in commit 9862657. I wrapped parse_schema() in a misguided attempt to keep the .err files concise: try: exprs =3D parse_schema(sys.stdin) except: print >>sys.stderr, "Crashed:", sys.exc_info()[0] exit(1) This misreported errors as crashes, so I amended it in commit 2caba36: try: exprs =3D parse_schema(sys.stdin) except SystemExit: raise except: print >>sys.stderr, "Crashed:", sys.exc_info()[0] exit(1) Llu=C3=ADs then ripped out the original misguided blanket exception catchin= g, but left in the amend (commit 98c1200): try: exprs =3D parse_schema(sys.stdin) except SystemExit: raise