Received: from eggs.gnu.org ([2001:4830:134:3::10]:59818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKTog-0006KU-VC for qemu-devel@nongnu.org; Mon, 03 Mar 2014 09:26:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WKTob-0001a4-0J for qemu-devel@nongnu.org; Mon, 03 Mar 2014 09:26:02 -0500 Received: from roura.ac.upc.edu ([147.83.33.10]:55870 helo=roura.ac.upc.es) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKToa-0001Zr-Ki for qemu-devel@nongnu.org; Mon, 03 Mar 2014 09:25:56 -0500 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <20140228155309.28087.96600.stgit@fimbulvetr.bsc.es> <20140228155316.28087.30919.stgit@fimbulvetr.bsc.es> <87ob1qgvtj.fsf@blackfin.pond.sub.org> Date: Mon, 03 Mar 2014 15:25:55 +0100 In-Reply-To: <87ob1qgvtj.fsf@blackfin.pond.sub.org> (Markus Armbruster's message of "Sat, 01 Mar 2014 09:35:52 +0100") Message-ID: <87y50rxsss.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 1/3] qapi: Use an explicit input file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org Markus Armbruster writes: > Llu=C3=ADs Vilanova writes: [...] >> diff --git a/scripts/qapi.py b/scripts/qapi.py >> index 9b3de4c..59c2b9b 100644 >> --- a/scripts/qapi.py >> +++ b/scripts/qapi.py >> @@ -12,6 +12,7 @@ >> # See the COPYING.LIB file in the top-level directory. >>=20 >> from ordereddict import OrderedDict >> +import os >> import sys >>=20 >> builtin_types =3D [ >> @@ -37,6 +38,7 @@ builtin_type_qtypes =3D { >>=20 >> class QAPISchemaError(Exception): >> def __init__(self, schema, msg): >> + self.base =3D schema.error_base > Non-obvious identifiers. Took me some reading on to figure out that > this is a directory. Will fix. >> self.fp =3D schema.fp >> self.msg =3D msg >> self.line =3D self.col =3D 1 >> @@ -50,12 +52,17 @@ class QAPISchemaError(Exception): >> self.col +=3D 1 >>=20 >> def __str__(self): >> - return "%s:%s:%s: %s" % (self.fp.name, self.line, self.col, sel= f.msg) >> + name =3D os.path.relpath(self.fp.name, self.base) >> + return "%s:%s:%s: %s" % (name, self.line, self.col, self.msg) > Can you explain what this change does, and why it's wanted? Paths are shown as relative so that the test outputs (stderr) can be verifi= ed with diff. Otherwise the actual message depends on the path from which you'= re running the tests. >>=20 >> class QAPISchema: >>=20 >> - def __init__(self, fp): >> + def __init__(self, fp, error_base=3DNone): >> self.fp =3D fp >> + if error_base is None: >> + self.error_base =3D os.getcwd() >> + else: >> + self.error_base =3D error_base >> self.src =3D fp.read() >> if self.src =3D=3D '' or self.src[-1] !=3D '\n': >> self.src +=3D '\n' >> @@ -158,9 +165,9 @@ class QAPISchema: >> raise QAPISchemaError(self, 'Expected "{", "[" or string') >> return expr >>=20 >> -def parse_schema(fp): >> +def parse_schema(input_path, error_base=3DNone): > The only caller that passes the optional argument is > tests/qapi-schema/test-qapi.py. Is it really necessary? It's part of the previous answer; that's also true for your next comment (w= hich I elided). When running tests, paths are shown as relative. Thanks, Lluis --=20 "And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth