Received: from eggs.gnu.org ([2001:4830:134:3::10]:57071) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WL0AH-0004Wy-TB for qemu-devel@nongnu.org; Tue, 04 Mar 2014 19:58:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WL0AB-0005w2-U6 for qemu-devel@nongnu.org; Tue, 04 Mar 2014 19:58:29 -0500 Received: from roura.ac.upc.es ([147.83.33.10]:52431) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WL0AB-0005vo-IP for qemu-devel@nongnu.org; Tue, 04 Mar 2014 19:58:23 -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> <87y50rxsss.fsf@fimbulvetr.bsc.es> <87vbvvwaog.fsf@blackfin.pond.sub.org> <87zjl7w74z.fsf@fimbulvetr.bsc.es> <87txbeksrs.fsf@blackfin.pond.sub.org> Date: Wed, 05 Mar 2014 01:58:19 +0100 In-Reply-To: <87txbeksrs.fsf@blackfin.pond.sub.org> (Markus Armbruster's message of "Tue, 04 Mar 2014 14:17:11 +0100") Message-ID: <87wqg9tqac.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: >> Markus Armbruster writes: >> [...] >>>>>> 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, >>>>>> self.msg) >>>>>> + name =3D os.path.relpath(self.fp.name, self.base) >>>>>> + return "%s:%s:%s: %s" % (name, self.line, self.col, self.ms= g) >>>>=20 >>>>> Can you explain what this change does, and why it's wanted? >>>>=20 >>>> Paths are shown as relative so that the test outputs (stderr) can be v= erified >>>> with diff. Otherwise the actual message depends on the path from which= you're >>>> running the tests. >>=20 >>> Hmm. This is the applicable make rule: >>=20 >>> $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PAT= H)/%.json >>> $(call quiet-command, PYTHONPATH=3D$(SRC_PATH)/scripts $(PYTHON) >>> $(SRC_PATH)/tests/qapi-schema/test-qapi.py "$^" >$*.test.out 2>$*.test.= err; >>> echo $$? >$*.test.exit, " TEST $*.out") >>> @diff -q $(SRC_PATH)/$*.out $*.test.out >>> @diff -q $(SRC_PATH)/$*.err $*.test.err >>> @diff -q $(SRC_PATH)/$*.exit $*.test.exit >>=20 >>> Since $^ is in $(SRC_PATH), it's like $(SRC_PATH)/foo.json. If >>> $(SRC_PATH)/foo.json has an error, the error messages duly points to >>> $(SRC_PATH)/foo.json. >>=20 >>> The "diff -q $(SRC_PATH)/$*.err $*.test.err" fails unless your SRC_PATH >>> matches the one that's encoded in tests/qapi-schema/foo.err. Is that >>> the problem you're trying to solve? >>=20 >> Right. Paths are internally stored as absolute in "qapi.py" (to check for >> include cycles), and the "base directory" is only used to show them as >> relative. I can try to change the code to retain this functionality but = without >> special-casing the tests. > Well, my fav method to check for include cycles is really simple: > 1. Estimate how many levels of inclusion you're going to need. > 2. Shift left a couple of times. > 3. Error out when inclusion depth hits that limit. > Obviously 100% reliable. File name comparisons tend to be unreliable or > unobvious :) Yes, I just wanted to error-out in a more helpful way. I really hate to have some arbitrary limit and an unhelpful (or unnecessarily long) message. > With this realpath business out of the way, file names in tests should > all be of the form $(SRC_PATH)/tests/qapi-schema/*.json, shouldn't they? > The $(SRC_PATH) prefix depends on where the user's build tree is, the > rest is fixed. We could strip the prefix from error messages with a > simple filter: > perl -pe 's,\Q$(SRC_PATH)/tests/qapi-schema/\E,tests/qapi-schema/,' Right, post-processing is the other option, silly me. 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