From patchwork Tue Jun 16 14:40:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 485037 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E004714027C for ; Wed, 17 Jun 2015 00:44:30 +1000 (AEST) Received: from localhost ([::1]:40678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4s6G-0001bl-Tc for incoming@patchwork.ozlabs.org; Tue, 16 Jun 2015 10:44:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4s5h-0000l8-CN for qemu-devel@nongnu.org; Tue, 16 Jun 2015 10:43:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4s5g-0007PB-Fa for qemu-devel@nongnu.org; Tue, 16 Jun 2015 10:43:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4s2x-0005bu-RU for qemu-devel@nongnu.org; Tue, 16 Jun 2015 10:41:03 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 61E8333E608; Tue, 16 Jun 2015 14:41:03 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5GEf1Rx003070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 16 Jun 2015 10:41:03 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 45B7F3009B5E; Tue, 16 Jun 2015 16:40:59 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Tue, 16 Jun 2015 16:40:48 +0200 Message-Id: <1434465658-20782-6-git-send-email-armbru@redhat.com> In-Reply-To: <1434465658-20782-1-git-send-email-armbru@redhat.com> References: <1434465658-20782-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: mdroth@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH v2 05/15] qapi: Fix file name in error messages for included files X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We print the name as it appears in the include expression. Tools processing error messages want it relative to the working directory. Make it so. Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake --- scripts/qapi.py | 7 +++---- tests/qapi-schema/include-cycle.err | 4 ++-- tests/qapi-schema/include-nested-err.err | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index c2eb12b..716e348 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -101,14 +101,13 @@ class QAPIExprError(Exception): class QAPISchema: - def __init__(self, fp, fname = None, include_hist = [], + def __init__(self, fp, include_hist = [], previously_included = [], incl_info = None): """ include_hist is a stack used to detect inclusion cycles previously_included is a global state used to avoid multiple inclusions of the same file""" abs_fname = os.path.abspath(fp.name) - if fname is None: - fname = fp.name + fname = fp.name self.fname = fname self.include_hist = include_hist + [(fname, abs_fname)] previously_included.append(abs_fname) @@ -148,7 +147,7 @@ class QAPISchema: except IOError, e: raise QAPIExprError(expr_info, '%s: %s' % (e.strerror, include)) - exprs_include = QAPISchema(fobj, include, self.include_hist, + exprs_include = QAPISchema(fobj, self.include_hist, previously_included, expr_info) self.exprs.extend(exprs_include.exprs) else: diff --git a/tests/qapi-schema/include-cycle.err b/tests/qapi-schema/include-cycle.err index 602cf62..bdcd07d 100644 --- a/tests/qapi-schema/include-cycle.err +++ b/tests/qapi-schema/include-cycle.err @@ -1,3 +1,3 @@ In file included from tests/qapi-schema/include-cycle.json:1: -In file included from include-cycle-b.json:1: -include-cycle-c.json:1: Inclusion loop for include-cycle.json +In file included from tests/qapi-schema/include-cycle-b.json:1: +tests/qapi-schema/include-cycle-c.json:1: Inclusion loop for include-cycle.json diff --git a/tests/qapi-schema/include-nested-err.err b/tests/qapi-schema/include-nested-err.err index 1dacbda..1b7b227 100644 --- a/tests/qapi-schema/include-nested-err.err +++ b/tests/qapi-schema/include-nested-err.err @@ -1,2 +1,2 @@ In file included from tests/qapi-schema/include-nested-err.json:1: -missing-colon.json:1:10: Expected ":" +tests/qapi-schema/missing-colon.json:1:10: Expected ":"