qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v4 1/3] qapi: Use an explicit input file


From: Lluís Vilanova
Subject: Re: [Qemu-devel] [PATCH v4 1/3] qapi: Use an explicit input file
Date: Mon, 03 Mar 2014 15:25:55 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Markus Armbruster writes:

> Lluís Vilanova <address@hidden> 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.
>> 
>> from ordereddict import OrderedDict
>> +import os
>> import sys
>> 
>> builtin_types = [
>> @@ -37,6 +38,7 @@ builtin_type_qtypes = {
>> 
>> class QAPISchemaError(Exception):
>> def __init__(self, schema, msg):
>> +        self.base = schema.error_base

> Non-obvious identifiers.  Took me some reading on to figure out that
> this is a directory.

Will fix.


>> self.fp = schema.fp
>> self.msg = msg
>> self.line = self.col = 1
>> @@ -50,12 +52,17 @@ class QAPISchemaError(Exception):
>> self.col += 1
>> 
>> def __str__(self):
>> -        return "%s:%s:%s: %s" % (self.fp.name, self.line, self.col, 
>> self.msg)
>> +        name = 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 verified
with diff. Otherwise the actual message depends on the path from which you're
running the tests.


>> 
>> class QAPISchema:
>> 
>> -    def __init__(self, fp):
>> +    def __init__(self, fp, error_base=None):
>> self.fp = fp
>> +        if error_base is None:
>> +            self.error_base = os.getcwd()
>> +        else:
>> +            self.error_base = error_base
>> self.src = fp.read()
>> if self.src == '' or self.src[-1] != '\n':
>> self.src += '\n'
>> @@ -158,9 +165,9 @@ class QAPISchema:
>> raise QAPISchemaError(self, 'Expected "{", "[" or string')
>> return expr
>> 
>> -def parse_schema(fp):
>> +def parse_schema(input_path, error_base=None):

> 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 (which
I elided). When running tests, paths are shown as relative.


Thanks,
  Lluis

-- 
 "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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]